ManagedCloud Servers

High performance handled and monitored by us 24/7/365. A complete solution to provide you with our in house expertise 24/7 tailored to your specific needs. We'll setup a bespoke server for your site using the latest tehnologies so you can get the most out of your hardware and get your website loading quickly and reliably. Find out more..

cPanelCloud Servers

Recommended - High performance cloud servers with no technical knowledge required. If you're hosting multiple websites already and you're looking to consolidate, or if you're looking to isolate yourself from the shared hosting environment but you don't have the time or knoweldge to manage a server, then the Managed cPanel Servers are for you. Find out more..

UnmanagedCloud Servers

Our unmanaged range gives you complete control at rock bottom prices and our cloud platform boasts super fast multipath 40Gb/s network, the latest Intel Xeon V3 CPUs and enterprise grade redundant SSDs. If you're a sysadmin look no further, we offer some of the best specification to price ratio servers available. Find out more..

Want your very own server? Get our 1GB memory, Xeon V4, 20GB SSD VPS for £10.00 / month.

View Plans

How to Install Grav CMS on CentOS 7

Grav is a free and open source content management system. Unlike other CMS, Grav does not use a database to store its data. Instead, the data is stored in flat files in markdown format. Grav is written in PHP, and it is known for its very fast performance. Grav is very popular CMS used by numerous beautiful websites around the globe.

Requirements

Grav does not require any special hardware requirements. It can be installed on servers with a small amount of RAM. All the necessary dependencies will be installed throughout the tutorial. You will need a minimal installation of CentOS 7 with root access on it. If you are logged in as a non-root user, you can run sudo -i to switch to root user.

Installing Grav CMS

Before installing any package, it is recommended you update the server and available packages. Run the following command to do so.

yum -y update

Now you will need to install Apache web server and PHP version greater than 5.5.9. To install Apache, run the following command.

yum -y install httpd

Since Grav uses a PHP version greater than 5.5.9 but the YUM repository contains PHP version 5.4 only. Hence we will need to use the Webtatic repository to install a version of PHP greater than 5.5.9. Run the following commands for installing EPEL repository as EPEL repository is required before we install Webtatic repository.

yum -y install epel-release yum -y update

Now install Webtatic repository using the following commands.

rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm yum -y update yum clean all

To install PHP 5.6 and all the required PHP modules, run the following command.

yum -y install php56w php56w-curl php56w-openssl php56w-zip php56w-apcu php56w-gd php56w-mysql php56w-xml php56w-mbstring php56w-opcache

To install PHP 7.0 and all the required PHP modules, run the following command.

yum -y install php70w php70w-curl php70w-openssl php70w-zip php70w-pecl-apcu php70w-gd php70w-mysql php70w-xml php70w-mbstring php70w-opcache

Make sure that you are using only one of the PHP versions mentioned above. Once you have PHP installed, you can check the version of PHP using the following command.

php -v

For example, for PHP 7.0, you will likely see the following output:

[root@ip-172-31-6-206 ~]# php -v
PHP 7.0.14 (cli) (built: Dec 10 2016 11:35:27) ( NTS )
Copyright (c) 1997-2016 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2016 Zend Technologies
    with Zend OPcache v7.0.14, Copyright (c) 1999-2016, by Zend Technologies

Make sure that your PHP version is not older than 5.5.9. Now start Apache web server and enable it to start at boot time using the following commands:

systemctl start httpd systemctl enable httpd

Now you will need to Enable Mod_rewrite by editing /etc/httpd/conf/httpd.conf using your favorite text editor.

nano /etc/httpd/conf/httpd.conf

If you do not have nano installed, you can run yum -y install nano to install nano editor. Find the following line under <Directory "/var/www/html"> block.

AllowOverride None

Change it to AllowOverride All.

Now restart your web server using the following command.

systemctl restart httpd

There are many ways to download Grav CMS. You can download the archive from Grav website, or you can use composer to install the package, or you can download the repository from Github.

Grav provides many types of pre-built zip archive. You can choose to download the Grav core package only. You can also decide to download the core package with admin plugin. Admin plugin provides the functionality of administering Grav through the web browser. You can also download the skeleton packages, which is an all in one package consisting of Grav core module and the themes, plugin and sample pages. At the time of writing this tutorial, the latest version of Grav is 1.1.12. You can check for the updated links at Grav Downloads page. Make sure that you only download and extract any one of these three types of packages. You can use all in one skeleton packages to get started quickly as Grav provides many different skeleton packages.

To download the Grav core package only run the following command.

cd /opt wget https://github.com/getgrav/grav/releases/download/1.1.12/grav-v1.1.12.zip

Now extract the files using the following command.

unzip grav*.zip

If you don't have unzip installed, run yum -y install unzip. The above command will extract Grav in grav directory, to move all the files including .htaccess to the web root directory, run the following command.

mv /opt/grav/{.[!.],}* /var/www/html

To download the Grav package with admin plugin, run the following command.

wget https://github.com/getgrav/grav/releases/download/1.1.12/grav-admin-v1.1.12.zip

Now extract the files using the following command.

unzip grav*.zip

The above command will extract Grav in grav-admin directory, to move all the files including .htaccess to the web root directory, run the following command.

mv /opt/grav-admin/{.[!.],}* /var/www/html

To download any skeleton or all in one package, you will need to go to Scalatons downloads page. Select any package you wish to download and download the package using wget command. For example, the command below will download Grav Skeleton Course Hub Site.

cd /opt wget https://github.com/hibbitts-design/grav-skeleton-course-hub/releases/download/v1.4.1/grav-skeleton-course-hub-site.zip

Now extract the files using the following command.

unzip grav-skeleton-course-hub-site.zip

The above command will extract Grav in grav-skeleton-course-hub-site directory, to move all the files including .htaccess to the web root directory, run the following command.

mv /opt/grav-skeleton-course-hub-site/{.[!.],}* /var/www/html

Once you have downloaded and moved any one of the above packages, you need to configure SELinux settings. To temporary disable SELinux, run the following command.

setenforce 0

To completely disable the SELinux you will need to edit /etc/selinux/config file.

nano /etc/selinux/config

If you don't have nano installed, you can install it using yum -y install nano Find the following line:

SELINUX=enforcing

Change it to:

SELINUX=disabled

Now you will need to reboot your server so that the new configuration can take effect. Once the server is rebooted, you will need to provide the ownership of the application to web server user using the following command.

chown -R apache:apache /var/www/html

You can now browse the following URL using your favorite web browser.

http://yourServerIP/

or

http://yourdomain.com/

If you have downloaded only the Grav core package, you will see the following instruction page.

If you have downloaded Grav with Admin plugin or Grav Skeleton package, then you will see the following interface to create an admin user.

Provide the required information like username, email, password, name and title. Click Create User button, and it will create the administrator user, and you will be automatically logged into to your admin dashboard.

Managing the Grav Installation

Grav provides a command line tool to manage the Grav installation. You can use this tool to install themes or plugins or to upgrade the installation. You will need to run the command in the root of the Grav installation, in our case, it is /var/www/html. Navigate to the above directory using the following command.

cd /var/www/html

To see a list of available themes and plugins, run the following command.

bin/gpm index

You will see output similar to this.

[root@ip-172-31-6-206 html]# bin/gpm index

GPM Releases Configuration: Stable

PLUGINS [ 157 ] ------------------------------------------------------------------------------------- | Count | Name | Slug | Version | Installed | ===================================================================================== | 1 | Twig Cache | twigcache | v1.2.0 | not installed | | 2 | Staticfilecache | staticfilecache | v1.0.0 | not installed | | 3 | Srcset Fallback | srcset-fallback | v1.0.0 | not installed | | 4 | Embed | embed | v1.0.0 | not installed | | 5 | Cachebuster | cachebuster | v1.0.0 | not installed |

.....

To get more information about the theme or plugin, run the following command.

bin/gpm info <name_of_plugin/theme>

For example, the following command will provide the information about Deliver theme.

bin/gpm info deliver

The output of the command will be similar to shown below.

[root@ip-172-31-6-206 html]# bin/gpm info deliver

GPM Releases Configuration: Stable

Found package 'deliver' under the 'Themes' section

Deliver [deliver] ----------------- Deliver theme is a port of the Michael Reimer's Deliver Free PSD theme.

Author : Team Grav <devs@getgrav.org> <http://getgrav.org> Version : 1.6.2 Keywords : deliver, theme, modern, fast, responsive, html5, css3 Last Update : Tue, 16 Sep 2014, 00:07:16, +00:00 Homepage : https://github.com/getgrav/grav-theme-deliver Demo : http://demo.getgrav.org/deliver-skeleton/ Repository : https://github.com/getgrav/grav-theme-deliver Bugs : https://github.com/getgrav/grav-theme-deliver/issues Download : https://github.com/getgrav/grav-theme-deliver/zipball/1.6.2 License : MIT

To install a plugin or theme, run the following command.

bin/gpm install <name_of_plugin/theme>

For example the command below will install Deliver theme.

bin/gpm install deliver

To update the Grav core package, run the following command.

bin/gpm selfupgrade -f

To update Grav core along with all the other plugins and themes, run the following command.

bin/gpm update -f

Adding Content

Grav stores its pages in /home/pages directory. If you navigate to the directory, you will see directories with numbers. Each directory represents a page in Grav site, the content of the page is stored in default.md file. The numbers in the name of the directory tells the order of the page, for example, 01 will always be ahead of 02. If you have just installed Grav core, there will be only one directory, 01.home. The text portion of the name of directory tells the URL of the page.

To create a new page you will need to create a new directory. Run the following command to do so.

cd /var/www/html/user/pages mkdir 02.newpage

Now create the default.md file using the following command.

nano 02.newpage/default.md

The pages in Grav CMS are created in Markdown format. Add the following sample text into the file.

---
title: New Page
menu: New Page
---
# Hi There, It's a New Page!

This is sample content, you can **easily** add the content using *Markdown* format.

## It's just a sub heading.

Save the file and exit from the editor. The content between the dashed line --- are page headers written in a very simple format called YAML. It provides page headers in Markdown files.

You can now refresh your web page to see a new menu item, navigate to the page after clicking on the menu item.

Conclusion

In this tutorial, we have learned how to install Grav CMS in CentOS 7. We also learned how to use the command line tool gpm to manage the Grav installation. We also added a new page to our Grav website.

Want your very own server? Get our 1GB memory, Xeon V4, 20GB SSD VPS for £10.00 / month.

View Plans