How to Install LEMP Stack (Nginx, MariaDB, PHP 8) and Drupal on CentOS Stream 10
Drupal is a powerful, open-source content management system (CMS) used to build and manage websites, blogs, and web applications. It is known for its flexibility, scalability, and security. Written in PHP, Drupal provides a wide range of modules and themes, allowing users to customize functionality and design. It is commonly used for enterprise-level websites, government portals, and community-driven platforms.
Update the System
Update the system packages,
dnf update -y
dnf upgrade -y
Install Nginx Web Server
Run the following command to install Nginx:
yum install nginx -y
Once the installation is complete, enable and start Nginx:
systemctl start nginx
systemctl enable nginx
systemctl status nginx
Allow HTTP and HTTPS traffic through the firewall:
firewall-cmd --permanent --zone=public --add-service=http
firewall-cmd --permanent --zone=public --add-service=https
firewall-cmd --reload
Change the ownership of the web directory to Nginx:
chown nginx:nginx /usr/share/nginx/html -R
Verify that Nginx is running by opening your server's IP address in a web browser:
http://IP_address
Install MariaDB Server
Install MariaDB with:
yum install mariadb-server mariadb -y
Enable and start MariaDB:
systemctl start mariadb
systemctl enable mariadb
systemctl status mariadb
Secure MariaDB:
mysql_secure_installation
Verify the installation:
mysql -e "SHOW DATABASES;" -p
Install PHP
Install PHP and necessary modules:
yum install php php-mysqlnd php-fpm php-opcache php-gd php-xml php-mbstring -y
Enable and start PHP-FPM:
systemctl start php-fpm
systemctl enable php-fpm
systemctl status php-fpm
Modify the PHP-FPM configuration to use the Nginx user:
vi /etc/php-fpm.d/www.conf
Change:
user = apache
group = apache
To:
user = nginx
group = nginx
Restart PHP-FPM:
systemctl reload php-fpm
Install Drupal
Install Wget and Developer Tools
yum groupinstall "Development tools"
yum install wget
Download and Extract Drupal
cd /var/www/html
wget https://ftp.drupal.org/files/projects/drupal-10.0.0.tar.gz
ls
tar xvzf drupal-10.0.0.tar.gz
rm -v drupal-10.0.0.tar.gz
mv drupal-10.0.0 drupal
Set Permissions
mkdir /var/www/html/drupal/sites/default/files
cp /var/www/html/drupal/sites/default/default.settings.php /var/www/html/drupal/sites/default/settings.php
chown -R nginx:nginx /var/www/html/drupal/
chmod -Rf 775 /var/www/html/drupal/sites/
chmod -Rf 777 /var/www/html/drupal/sites/files
chcon -R -t httpd_sys_content_rw_t /var/www/html/drupal/sites/
Configure Nginx for Drupal
Create PHP-FPM Configuration for Drupal
vi /etc/php-fpm.d/drupal.conf
Add:
[drupal]
user = nginx
group = nginx
listen.owner = nginx
listen.group = nginx
listen = /run/php-fpm/drupal.sock
pm = ondemand
pm.max_children = 50
pm.process_idle_timeout = 10s
pm.max_requests = 500
chdir = /
Create Nginx Virtual Host Configuration
vi /etc/nginx/conf.d/drupal.conf
Add:
server {
listen 80;
server_name yourdomain.com;
root /var/www/html/drupal;
location / {
try_files $uri /index.php?$query_string;
}
location ~ \.php$ {
fastcgi_split_path_info ^(.+?\.php)(|/.*)$;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_pass unix:/run/php-fpm/drupal.sock;
}
}
Restart services:
systemctl restart php-fpm
systemctl restart nginx
Configure SELinux and Firewall
semanage fcontext -a -t httpd_sys_rw_content_t "/var/www/html/drupal(/.*)?"
semanage fcontext -a -t httpd_sys_rw_content_t '/var/www/html/drupal/sites/default/settings.php'
semanage fcontext -a -t httpd_sys_rw_content_t '/var/www/html/drupal/sites/default/files'
restorecon -Rv /var/www/html/drupal
setsebool -P httpd_can_sendmail on
Enable firewall rules:
firewall-cmd --permanent --add-service=http
firewall-cmd --permanent --add-service=https
firewall-cmd --reload
Configure the Drupal Database
mysql -u root -p
CREATE DATABASE drupal;
CREATE USER 'drupaluser'@'localhost' IDENTIFIED BY 'yourpassword';
GRANT ALL PRIVILEGES ON drupal.* TO 'drupaluser'@'localhost';
FLUSH PRIVILEGES;
exit
Note: Replace yourpassword with actual strong password
Complete Drupal Installation
Open your browser and go to:
http://your-server-ip
Follow the installation wizard and enter the database details you configured.
Done!
You have successfully installed the LEMP stack and Drupal on CentOS Stream 10!
CrownCloud - Get a SSD powered KVM VPS at $4.5/month!
Use the code WELCOME
for 10% off!
1 GB RAM / 25 GB SSD / 1 CPU Core / 1 TB Bandwidth per month
Available Locations: LAX | MIA | ATL | FRA | AMS