Grav is a modern open-source flat-file CMS. This guide will help you set up Grav on a Linux server.
First, download the latest version of Grav from the official website or via the command line.
wget https://getgrav.org/download/core/grav-admin/latest -O grav-admin.zip
Unzip the downloaded package to your web server’s root directory.
unzip grav-admin.zip -d /var/www/html
Set the correct permissions for the Grav files and directories.
cd /var/www/html/grav-admin
chown -R www-data:www-data .
chmod -R 755 .
Create a new virtual host configuration for Grav.
<VirtualHost *:80>
ServerAdmin admin@example.com
DocumentRoot /var/www/html/grav-admin
ServerName example.com
ServerAlias www.example.com
<Directory /var/www/html/grav-admin>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
Enable the site and rewrite module, then restart Apache.
a2ensite example.com.conf
a2enmod rewrite
systemctl restart apache2
Create a new server block configuration for Grav.
server {
listen 80;
server_name example.com www.example.com;
root /var/www/html/grav-admin;
index index.php index.html index.htm;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
}
location ~ /\.ht {
deny all;
}
}
Enable the site and restart Nginx.
ln -s /etc/nginx/sites-available/example.com /etc/nginx/sites-enabled/
systemctl restart nginx
Open your web browser and navigate to http://example.com. You should see the Grav setup page. Follow the on-screen instructions to complete the setup.
You have successfully set up Grav on your Linux server. You can now start creating and managing your content.