How to Install Drupal 8 on CentOS 7

We’ll show you, How to Install Drupal 8 on CentOS 7. Drupal is a free and open-source content management system that allows users to easily create online content and user communities. It is written in PHP and distributes under the GNU General Public License. Drupal is one of the most popular content management systems available today and it powers some of the largest and busiest sites in the world, such as The White House, Yale, Stanford,  Weather.com and many other. In this article, we will cover all steps of installing Drupal 8 on a CentOS 7 VPS. The installation is pretty simple and straightforward and if you closely follow the steps below, you will have a working Drupal installation in less than 10 minutes.

Drupal has several requirements that have to be installed on your server, to be able to run a Drupal website.
– Apache 2.x (Recommended)
– PHP 5.5.9 or higher (5.5 recommended)
– MySQL 5.5.3 or MariaDB 5.5.20 with PHP Data Objects (PDO)

1. Install LAMP stack

Make sure to install a LAMP stack if you don’t have one already installed.

2. Login via SSH

First of all, login to your CentOS 7 VPS via SSH as user root

ssh root@IP_Address

3. Update installed packages

and make sure that all installed packages are up to date

yum -y update

4. Create new MySQL database

Drupal requires an empty MySQL database. You can create a MySQL database and user for the Drupal installation as described above:

# mysql -u root -p

mysql> CREATE DATABASE drupal;
mysql> GRANT ALL PRIVILEGES on drupal.* to 'drupaluser'@'localhost' identified by 'PASSWORD';
mysql> FLUSH PRIVILEGES;
mysql> exit

Don’t forget to replace ‘PASSWORD’ with an actual, strong password.

If you have a control panel installed on your server, you can create a database through the control panel.

5. Download Drupal 8

Download the latest stable Drupal release to your server. At the moment of writing this article, it is version 8.7.2

wget https://ftp.drupal.org/files/projects/drupal-8.2.7.zip

Once it is downloaded, unpack the zip archive to the document root directory on your server.

unzip drupal-8.2.7.zip -d /var/www/html && mv /var/www/html/drupal-8.2.7 /var/www/html/drupal

6. Configure Drupal 8

Create a settings file for Drupal from the default.settings.php file.

cp /var/www/html/drupal/sites/default/default.settings.php /var/www/html/drupal/sites/default/settings.php

7. Configure Apache web server

Set the Apache user to be owner of the Drupal files and directories

chown -R apache:apache /var/www/html/drupal

Create a new Apache virtual host, so you can access your Drupal website with your domain name. Create ‘/etc/httpd/conf.d/vhosts.conf’ file with the following content:

IncludeOptional vhosts.d/*.conf

Create a ‘vhosts.d/’ directory

mkdir /etc/httpd/vhosts.d/

and create the virtual host with the following content:

vim /etc/httpd/vhosts.d/domain.com.conf

<VirtualHost YOUR_SERVER_IP:80>
ServerAdmin [email protected]
DocumentRoot "/var/www/html/drupal/"
ServerName domain.com
ServerAlias www.domain.com
ErrorLog "/var/log/httpd/domain.com-error_log"
CustomLog "/var/log/httpd/domain.com-access_log" combined

<Directory "/var/www/html/drupal/">
DirectoryIndex index.html index.php
Options FollowSymLinks
AllowOverride All
Require all granted
</Directory>
</VirtualHost>

8. Restart Apache web server

Save the file and restart the web server for the changes to take effect.

systemctl restart httpd

9. Finalize the installation via web browser

The installation from the command line is complete. Now, open your favorite web browser and navigate it to http://domain.com to complete the Drupal installation.


Of course, you don’t have to Install Drupal 8 on CentOS 7, if you use one of our Linux Cloud VPS hosting services, in which case you can simply ask our expert Linux admins to install Drupal for you.They are available 24×7 and will take care of your request immediately.

PS. If you liked this post, on how to Install Drupal 8 on CentOS 7, please share it with your friends on the social networks using the buttons on the left or simply leave a reply below. Thanks.

Leave a Comment