Setup Grav CMS On Ubuntu 14


Grav is a modern flat file CMS that is fast, extensible and open-source. It’s easy to use and has a host of impressive plugins, one of which is an admin for it.


Spin up a Ubuntu 14 Vultr instance and run below commands to install some essential utilities, PHP 7, and Nginx. Note: You can put this portion in a startup script and spin up your using it to make the process faster.

export DEBIAN_FRONTEND=noninteractivesudo apt-get update -ysudo apt-get upgrade -y# install some essential toolssudo apt-get install -y acl curl git software-properties-common unzip zip# install php7sudo apt-add-repository ppa:ondrej/php -ysudo apt-get update -ysudo apt-get install -y --force-yes php7.0-cli php-curl php-gd php7.0-zip php7.0-mcrypt php-apcu php-xml php-mbstring php-intl# install nginxsudo apt-get install -y --force-yes nginxsudo apt-get install -y --force-yes php7.0-fpm# tweak php ini filesudo sed -i "s/;cgi.fix_pathinfo=1/cgi.fix_pathinfo=0/" /etc/php/7.0/cli/php.inisudo sed -i "s/;cgi.fix_pathinfo=1/cgi.fix_pathinfo=0/" /etc/php/7.0/fpm/php.ini# remove default site setup and restart nginxrm -f /etc/nginx/sites-enabled/*rm -f /etc/nginx/sites-available/*service nginx restart

Configure Server for Grav

SSH into your server as root from your terminal.

ssh root@[vultr-instance-ip]

Note: Ideally you will want to secure ssh as prescribed in on a public facing site

Create a directory to hold grav site

# create directorymkdir -p /sites/grav && cd /sites/grav# set permissionschmod -R 775 /siteschown -R www-data:www-data /siteschmod -R g+s /sites# put temporary index fileecho "<h3>Welcome Home...</h3>" >> index.phpecho "<?php phpinfo();" >> index.php

Setup a nginx host to for the site:

  1. cd into nginx sites available directory cd /etc/nginx/sites-available/
  2. Create a config file for grav site sudo nano grav
  3. Paste below content into file, then save and exit (Ctrl+X -> Y -> hit Enter)

    server {    listen 80;    server_name; #NOTE: should be replaced with your domain name eventually    root /sites/grav;    index index.html index.htm index.php;    charset utf-8;    location / {        try_files $uri $uri/ /index.php$is_args$args;    }    location ~ /.php$ {        fastcgi_split_path_info ^(.+/.php)(/.+)$;        fastcgi_pass unix:/run/php/php7.0-fpm.sock;        fastcgi_index index.php;        include fastcgi_params;    }}
  4. Enable grav config

    sudo ln -s /etc/nginx/sites-available/grav /etc/nginx/sites-enabled/grav
  5. Restart nginx and php-fpm

    sudo service nginx restartsudo service php7.0-fpm restart
  6. Update servers host file sudo bash -c "echo '' >> /etc/hosts" _(Note: should be replaced with your domain name eventually)

  7. You should be able to browse to http://[vultr-instance-ip] and see a “Welcome Home” message along with some info on the version of PHP installed (if you don’t see this or are using as used above, you’ll have to perform additional step below to add a host entry for on your local machine)

Update your local machine’s host file (Optional)

Add below entry to your host file.


Your host file should be located in one of the listed areas below depending on what OS you are running.

  • Windows – c:/windows/system32/drivers/etc/hosts
  • Linux – /etc/hosts
  • Mac – /private/etc/hosts

Install Grav

  1. Install composer and create a grav project.

    # install composersudo curl -sS | phpsudo mv composer.phar /usr/local/bin/composer# create grav projectcd /sitesmv grav grav-testcomposer create-project getgrav/grav# below is only needed if you logged as sudo# ideally you should secure ssh as prescribed in -R www-data:www-data /sites
  2. Browse to (or your domain) and you should be greeted with a welcome page that says “Grav is Running!”.

Written by Lami Adabonyan

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.