How to Install Grav CMS on Fedora 28

Using a Different System?

  • How to Install Grav CMS on Ubuntu 18.04

  • How to Install Grav CMS on CentOS 7

  • How to Install Grav CMS on Debian 9

  • How to Install Grav CMS on FreeBSD 11

Are we missing a guide for your target system? Request one, or submit your own!


Grav is an open source flat-file CMS written in PHP. Grav source code is publicly hosted on GitHub. This guide will show you how to install Grav CMS on a fresh Fedora 28 Vultr instance.

Requirements

  • Web Server (Apache, Nginx, LiteSpeed or IIS). In this guide we will use Nginx.
  • PHP 5.5.9 or higher

Before you begin

Check the Fedora version.

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

Create a new non-root user account with sudo access and switch to it.

useradd -c "John Doe" johndoe && passwd johndoeusermod -aG wheel johndoesu - johndoe

NOTE: Replace johndoe with your username.

Set up the timezone.

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

Ensure that your system is up to date.

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

Install necessary packages.

sudo dnf install -y wget curl vim unzip

For simplicity, disable SELinux and Firewall.

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

Install PHP and required PHP extensions

Install PHP and 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

Check the version.

php --version

Start and enable PHP-FPM service.

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

Install and configure Nginx

Install Nginx.

sudo dnf install -y nginx

Check the version.

nginx -v

Start and enable Nginx service.

sudo systemctl start nginx.servicesudo systemctl enable nginx.service

Configure Nginx. Run sudo vim /etc/nginx/conf.d/grav.conf and populate 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;  }}

Test Nginx configuration.

sudo nginx -t

Reload Nginx.

sudo systemctl reload nginx.service

Install Grav

Create a document root directory.

sudo mkdir -p /var/www/grav

Change ownership of the /var/www/grav directory to johndoe.

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

Navigate to the document root folder.

cd /var/www/grav

Download and unzip Grav.

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

Change ownership 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 user and group to nginx. Initially, it will be set to user and group apache.

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

Restart PHP-FPM service.

sudo systemctl restart php-fpm.service

Create /var/lib/php/session/ directory and change the ownership 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 on-screen instructions. To access Grav admin append /admin to your URL.

Want to contribute?

You could earn up to $300 by adding new articles

Submit your article
Suggest an update
Request an article

No comments

Powered by Blogger.