How to Install Drupal 8 On CentOS 7

Drupal is an Open Source Content Management Software which allows us to build & create web sites without doing any coding. Drupal’s code is written in PHP and comes under GNU GPL (General Public License ).

In this article we will demonstrate how to install Drupal 8 on CentOS 7.  Hostname and IP of my machine on which i will install Drupal 8

  • Hostname =
  • IP Address =

Step:1 Install Apache Web Server (httpd) & PHP 5.5

Drupal 8 require at least PHP 5.5 or above, But php 5.5 is not available in the default yum repository so we will set the following repositories so that we can install php 5.5 using yum command.

[[email protected] ~]# rpm -Uvh
[[email protected] ~]# rpm -Uvh

Use below command to install web server ( httpd), PHP5.5 & other required php dependencies.

[[email protected] ~]# yum install httpd php55w php55w-opcache php55w-mbstring php55w-gd php55w-xml php55w-pear php55w-fpm php55w-mysql

Start the Web Server Service

[[email protected] ~]# systemctl start httpd
[[email protected] ~]# systemctl enable httpd
ln -s '/usr/lib/systemd/system/httpd.service' '/etc/systemd/system/'
[[email protected] ~]#

In case firewall is running on the Server then use below commands to open 80 & 443 port.

[[email protected] ~]# firewall-cmd --permanent --zone=public --add-service=http
[[email protected] ~]# firewall-cmd --permanent --zone=public --add-service=https
[[email protected] ~]# firewall-cmd --reload
[[email protected] ~]#

Step:2 Install Database Server ( MariaDB )

In CentOS 7 mariadb is default database server. Use below command to install mariadb .

[[email protected] ~]# yum install mariadb-server mariadb

Start the Database service using below command

[[email protected] ~]# systemctl start mariadb
[[email protected] ~]# systemctl enable mariadb
ln -s '/usr/lib/systemd/system/mariadb.service' '/etc/systemd/system/'
[[email protected] ~]#

Set the “root password”, “Remove anonymous users” and “disable remote root login” and other parameters using below “mysql_secure_installation” command.

[[email protected] ~]# mysql_secure_installation

Create the database for drupal

[[email protected] ~]# mysql -u root -p

MariaDB [(none)]> create database drupal_db;
Query OK, 1 row affected (0.00 sec)
MariaDB [(none)]>

Create a user for database (drupal_db) and grant all privileges to the user on the database ‘drupal_db

MariaDB [(none)]> CREATE USER [email protected] IDENTIFIED BY '[email protected]#';
Query OK, 0 rows affected (0.01 sec)

MariaDB [(none)]> GRANT ALL PRIVILEGES ON drupal_db.* TO [email protected];
Query OK, 0 rows affected (0.00 sec)

Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> exit
[[email protected] ~]#

Restart the DB service

[[email protected] ~]# systemctl restart mariadb
[[email protected] ~]#

Step:3 Download Drupal 8 using wget command.

Download the latest version of drupal from from their official site “Download Drupal

We can also use wget command to download drupal from the terminal. In case wget and gzip package is not installed then below command to install wget and gzip command.

[[email protected] ~]# yum install wget gzip
[[email protected] ~]# wget

Step:4 Untar the downloaded file and set the required permissions.

Use the below command to untar the downloaded drupal file.

[[email protected] ~]# ls -l drupal-8.0.2.tar.gz
-rw-r--r--. 1 root root 11720487 Jan 6 17:57 drupal-8.0.2.tar.gz
[[email protected] ~]#
[[email protected] ~]# tar -zxpvf drupal-8.0.2.tar.gz

Move the drupal folder to web server’s document root ( /var/www/html ) and set the permissions.

[[email protected] ~]# mv drupal-8.0.2 /var/www/html/drupal
[[email protected] ~]# chown -R apache:apache /var/www/html/drupal/
[[email protected] ~]#

Now create settings file (settings.php ), a default settings file (default.settings.php) is already placed in the folder (/var/www/html/drupal/sites/default).

[[email protected] ~]# cd /var/www/html/drupal/sites/default
[[email protected] default]# cp -p default.settings.php settings.php
[[email protected] default]#

Note : Set the Selinux rule on the folder “/var/www/html/drupal/” in case SElinux is enable on your Linux box.

[[email protected] ~]# chcon -R -t httpd_sys_content_rw_t /var/www/html/drupal/
[[email protected] ~]#

Step:5 Start the Drupal installation

Open the web browser and type “http://<server_ip_address_or_hostname>/drupal

Choose your preferred language.


Click on “Save and Continue

Select the installation Profile.


Verify Requirements for Drupal Installation :


click on “continue anyway

Database Configuration : Use drupal database, user name & its password that we created  in above steps.

Database configuration-drupal-installation

Click on ‘Save and Continue’ and then Installation will start as shown in below.


Specify the Site info :

Please change the below parameters as per your setup and in my case i am using below :

  • Site Name :
  • Site email address : [email protected]
  • User Name for Site Maintenance Account : linuxtechi
  • Password : XXXXX
  • Country : India
  • Default time zone : UTC



Click on ‘Save and Continue’ to finish the installation.


Now Add the content to your site, In my case when i click on add Content , i was getting an error “URL /drupal/node/add was not found on this server


To resolve this issue , i have changed the parameter ‘AllowOverride none’ to ‘AllowOverride all’ in the web server config file ‘/etc/httpd/conf/httpd.conf’ and restart the web server service:

[[email protected] ~]# systemctl restart httpd


Now the Drupal installation is Completed. Add content to your site have fun 🙂

15 Responses

  1. Kyler says:

    rpm -Uvh is giving me a 404 error and failing. Any ideas?

  2. viju says:

    Error here:
    chcon -R -t httpd_sys_content_rw_t /var/www/html/drupal/sites/
    should be:
    chcon -R -t httpd_sys_content_rw_t /var/www/html/drupal/
    otherwise the setuppage for drupal does not show up.

  3. Greg says:

    Thanks Pradeep
    Well done – works from first kick 🙂

  4. Simon Bishop says:

    Good and concise article. Good work Pradeep. However I cannot apply the same commands for my Ubuntu 16.04 server.
    After searching the net for some time i finally stumbled upon a good tutorial.
    Nevertheless, this article helped me install Drupal on my Centos server and for that I’m grateful.

  5. sog says:

    Great tutorial, saved me a lot of time – thanks a lot!

    BTW – AllowOverride All option should be changed in section of ‘/etc/httpd/conf/httpd.conf’ (if done elsewere it won’t work).

  6. Azaz says:

    Pradeep nice tutorial. After looking at all these codes, it feels like manually installing Drupal on linux distribution must be a pain. I haven’t done that in a long time because I have been using Cloudways platform (‘’ ) where Debian is already installed. Do you think it is better to install the OS myself?

  7. ISK1ON1 says:

    Hi – currently I use virtual hosts and basic html to display 3 different sites I host on centos 7 server delivered with apache. I was thinking about going to Drupal. is there any way to manage or add multiple, existing sites into drupal front manager?

  8. Rene says:

    Pradeep, thank you very much for this tut. Great work!

  9. Eric says:

    Great tutorial! Thank you very much – this would have taken hours to work out alone. Everything went perfect except for some selinux permissions issues. Viju left a comment showing the fix for that; I’m glad for that as well.

  10. Supriya Bhuyan says:

    Everything was going well while install druapal 8 on my server but at the end it states I need php 5.5.9 or higher.Please help as I am a learner.Thanks in advance

  11. Seema says:


    Thanks for great help, everything works well for me , but when I tried access my Ip address on browser , it says requested URL not found
    PLease help.

    Thanks in advance

  12. Ahmer Mansoor says:

    Good article. But I didn’t find any web server configurations for Drupal.

Leave a Reply

Your email address will not be published. Required fields are marked *

Pin It on Pinterest