Introduction
Grav is an open-source Content Management System (CMS) used for creating and managing website content. It's based on PHP and uses a flat-file database for storing its data. It focuses majorly on performance, speed, and simplicity. Some features are:
- Content creation using a markdown editor.
- One-click installs for extensions and themes.
- Search Engine Optimization friendly through configuration.
- Content filtering uses unlimited taxonomies such as tags, categories, etc.
- Multi-language support.
- Backups and restores of your data when changing hosts.
- Dynamic image manipulation.
- Theme customization.
- Version control support.
You can read more on the available features.
This article explains how to install Grav CMS on FreeBSD 13.0 server.
Prerequisites
Perform the following steps first:
- Deploy a Rcs FreeBSD 13.0 Server.
- SSH into the server you deployed.
- Create a non-root user with sudo access.
Step 1. Install Required Packages
Update the system package list.
$ pkg update
Install required packages.
$ pkg install -y sudo nano unzip wget bash
Install PHP 7.4 and more modules.
$ sudo pkg install -y apache24 mysql80-server mod_php74 php74 php74-session php74-curl php74-xml php74-zip php74-mbstring php74-ctype php74-imap php74-simplexml php74-tokenizer php74-xmlreader php74-xmlwriter php74-pear php74-fileinfo php74-json php74-phar php74-exif php74-iconv php74-mysqli php74-pdo_mysql php74-dom php74-filter php74-intl php74-openssl php74-intl php74-opcache php74-gd php74-zlib php74-openssl
Enable PHP-FPM service.
$ sudo sysrc php_fpm_enable=yes
Start PHP-FPM service.
$ sudo service php-fpm start
Copy the sample PHP configuration file.
$ sudo cp /usr/local/etc/php.ini-production /usr/local/etc/php.ini
Step 2. Install Grav CMS
Download the latest version of Grav CMS. Please visit official release page to find the latest releases.
$ wget -O grav.zip https://getgrav.org/download/core/grav-admin/1.7.30
Unzip the downloaded zip files.
$ sudo unzip grav.zip
Rename the extracted directory.
$ sudo mv grav-admin grav
Move the renamed directory to the web root.
$ sudo mv grav /usr/local/www/apache24/data/
Delete the downloaded zip files after unzipping it.
$ sudo rm grav.zip
Change ownership of the installation directory.
$ sudo chown -R www:www /usr/local/www/apache24/data/grav
Change access permissions for the directory.
$ sudo chmod -R 755 /usr/local/www/apache24/data/grav
Step 3. Configure Apache2
Enable Apache service to start on system boot.
$ sudo sysrc apache24_enable=yes
Start Apache service.
$ sudo service apache24 start
Create a configuration file to allow Apache to work with PHP.
$ sudo nano /usr/local/etc/apache24/modules.d/001_mod-php.conf
Add the following lines of code to the file. Then, save and close the file.
<IfModule dir_module>
DirectoryIndex index.php index.html
<FilesMatch "\.php$">
SetHandler application/x-httpd-php
</FilesMatch>
<FilesMatch "\.phps$">
SetHandler application/x-httpd-php-source
</FilesMatch>
</IfModule>
Create Apache configuration file for Grav CMS named grav.conf
.
$ sudo nano /usr/local/etc/apache24/Includes/grav.conf
Add the below code to the file. Save and close the file.
<VirtualHost *:80>
ServerAdmin admin@example.com
DocumentRoot /usr/local/www/apache24/data/grav
ServerName example.com
<Directory /usr/local/www/apache24/data/grav/>
Options -Indexes +FollowSymLinks
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
Test the configuration.
$ sudo apachectl configtest
Enable mod_rewrite
by editing the apache configuration file.
$ sudo nano /usr/local/etc/apache24/httpd.conf
Comment out the following line. Then, save and close the file:
LoadModule rewrite_module libexec/apache24/mod_rewrite.so
Restart Apache service.
$ sudo service apache24 restart
Step 4. Access Grav CMS
To access the Grav CMS Web Interface, go to your browser and visit http://Server_IP/
. For example:
http://192.0.2.11/
Conclusion
You have installed Grav CMS on your FreeBSD 13.0 server. Access the installation page, and follow the wizard to set up the administrator account. You can now check the official documentation to learn more about using Grav CMS.