Setup Grav CMS On Ubuntu 14

Modified on: Thu, Apr 7, 2016 at 12:32 pm EST


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=noninteractive
sudo apt-get update -y
sudo apt-get upgrade -y

# install some essential tools
sudo apt-get install -y acl curl git software-properties-common unzip zip

# install php7
sudo apt-add-repository ppa:ondrej/php -y
sudo apt-get update -y
sudo 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 nginx
sudo apt-get install -y --force-yes nginx
sudo apt-get install -y --force-yes php7.0-fpm

# tweak php ini file
sudo sed -i "s/;cgi.fix_pathinfo=1/cgi.fix_pathinfo=0/" /etc/php/7.0/cli/php.ini
sudo sed -i "s/;cgi.fix_pathinfo=1/cgi.fix_pathinfo=0/" /etc/php/7.0/fpm/php.ini

# remove default site setup and restart nginx
rm -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 directory
mkdir -p /sites/grav && cd /sites/grav

# set permissions
chmod -R 775 /sites
chown -R www-data:www-data /sites
chmod -R g+s /sites

# put temporary index file
echo "<h3>Welcome Home...</h3>" >> index.php
echo "<?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 restart
    sudo 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 composer
    sudo curl -sS | php
    sudo mv composer.phar /usr/local/bin/composer
    # create grav project
    cd /sites
    mv grav grav-test
    composer create-project getgrav/grav
    # below is only needed if you logged as sudo
    # ideally you should secure ssh as prescribed in
    chown -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!".

Get started in the SSD Cloud!