Learn how to – Install and Configure Drupal 8 on CentOS 8 / RHEL 8.
In this blog post, we’ll discuss how to install Drupal 8 on CentOS 8 / RHEL 8 Linux distribution. Drupal is a free and open-source content management platform created to facilitate creation of websites, online content and user engagement communities. Drupal is written in PHP and it uses a database backend to store its data – MySQL, MariaDB, SQLite, PostgreSQL e.t.c.
Update for Drupal 9: Install Drupal 9 CMS on CentOS 8
Features of Drupal can be extended or customized with thousands of addons available. You can choose a web server of your choice for hosting Drupal on CentOS 8 – This can be Nginx, Apache, Lighttpd or Windows IIS server.
Having covered the basics of Drupal and its software requirements, let’s move to the actual installation of Drupal on CentOS 8. You’re expected to have a running CentOS 8 server – can be in the Cloud, your DC or any other hosting platform powered by CentOS 8 Linux.
Let’s get started and install Drupal on CentOS 8 / RHEL 8 Linux.
Step 1 – Update CentOS / RHEL 8 Machine
Update your system packages index and installed packages.
sudo dnf -y update
Since you may get Kernel updates, consider rebooting your system.
sudo reboot
Step 2 – Install Database server
Choose a database server you want to use, this can be MySQL, MariaDB or PostgreSQL. One of the guides below should work for you.
My installation will use MariaDB as database server for Drupal. After database installation, create database and user for Drupal on CentOS 8 Linux.
$ mysql -u root -p
CREATE DATABASE drupal CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;
CREATE USER drupal@localhost IDENTIFIED BY "StrongDrupalP@5s";
GRANT ALL PRIVILEGES ON drupal.* TO drupal@localhost IDENTIFIED BY "StrongDrupalP@5s";
FLUSH PRIVILEGES;
QUIT
The drupal database user should be able to access the drupal database created.
$ mysql -u drupal -p
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or g.
Your MariaDB connection id is 19
Server version: 10.3.11-MariaDB MariaDB Server
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or 'h' for help. Type 'c' to clear the current input statement.
MariaDB [(none)]> SHOW DATABASES;
+--------------------+
| Database |
+--------------------+
| drupal |
| information_schema |
+--------------------+
2 rows in set (0.000 sec)
MariaDB [(none)]> QUIT
Bye
Step 3: Install PHP and required extensions
Install PHP which is required by Drupal on CentOS 8. This can be achieved by running the commands below in your terminal.
sudo dnf install -y @php
sudo dnf install -y php php-{cli,mysqlnd,json,opcache,xml,mbstring,gd,curl}
Version installed can be checked with php command.
$ php -v
PHP 7.2.11 (cli) (built: Oct 9 2018 15:09:36) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
with Zend OPcache v7.2.11, Copyright (c) 1999-2018, by Zend Technologies
Start and enable php-fpm service.
sudo systemctl enable --now php-fpm
Service should show running on systemctl status command.
$ systemctl status php-fpm
● php-fpm.service - The PHP FastCGI Process Manager
Loaded: loaded (/usr/lib/systemd/system/php-fpm.service; enabled; vendor preset: disabled)
Active: active (running) since Wed 2019-10-09 22:02:47 EAT; 5s ago
Main PID: 9716 (php-fpm)
Status: "Ready to handle connections"
Tasks: 6 (limit: 11512)
Memory: 22.5M
CGroup: /system.slice/php-fpm.service
├─9716 php-fpm: master process (/etc/php-fpm.conf)
├─9717 php-fpm: pool www
├─9718 php-fpm: pool www
├─9719 php-fpm: pool www
├─9720 php-fpm: pool www
└─9721 php-fpm: pool www
Oct 09 22:02:47 centos8.novalocal systemd[1]: Starting The PHP FastCGI Process Manager...
Oct 09 22:02:47 centos8.novalocal systemd[1]: Started The PHP FastCGI Process Manager.
Step 4: Install Web Server
In this guide, we’ll go with Apache as Web server for Drupal on CentOS 8. We have a detailed guide on installing Apache on CentOS 8. Just run the following commands to get Apache httpd server on CentOS 8.
sudo dnf -y install @httpd
Start and enable httpd service.
sudo systemctl enable --now httpd
Allow http and https protocols in the firewall.
sudo firewall-cmd --add-service={http,https} --permanent
sudo firewall-cmd --reload
Step 5: Install Drupal 8 on CentOS 8 / RHEL 8
Download the latest release of Drupal from the Drupal releases page.
sudo dnf -y install wget
DRUPAL_VERSION="8.9.19"
wget https://ftp.drupal.org/files/projects/drupal-${DRUPAL_VERSION}.tar.gz
Extract downloaded archive file.
tar xvf drupal-${DRUPAL_VERSION}.tar.gz
Move folder created from extraction to /var/www/html directory.
sudo mv drupal-${DRUPAL_VERSION} /var/www/html/drupal
Create additional directories and files required by Drupal installer.
sudo mkdir /var/www/html/drupal/sites/default/files
sudo cp /var/www/html/drupal/sites/default/default.settings.php /var/www/html/drupal/sites/default/settings.php
Set directory permissions and SELinux labels.
sudo semanage fcontext -a -t httpd_sys_rw_content_t "/var/www/html/drupal(/.*)?"
sudo semanage fcontext -a -t httpd_sys_rw_content_t '/var/www/html/drupal/sites/default/settings.php'
sudo semanage fcontext -a -t httpd_sys_rw_content_t '/var/www/html/drupal/sites/default/files'
sudo restorecon -Rv /var/www/html/drupal
sudo restorecon -v /var/www/html/drupal/sites/default/settings.php
sudo restorecon -Rv /var/www/html/drupal/sites/default/files
sudo chown -R apache:apache /var/www/html/drupal
Create Apache Configuration file for Drupal on CentOS 8.
sudo vi /etc/httpd/conf.d/drupal.conf
A basic configuration looks similar to below.
<VirtualHost *:80>
ServerAdmin webmaster@example.com
ServerName example.com
DocumentRoot /var/www/html/drupal
<Directory /var/www/html/drupal/>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
ErrorLog /var/log/httpd/drupal_error.log
CustomLog /var/log/httpd/drupal_access.log combined
</VirtualHost>
Where:
- example.com is your site domain
- /var/www/html/drupal is the location of Drupal files
- /var/log/apache2/ is the location of Apache log files
For https access, check Drupal SSL Configuration guide.
Restart httpd service after making the change.
sudo systemctl restart httpd
If restart succeeded, you should see a success message in status check.
$ systemctl status httpd
● httpd.service - The Apache HTTP Server
Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled; vendor preset: disabled)
Drop-In: /usr/lib/systemd/system/httpd.service.d
└─php-fpm.conf
Active: active (running) since Wed 2019-10-09 22:17:06 EAT; 5s ago
Docs: man:httpd.service(8)
Main PID: 9951 (httpd)
Status: "Started, listening on: port 443, port 80"
Tasks: 213 (limit: 11512)
Memory: 25.1M
CGroup: /system.slice/httpd.service
├─9951 /usr/sbin/httpd -DFOREGROUND
├─9953 /usr/sbin/httpd -DFOREGROUND
├─9954 /usr/sbin/httpd -DFOREGROUND
├─9955 /usr/sbin/httpd -DFOREGROUND
└─9956 /usr/sbin/httpd -DFOREGROUND
Oct 09 22:17:06 centos8.novalocal systemd[1]: Starting The Apache HTTP Server...
Oct 09 22:17:06 centos8.novalocal httpd[9951]: Server configured, listening on: port 443, port 80
Oct 09 22:17:06 centos8.novalocal systemd[1]: Started The Apache HTTP Server.
Step 6: Complete Drupal Installation on CentOS 8 / RHEL 8
Open your browser and type the configured URL “http://example.com”, this is should be a record resolvable from DNS or in your /etc/hosts file.
Select your installation language and click “continue“.
On the next page, choose the installation profile.
Provide database connection details. For remote database server, provide address under “ADVANCED OPTIONS”.
Installation should start.
Provide website domain, admin user,email and password.
This marks the end of the installation of Drupal 8 on CentOS 8 / RHEL 8 Linux. A success message is shown in the next page.
Conclusion
You have successfully installed and configured Drupal on CentOS 8. Congratulations!!. The next place to visit is Drupal Documentation page.
Related guides:
- Install Drupal on Debian 10 (Buster) Linux
- Install and Configure Ghost CMS on CentOS 8 / RHEL 8
- How To Install Ghost CMS on Ubuntu
- How To Install and Use Hugo On Ubuntu / Debian
Leave a Reply
You must be logged in to post a comment.