How to install Grav CMS on Rocky Linux 9.3

To Install Grav CMS On Rocky Linux 9.3

Introduction:

Grav is a free, self-hosted Content Management System (CMS) written in PHP. It uses flat-file databases both in the backend and in the frontend. The Grav admin plugin offers an intuitive and simple interface for configuring and creating content.

Installation Steps:

Step 1: Check the OS version by using the below command

[root@Linuxhelp ~]# cat /etc/os-release
NAME="Rocky Linux"
VERSION="9.3 (Blue Onyx)"
ID="rocky"
ID_LIKE="rhel centos fedora"
VERSION_ID="9.3"
PLATFORM_ID="platform:el9"
PRETTY_NAME="Rocky Linux 9.3 (Blue Onyx)"
ANSI_COLOR="0;32"
LOGO="fedora-logo-icon"
CPE_NAME="cpe:/o:rocky:rocky:9::baseos"
HOME_URL="https://rockylinux.org/"
BUG_REPORT_URL="https://bugs.rockylinux.org/"
SUPPORT_END="2032-05-31"
ROCKY_SUPPORT_PRODUCT="Rocky-Linux-9"
ROCKY_SUPPORT_PRODUCT_VERSION="9.3"
REDHAT_SUPPORT_PRODUCT="Rocky Linux"
REDHAT_SUPPORT_PRODUCT_VERSION="9.3"

Step 2: Install Apache web server by using the below command

[root@Linuxhelp ~]# dnf install httpd -y
Rocky Linux 9 - BaseOS                                                                  5.0 kB/s | 4.1 kB     00:00    
Rocky Linux 9 - BaseOS                                                                  1.5 MB/s | 2.2 MB     00:01    
Rocky Linux 9 - AppStream                                                               4.4 kB/s | 4.5 kB     00:01    
Rocky Linux 9 - AppStream                                                               4.1 MB/s | 7.4 MB     00:01    
Rocky Linux 9 - Extras                                                                  3.6 kB/s | 2.9 kB     00:00    
Dependencies resolved.
========================================================================================================================
 Package                          Architecture          Version                          Repository                Size
========================================================================================================================
Installing:
 httpd                            x86_64                2.4.57-5.el9                     appstream                 46 k
Installing dependencies:
 apr                              x86_64                1.7.0-12.el9_3                   appstream                122 k
 apr-util                         x86_64                1.6.1-23.el9                     appstream                 94 k
httpd-tools                      x86_64                2.4.57-5.el9                     appstream                 80 k
 rocky-logos-httpd                noarch                90.14-2.el9                      appstream                 24 k
Installing weak dependencies:
 apr-util-openssl                 x86_64                1.6.1-23.el9                     appstream                 14 k
 mod_http2                        x86_64                1.15.19-5.el9                    appstream                148 k
 mod_lua                          x86_64                2.4.57-5.el9                     appstream                 60 k

Transaction Summary
========================================================================================================================
Install  11 Packages

Total download size: 2.0 M
Installed size: 6.0 M
Downloading Packages:
(1/11): rocky-logos-httpd-90.14-2.el9.noarch.rpm                                        113 kB/s |  24 kB     00:00    
(2/11): httpd-tools-2.4.57-5.el9.x86_64.rpm                                             350 kB/s |  80 kB     00:00    
(3/11): mod_lua-2.4.57-5.el9.x86_64.rpm                                                 247 kB/s |  60 kB     00:00    
------------------------------------------------------------------------------------------------------------------------
Total                                                                                   1.6 MB/s | 2.0 MB     00:01     
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                                                                1/1 
  Installing       : apr-1.7.0-12.el9_3.x86_64                                                                     1/11 
  Installing       : apr-util-bdb-1.6.1-23.el9.x86_64                                                              2/11 
  Installing       : apr-util-1.6.1-23.el9.x86_64                                                                  3/11 
  Verifying        : rocky-logos-httpd-90.14-2.el9.noarch                                                          1/11 
  Verifying        : mod_lua-2.4.57-5.el9.x86_64                                                                   2/11 
  Verifying        : httpd-tools-2.4.57-5.el9.x86_64                                                               3/11 
Installed:
  apr-1.7.0-12.el9_3.x86_64                apr-util-1.6.1-23.el9.x86_64             apr-util-bdb-1.6.1-23.el9.x86_64    
  apr-util-openssl-1.6.1-23.el9.x86_64     httpd-2.4.57-5.el9.x86_64                httpd-core-2.4.57-5.el9.x86_64      
Complete!

Step 3: Enable and start the Apache Service by using the below command

[root@Linuxhelp ~]# systemctl enable httpd
Created symlink /etc/systemd/system/multi-user.target.wants/httpd.service ? /usr/lib/systemd/system/httpd.service.
[root@Linuxhelp ~]# systemctl start httpd

Step 4: Check the status of the Apache service by using the below command

[root@Linuxhelp ~]# systemctl status httpd
? httpd.service - The Apache HTTP Server
     Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; preset: disabled)
     Active: active (running) since Wed 2023-12-20 02:53:27 IST; 20s ago
       Docs: man:httpd.service(8)
   Main PID: 215243 (httpd)
     Status: "Total requests: 0; Idle/Busy workers 100/0;Requests/sec: 0; Bytes served/sec:   0 B/sec"
      Tasks: 213 (limit: 22877)
     Memory: 29.3M
        CPU: 253ms
     CGroup: /system.slice/httpd.service
             +-215243 /usr/sbin/httpd -DFOREGROUND
             +-215244 /usr/sbin/httpd -DFOREGROUND
             +-215246 /usr/sbin/httpd -DFOREGROUND
             +-215249 /usr/sbin/httpd -DFOREGROUND
             +-215250 /usr/sbin/httpd -DFOREGROUND

Dec 20 02:53:26 Linuxhelp systemd[1]: Starting The Apache HTTP Server...
Dec 20 02:53:27 Linuxhelp httpd[215243]: AH00558: httpd: Could not reliably determine the server's fully qualified doma>
Dec 20 02:53:27 Linuxhelp systemd[1]: Started The Apache HTTP Server.
Dec 20 02:53:27 Linuxhelp httpd[215243]: Server configured, listening on: port 80

Step 5: Install php and its modules by using the below command

[root@Linuxhelp ~]# dnf install php php-fpm php-mysqlnd php-opcache php-gd php-xml php-mbstring -y php-zip
Last metadata expiration check: 0:01:49 ago on Wednesday 20 December 2023 02:52:40 AM.
Dependencies resolved.
========================================================================================================================
 Package                        Architecture         Version                              Repository               Size
========================================================================================================================
Installing:
 php                            x86_64               8.0.30-1.el9_2                       appstream               7.7 k
 php-fpm                        x86_64               8.0.30-1.el9_2                       appstream               1.6 M
 php-gd                         x86_64               8.0.30-1.el9_2                       appstream                39 k
php-pecl-zip                   x86_64               1.19.2-6.el9                         appstream                54 k
 php-xml                        x86_64               8.0.30-1.el9_2                       appstream               131 k
Installing dependencies:
 libzip                         x86_64               1.7.3-7.el9                          appstream                62 k
php-pdo                        x86_64               8.0.30-1.el9_2                       appstream                81 k
Installing weak dependencies:
 php-cli                        x86_64               8.0.30-1.el9_2                       appstream               3.1 M

Transaction Summary
========================================================================================================================
Install  13 Packages

Total download size: 6.8 M
Installed size: 36 M
Downloading Packages:
(1/13): nginx-filesystem-1.20.1-14.el9_2.1.noarch.rpm                                    22 kB/s | 8.5 kB     00:00    
(2/13): libzip-1.7.3-7.el9.x86_64.rpm                                                   137 kB/s |  62 kB     00:00    
(3/13): php-pecl-zip-1.19.2-6.el9.x86_64.rpm                                            117 kB/s |  54 kB     00:00    
------------------------------------------------------------------------------------------------------------------------
Total                                                                                   3.3 MB/s | 6.8 MB     00:02     
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                                                                1/1 
  Installing       : php-common-8.0.30-1.el9_2.x86_64                                                              1/13 
  Installing       : php-pdo-8.0.30-1.el9_2.x86_64                                                                 2/13 
  Installing       : php-xml-8.0.30-1.el9_2.x86_64                                                                 3/13 
  Verifying        : nginx-filesystem-1:1.20.1-14.el9_2.1.noarch                                                   1/13 
  Verifying        : libzip-1.7.3-7.el9.x86_64                                                                     2/13 
  Verifying        : php-pecl-zip-1.19.2-6.el9.x86_64                                                              3/13 
Installed:
  libzip-1.7.3-7.el9.x86_64           nginx-filesystem-1:1.20.1-14.el9_2.1.noarch   php-8.0.30-1.el9_2.x86_64          
  php-opcache-8.0.30-1.el9_2.x86_64   php-pdo-8.0.30-1.el9_2.x86_64                 php-pecl-zip-1.19.2-6.el9.x86_64   
  php-xml-8.0.30-1.el9_2.x86_64      
Complete!

Step 6: Download the Grav CMS Package by using the below command

[root@Linuxhelp ~]# wget https://getgrav.org/download/core/grav-admin/1.7.43
--2023-12-20 02:55:06--  https://getgrav.org/download/core/grav-admin/1.7.43
Resolving getgrav.org (getgrav.org)... 172.67.72.160, 104.26.3.204, 104.26.2.204, ...
Connecting to getgrav.org (getgrav.org)|172.67.72.160|:443... connected.
HTTP request sent, awaiting response... 302 Found
Location: https://github.com/getgrav/grav/releases/download/1.7.43/grav-admin-v1.7.43.zip [following]
--2023-12-20 02:55:07--  https://github.com/getgrav/grav/releases/download/1.7.43/grav-admin-v1.7.43.zip
Resolving github.com (github.com)... 20.207.73.82
Connecting to github.com (github.com)|20.207.73.82|:443... connected.
HTTP request sent, awaiting response... 302 Found
.githubusercontent.com)... 185.199.110.133, 185.199.108.133, 185.199.111.133, ...
Connecting to objects.githubusercontent.com (objects.githubusercontent.com)|185.199.110.133|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 18567688 (18M) [application/octet-stream]
Saving to: ‘1.7.43’
1.7.43                        100%[=================================================>]  17.71M  11.2MB/s    in 1.6s    
2023-12-20 02:55:10 (11.2 MB/s) - ‘1.7.43’ saved [18567688/18567688]

Step 7: Long list the files by using the below command

[root@Linuxhelp ~]# ll
total 18140
-rw-r--r--. 1 root root 18567688 Oct  2 22:12 1.7.43
-rw-------. 1 root root     1039 Aug 13 22:24 anaconda-ks.cfg
drwxr-xr-x. 2 root root        6 Aug 13 22:33 Desktop
drwxr-xr-x. 2 root root        6 Aug 13 22:33 Documents
drwxr-xr-x. 2 root root        6 Aug 13 22:33 Downloads
drwxr-xr-x. 2 root root        6 Aug 13 22:33 Music
drwxr-xr-x. 2 root root        6 Aug 13 22:33 Pictures
drwxr-xr-x. 2 root root        6 Aug 13 22:33 Public
drwxr-xr-x. 2 root root        6 Aug 13 22:33 Templates
drwxr-xr-x. 2 root root        6 Aug 13 22:33 Videos

Step 8: Extract the downloaded zip file by using unzip the command

[root@Linuxhelp ~]# unzip 1.7.43
Archive:  1.7.43
   creating: grav-admin/
  inflating: grav-admin/index.php    
  inflating: grav-admin/now.json     
  inflating: grav-admin/.htaccess    
   creating: grav-admin/images/
  inflating: grav-admin/images/.gitkeep  
   creating: grav-admin/assets/
  inflating: grav-admin/assets/.gitkeep  
   creating: grav-admin/.phan/
  inflating: grav-admin/.phan/config.php  
   creating: grav-admin/webserver-configs/
  inflating: grav-admin/webserver-configs/Caddyfile  
  inflating: grav-admin/webserver-configs/Caddyfile-0.8.x  
  inflating: grav-admin/webserver-configs/htaccess.txt  
  inflating: grav-admin/webserver-configs/nginx.conf  
  inflating: grav-admin/webserver-configs/lighttpd.conf  
  inflating: grav-admin/webserver-configs/web.config

Step 9: Again long list the files and check the extracted directory

[root@Linuxhelp ~]# ll
total 18144
-rw-r--r--.  1 root root 18567688 Oct  2 22:12 1.7.43
-rw-------.  1 root root     1039 Aug 13 22:24 anaconda-ks.cfg
drwxr-xr-x.  2 root root        6 Aug 13 22:33 Desktop
drwxr-xr-x.  2 root root        6 Aug 13 22:33 Documents
drwxr-xr-x.  2 root root        6 Aug 13 22:33 Downloads
drwxr-xr-x. 15 root root     4096 Oct  2 22:12 grav-admin
drwxr-xr-x.  2 root root        6 Aug 13 22:33 Music
drwxr-xr-x.  2 root root        6 Aug 13 22:33 Pictures
drwxr-xr-x.  2 root root        6 Aug 13 22:33 Public
drwxr-xr-x.  2 root root        6 Aug 13 22:33 Templates
drwxr-xr-x.  2 root root        6 Aug 13 22:33 Videos

Step 10: Rename and Move the Extracted Directory to Apache Root Directory by using the below command

[root@Linuxhelp ~]# mv grav-admin/ /var/www/grav/

Step 11: Grant Permission and Set Ownership for Grav CMS by using the below command

[root@Linuxhelp ~]# chmod -R 775 /var/www/grav/
[root@Linuxhelp ~]# chown -R apache:apache /var/www/grav/

Step 12: Create a Virtual Configuration file to Access Grav CMS by using the below command.

[root@Linuxhelp ~]# vim /etc/httpd/conf.d/grav.conf
Insert the below lines in the configuration file
<virtualhost 192.168.6.130:80>
servername  www.linuxhelp1.com
Documentroot  /var/www/grav
<Directory /var/www/grav >
AllowOverride all
allow from all
</Directory>
</virtualhost>

Step 13: Disable the SELinux by using the following command

[root@Linuxhelp ~]# setenforce 0

Step 14: Restart the Apache service to apply all changes.

[root@Linuxhelp ~]# systemctl restart httpd

Step 15: Open the Web browser and search the IP address as shown in the below image Here create a admin account to ensure your GRAV install is secure. This is the Dashboard page of Grav CMS

Conclusion:

We have reached the end of this article. In this guide, we have walked you through the steps required to install Grav CMS on Rocky Linux 9.3. Your feedback is much welcome.

FAQ
Q
Are there backup recommendations for Grav CMS?
A
Regularly back up your Grav files and configurations. Consider using tools like rsync or tar to create backups, and schedule automatic backups to prevent data loss.
Q
How do I update Grav to the latest version?
A
To update Grav, navigate to the Grav directory and use the Grav Package Manager (GPM):
cd /var/www/html/grav
bin/gpm selfupgrade
bin/gpm update
Q
What's the Grav admin interface URL after installation?
A
The Grav admin interface is typically accessed at http://your-server-ip/admin or http://your-domain/admin. Ensure that you secure the admin interface with strong credentials.
Q
Can I install Grav CMS in a subdirectory?
A
Yes, you can install Grav in a subdirectory by adjusting the Apache configuration or using a virtual host. Update the DocumentRoot and settings accordingly.
Q
What is Grav CMS?
A
Grav is an open-source flat-file CMS (Content Management System) written in PHP. It is designed to be fast, flexible, and easy to use.