How to install Grav CMS with Nginx on Fedora 30

How to install Grav CMS with Nginx on Fedora 30

Grav is a fast, simple, and flexible file-based CMS platform. Grav comes with a powerful package management system that makes it easy to install and upgrade plugins and themes, as well as simple updates to Grav itself.

Grav’s underlying architecture is designed using well-established, state-of-the-art technology to ensure that Grav is easy to use and easy to extend. Some of these key technologies include:

  • Twig template production: for reliable control of the user interface
  • Markdown: Easily create content
  • YAML: for simple configuration
  • Parsedown: Fast Markdown and Markdown Extra support
  • Principle caching: performance layer
  • Simple dependency injection container: extensibility and maintainability
  • Symfony Event Dispatcher: for plugin event processing
  • Symfony console: for the CLI interface
  • Gregwar image library: for dynamic image processing

In this tutorial, we will use NGINX as a web server to complete the installation and setup of Grav CMS on a Fedora 30 system, and you can choose to use the client and Let’s Encrypt certification authority to add SSL support to protect the transport layer.


Grav is carefully designed with almost no requirements. Grav is built using plain text files and can be used for your content. No database is required.

Make sure your system meets the following requirements:

  • Web server (Apache, Nginx, LiteSpeed, Lightly, IIS, etc.) We will use NGINX.
  • PHP version 7.1.3 or higher


  • An operating system running Fedora 30.
  • A non-root user with sudo privileges.

Preliminary steps

Check your Fedora version:

cat /etc/fedora-release# 

Set time zone:

timedatectl list-timezonessudo timedatectl set-timezone 'Region/City'

Update your operating system package (software). This is an important first step because it ensures that you have the latest updates and security fixes for the operating system’s default packages:

sudo dnf update -y

Install some basic packages that are required for basic management of the Fedora operating system:

sudo dnf install -y curl wget vim git unzip socat bash-completion epel-release

Step 1-install PHP and necessary PHP extensions

Install PHP and required PHP extensions:

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

To display PHP compiled in the module, run:

php -mctypecurlexiffileinfo. . .. . .

Check PHP version:

php --version# PHP 7.3.17 (cli) (built: May 13 2019 18:03:04) ( NTS )# Copyright (c) 1997-2018 The PHP Group# Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies#     with Zend OPcache v7.2.17, Copyright (c) 1999-2018, by Zend Technologies

Start and enable the PHP-FPM service:

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

Step 2-Install the client and obtain the “Let’s Encrypt” certificate (optional)

There is no need to use HTTPS to protect the forum, but it is a good practice to keep your site traffic secure. In order to obtain a TLS certificate from Let’s Encrypt, we will use the client. is a simple UNIX shell software for obtaining TLS certificates from Let’s Encrypt with zero dependencies.

Download and install

sudo su - rootgit clone ./ --install --accountemail [email protected]source ~/.bashrccd ~

Check the version: --version# v2.8.2

Gain RSA with ECC / ECDSA Your domain / hostname certificate:

# RSA --issue --standalone -d --keylength 2048# --issue --standalone -d --keylength ec-256

If you want to test with a fake certificate, you can add --staging Mark the above command.

After running the above command, your certificate and key will be located at:

  • For RSA: /home/username/ table of Contents.
  • For ECC / ECDSA: /home/username/example.com_ecc table of Contents.

To list the certificates you issued, you can run: --list

Create a directory to store your certificates. We will use /etc/letsencrypt table of Contents.

mkdir -p /etc/letsecnrypt/example.comsudo mkdir -p /etc/letsencrypt/example.com_ecc

Install / copy the certificate into the / etc / letsencrypt directory.

# --install-cert -d --cert-file /etc/letsencrypt/ --key-file /etc/letsencrypt/ --fullchain-file /etc/letsencrypt/ --reloadcmd "sudo systemctl reload nginx.service"# ECC/ --install-cert -d --ecc --cert-file /etc/letsencrypt/example.com_ecc/cert.pem --key-file /etc/letsencrypt/example.com_ecc/private.key --fullchain-file /etc/letsencrypt/example.com_ecc/fullchain.pem --reloadcmd "sudo systemctl reload nginx.service"

All certificates are automatically renewed every 60 days.

After obtaining the certificate, exit from the root user and return to the regular sudo user:


Step 3-install and configure NGINX

Install NGINX:

sudo dnf install -y nginx

Check NGINX version:

nginx -v# nginx version: nginx/1.14.2

Start and enable the NGINX service:

sudo systemctl start nginx.servicesudo systemctl enable nginx.service

Configure NGINX for Grav. Run sudo vim /etc/nginx/conf.d/grav.conf And add the following configuration.

server {
  listen 80;
  listen 443 ssl;
  root /var/www/grav;
  ssl_certificate /etc/letsencrypt/;  ssl_certificate_key /etc/letsencrypt/;  ssl_certificate /etc/letsencrypt/example.com_ecc/fullchain.pem;  ssl_certificate_key /etc/letsencrypt/example.com_ecc/private.key;
  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;


Check the NGINX configuration for syntax errors:

sudo nginx -t

Reload the NGINX service:

sudo systemctl reload nginx.service

Step 4-install Grav CMS

Create a document root directory:

sudo mkdir -p /var/www/grav

Change ownership /var/www/grav Directory of the currently logged in user, in my case the user is johndoe:

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

Navigate to the document root folder:

cd /var/www/grav

Download and extract Grav:

wget 1.6.9mv grav-admin/* . && mv grav-admin/.* .rm -rf grav-admin 1.6.9

note: Version 1.6.9 is the current version and may be different as you read this. Please check the Grav website for the latest information.

Change ownership /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 users and groups to nginx. Initially it was set up as users and groups apache:

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

Restart the PHP-FPM service.

sudo systemctl restart php-fpm.service

Create /var/lib/php/session/ Directory and change ownership to nginx:

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

turn on In a web browser, follow the instructions on the screen. To access Grav admin append /admin To your URL.

Step 5-complete Grav setup

Create a Grav admin user:

Once created, you will be redirected to the management dashboard:

Grav CMS Dashboard