Skip to content

Powered by Grav + Helios

DigitalOcean

DigitalOcean

Perhaps the most popular and most widely used of all the VPS providers out there, DigitalOcean provides a range of VPS options. Starting at $5/mo for a 1 CPU, 1024MB system up to $960/mo for a 32 CPU, 192GB setup, DigitalOcean has solutions that can scale with you. All their servers are built with RAID SSD drives, modern hexa-core hardware, KVM Virtualization, and reliable Tier-1 bandwidth to ensure maximum performance. They are a fantastic option for hosting your Grav-based site.

After creating an account and depositing some credit into it, you can get started. DigitalOcean let's you create Droplets that represent a VPS instance. You simple click the Create Droplet button in your Control Panel, and fill in the form:

Simply pick a name for your Droplet, and choose a size based on price and server needs. Grav will run fine on any configuration even the base $5/mo option will run Grav quickly and efficiently.

Next, select a Region where your VPS will be located. It's best to pick a region that is going to serve your target audience the best. If the server is for development purposes only, pick one that is located closest to you.

Lastly you will need to select an Image to install. DigitalOcean lets you choose from a wide variety of stock Linux distributions, as well as complete Applications and even prior saved snapshots. For the purpose of this guide, we'll install the latest Ubuntu 24.04 LTS which is very popular and very well supported.

You can leave all the other options at their defaults. After clicking Create Droplet your Droplet will be created within 55 seconds, and you will see it listed in your list of Droplets. You should receive an email with your root password. Clicking on the Droplet you just created you will see various options.

The Access tab in the Droplet Manager allows you to quickly log on to your instance, but using SSH is a more enjoyable experience. Public key authentication is also recommended, and DigitalOcean has great SSH public key authentication documentation that walks you through the steps required.


This guide covers installing Grav on a fresh Ubuntu 24.04 LTS (Noble Numbat) VPS with Nginx and PHP 8.3.

Initial Server Setup

First, set up a local /etc/hosts entry to give your server IP a friendly name such as vultr.dev. This makes it easier to SSH to your server:

BASH

Update System Packages

After connecting as root, update all installed packages:

BASH
apt update && apt upgrade -y

Install Required Packages

Install Nginx, PHP 8.3, and essential extensions for Grav:

BASH
apt install -y vim zip unzip nginx git \
    php8.3-fpm php8.3-cli php8.3-gd php8.3-curl \
    php8.3-mbstring php8.3-xml php8.3-zip php8.3-intl php8.3-apcu

This installs:

  • Nginx - High-performance web server
  • PHP 8.3-FPM - FastCGI Process Manager for PHP
  • PHP Extensions - Required by Grav for image processing, caching, etc.

Configure PHP-FPM

Edit the PHP configuration for better security:

BASH
vim /etc/php/8.3/fpm/php.ini

Find cgi.fix_pathinfo (use /cgi.fix_pathinfo in vim to search), uncomment it and set to 0:

INI
cgi.fix_pathinfo=0

Warning

This setting prevents PHP from executing the closest matching file when the requested file isn't found - a significant security risk if left enabled.

Create a Dedicated User

Create a grav user to run the site (don't run web apps as root):

BASH
adduser grav

Provide a strong password when prompted.

Configure PHP-FPM Pool

Create a dedicated PHP-FPM pool for the grav user:

BASH
cd /etc/php/8.3/fpm/pool.d
mv www.conf www.conf.bak
vim grav.conf

Add the following configuration:

grav.conf
 1[grav]
 2user = grav
 3group = grav
 4
 5listen = /run/php/php8.3-fpm-grav.sock
 6
 7listen.owner = www-data
 8listen.group = www-data
 9
10pm = dynamic
11pm.max_children = 10
12pm.start_servers = 3
13pm.min_spare_servers = 2
14pm.max_spare_servers = 5
15
16chdir = /

Create Web Directory

Switch to the grav user and create the web directory:

BASH
su - grav
mkdir -p ~/www/html

Create a test file to verify the setup:

BASH
echo '<?php phpinfo();' > ~/www/html/info.php
exit

Configure Nginx

Create the Nginx server block:

BASH
vim /etc/nginx/sites-available/grav

Add the following configuration:

grav
 1server {
 2    listen 80;
 3    index index.html index.php;
 4
 5    ## Begin - Server Info
 6    root /home/grav/www/html;
 7    server_name _;
 8    ## End - Server Info
 9
10    ## Begin - Index
11    location / {
12        try_files $uri $uri/ /index.php?$query_string;
13    }
14    ## End - Index
15
16    ## Begin - Security
17    # deny all direct access for these folders
18    location ~* /(\.git|cache|bin|logs|backup|tests)/.*$ { return 403; }
19    # deny running scripts inside core system folders
20    location ~* /(system|vendor)/.*\.(txt|xml|md|html|yaml|yml|php|pl|py|cgi|twig|sh|bat)$ { return 403; }
21    # deny running scripts inside user folder
22    location ~* /user/.*\.(txt|md|yaml|yml|php|pl|py|cgi|twig|sh|bat)$ { return 403; }
23    # deny access to specific files in the root folder
24    location ~ /(LICENSE\.txt|composer\.lock|composer\.json|nginx\.conf|web\.config|htaccess\.txt|\.htaccess) { return 403; }
25    ## End - Security
26
27    ## Begin - PHP
28    location ~ \.php$ {
29        fastcgi_pass unix:/run/php/php8.3-fpm-grav.sock;
30        fastcgi_split_path_info ^(.+\.php)(/.+)$;
31        fastcgi_index index.php;
32        include fastcgi_params;
33        fastcgi_param SCRIPT_FILENAME $document_root/$fastcgi_script_name;
34    }
35    ## End - PHP
36}

Enable the site and remove the default:

BASH
ln -s /etc/nginx/sites-available/grav /etc/nginx/sites-enabled/
rm /etc/nginx/sites-enabled/default

Test the configuration:

BASH
nginx -t

You should see:

TXT
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful

Start Services

Restart Nginx and PHP-FPM:

BASH
systemctl restart nginx
systemctl restart php8.3-fpm

Verify PHP is working by visiting http://YOUR_SERVER_IP/info.php. You should see the PHP info page with PHP 8.3 and APCu listed.

Caution

Remove the info.php file after testing: rm /home/grav/www/html/info.php

Install Grav

Switch to the grav user and download Grav:

BASH
su - grav
cd ~/www
wget -O grav.zip https://getgrav.org/download/core/grav/latest
unzip grav.zip
rm -rf html
mv grav html

Verify Installation

Visit http://YOUR_SERVER_IP and you should see the Grav is Running! page.

Test CLI Tools

Since you're running as the grav user, CLI tools work out of the box:

BASH
cd ~/www/html
bin/grav clear

Output:

TXT
Clearing cache

Cleared:  cache/twig/*
Cleared:  cache/compiled/*

Touched: /home/grav/www/html/user/config/system.yaml

GPM commands also work:

BASH
bin/gpm index

Optional: Install Admin Plugin

To install the Grav Admin panel:

BASH
bin/gpm install admin

Then visit http://YOUR_SERVER_IP/admin to create your admin account.

Optional: Enable HTTPS with Let's Encrypt

For production sites, enable HTTPS using Certbot:

BASH
apt install -y certbot python3-certbot-nginx
certbot --nginx -d yourdomain.com

Certbot will automatically configure Nginx for SSL and set up auto-renewal.

Next Steps