Rocky Linux is an open-source enterprise operating system designed to be 100% bug-for-bug compatible with Red Hat Enterprise Linux. This tutorial explains how to set up the environment for running Drupal 10 and Drupal 11 sites.
1. Show OS Info and run update
sudo cat /etc/redhat-release
sudo dnf update -y
2. Install Nginx
sudo dnf install nginx
sudo systemctl enable --now nginx
nginx -v
Refer: https://docs.rockylinux.org/guides/web/nginx-mainline/
3. Install PHP 8.3
sudo dnf module list php
This command lists the available PHP modules
sudo dnf install
https://rpms.remirepo.net/enterprise/remi-release-9.rpm
-y
Enable Remi repository
sudo dnf config-manager --set-enabled remi
Install php package
sudo dnf install php php-common php-mbstring php-xmlrpc php-soap php-gd php-xml php-intl php-mysql php-cli php-zip php-curl php-apcu php-fpm php-bcmath
sudo dnf module enable php:remi-8.3 -y
sudo dnf install php php-common php-mbstring php-xmlrpc php-soap php-gd php-xml php-intl php-mysql php-cli php-zip php-curl php-apcu php-fpm php-bcmath
Enable php-fpm
sudo systemctl enable --now php-fpm
sudo systemctl status php-fpm
Change default user/group apache to nginx
sudo vi /etc/php-fpm.d/www.conf
Refer: https://docs.rockylinux.org/guides/web/php/#__tabbed_1_1
4. Install MariaDB
sudo dnf install mariadb-server
sudo systemctl enable mariadb
sudo dnf module enable mariadb:10.11
mysql_secure_installation
https://docs.rockylinux.org/guides/database/database_mariadb-server/
5. Configure Nginx for Multiple Websites
cd /etc/nginx
sudo mkdir sites-available
sudo mkdir sites-enabled
sudo vi nginx.conf
Add include /etc/nginx/sites-enabled/*.conf;
sudo vi sites-available/drupal.conf
cd sites-enabled
sudo ln -s ../sites-available/drupal.conf
sudo nginx -t
sudo service nginx restart
6. Configure SSL Certificates Using Certbot
sudo dnf install snapd
sudo snap install --classic certbot
sudo ln -s /snap/bin/certbot /usr/bin/certbot
sudo certbot --nginx
Note:
By default, SELinux is enabled on Rocky Linux. However, SELinux blocks Nginx from serving content located in /home
, which results in an "Access Denied" error when accessing the website. There are two ways to resolve this:
- Disable SELinux (not recommended)
Configure SELinux to allow Nginx to access the home directory:
sudo dnf install policycoreutils-python-utils
sudo semanage fcontext -a -t httpd_sys_content_t "/home/www(/.*)?"
sudo restorecon -R /home/wwww
sudo setsebool -P httpd_enable_homedirs 1
sudo systemctl restart nginx
Refer: https://docs.rockylinux.org/guides/security/learning_selinux/