How to install Grav CMS on Fedora 28

The Grav administration plugin is a very simple and intuitive interface. It makes setting up content creation very enjoyable and easy! This CMS is open source, and written in PHP.

Checking Fedora Version

Before we begin the installation of Grav CMS, we must check the version of Fedora

cat /etc/fedora-release
# Fedora release 28 (Twenty Eight)

Next, you need to create a new account, it is important that it is non-root and go to it

useradd -c "Alex Moure" alexmoure && passwd johndoe
usermod -aG wheel alexmoure
su - alexmoure

Note! In this manual, replace “alexmoure” with your username

Set the time zone

timedatectl list-timezones
sudo timedatectl set-timezone 'Region/City'

Make sure that your system is up to date

sudo dnf check-upgrade || sudo dnf upgrade -y

Install the necessary packages

sudo dnf install -y wget curl vim unzip

For easier operation, disable SELinux and Firewall

sudo setenforce 0 ; sudo systemctl stop firewalld ; sudo systemctl disable firewalld

Install PHP and the necessary PHP extensions

To install, enter the following command:

sudo dnf install -y php-cli php-fpm php-common php-curl php-gd php-json php-mbstring php-xml php-zip php-opcache php-pecl-apcu

Check the version

php --version

Next, you need to start and enable the PHP-FPM service

sudo systemctl start php-fpm.service
sudo systemctl enable php-fpm.service

Install and configure Nginx

To install, enter the following:

sudo dnf install -y nginx

Check the version of Nginx

nginx -v

Launch and enable the Nginx service

sudo systemctl start nginx.service
sudo systemctl enable nginx.servic

Then configure Nginx. Run sudo vim /etc/nginx/conf.d/grav.conf and fill in the file with the following configuration

server {

  listen 80;

  server_name example.com;
  root /var/www/grav;

  index index.html index.php;

  location / {
    try_files $uri $uri/ /index.php?$query_string;
  }

  location ~* /(\.git|cache|bin|logs|backup|tests)/.*$ { return 403; }
  location ~* /(system|vendor)/.*\.(txt|xml|md|html|yaml|yml|php|pl|py|cgi|twig|sh|bat)$ { return 403; }
  location ~* /user/.*\.(txt|md|yaml|yml|php|pl|py|cgi|twig|sh|bat)$ { return 403; }
  location ~ /(LICENSE\.txt|composer\.lock|composer\.json|nginx\.conf|web\.config|htaccess\.txt|\.htaccess) { return 403; }

  location ~ \.php$ {
    fastcgi_pass unix:/run/php-fpm/www.sock;
    fastcgi_split_path_info ^(.+\.php)(/.+)$;
    fastcgi_index index.php;
    include fastcgi_params;
    fastcgi_param SCRIPT_FILENAME $document_root/$fastcgi_script_name;
  }

}

Then check the configuration of Nginx

sudo nginx -t

Restart Nginx

sudo systemctl reload nginx.service

Install Grav

Create the root directory of the document

sudo mkdir -p /var/www/grav

Change the owner of the /var/www/grav directory to alexmoure

sudo chown -R alexmoure:alexmoure /var/www/grav

Go to the root folder of the document

cd /var/www/grav

Then download and unzip Grav

wget https://getgrav.org/download/core/grav-admin/1.4.8
unzip 1.4.8
mv grav-admin/* . && mv grav-admin/.* .
rm -rf grav-admin 1.4.8

After successful unpacking Change the owner of the /var/www/grav directory to nginx

sudo chown -R nginx:nginx /var/www/grav

Run sudo vim /etc/php-fpm.d/www.conf and set the user and group to nginx

sudo vim /etc/php-fpm.d/www.conf
# user = nginx
# group = nginx

Restart the PHP-FPM service

sudo systemctl restart php-fpm.service

Create /var/lib/php/session/ directory and change the owner to nginx

sudo mkdir -p /var/lib/php/session/ && sudo chown -R nginx:nginx /var/lib/php/session/

Open http://example.com in your web browser and follow the instructions on the screen, so that you have access to Grav admin add /admin your URL

Was this article helpful?

Related Articles

Leave A Comment?