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 = drupal.example.com
  • IP Address = 192.168.1.11

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.

[root@drupal ~]# rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
[root@drupal ~]# rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm

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

[root@drupal ~]# yum install httpd php55w php55w-opcache php55w-mbstring php55w-gd php55w-xml php55w-pear php55w-fpm php55w-mysql

Start the Web Server Service

[root@drupal ~]# systemctl start httpd
[root@drupal ~]# systemctl enable httpd
ln -s '/usr/lib/systemd/system/httpd.service' '/etc/systemd/system/multi-user.target.wants/httpd.service'
[root@drupal ~]#

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

[root@drupal ~]# firewall-cmd --permanent --zone=public --add-service=http
success
[root@drupal ~]# firewall-cmd --permanent --zone=public --add-service=https
success
[root@drupal ~]# firewall-cmd --reload
success
[root@drupal ~]#

Step:2 Install Database Server ( MariaDB )

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

[root@drupal ~]# yum install mariadb-server mariadb

Start the Database service using below command

[root@drupal ~]# systemctl start mariadb
[root@drupal ~]# systemctl enable mariadb
ln -s '/usr/lib/systemd/system/mariadb.service' '/etc/systemd/system/multi-user.target.wants/mariadb.service'
[root@drupal ~]#

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

[root@drupal ~]# mysql_secure_installation

Create the database for drupal

[root@drupal ~]# 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 db_user@localhost IDENTIFIED BY 'Durpal@123#';
Query OK, 0 rows affected (0.01 sec)

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

MariaDB [(none)]> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> exit
Bye
[root@drupal ~]#

Restart the DB service

[root@drupal ~]# systemctl restart mariadb
[root@drupal ~]#

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.

[root@drupal ~]# yum install wget gzip
[root@drupal ~]# wget https://ftp.drupal.org/files/projects/drupal-8.0.2.tar.gz

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

Use the below command to untar the downloaded drupal file.

[root@drupal ~]# 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
[root@drupal ~]#
[root@drupal ~]# 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.

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

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).

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

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

[root@drupal ~]# chcon -R -t httpd_sys_content_rw_t /var/www/html/drupal/
[root@drupal ~]#

Step:5 Start the Drupal installation

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

Choose your preferred language.

Choose-language-drupal-installation

Click on “Save and Continue

Select the installation Profile.

Select-installation-profile-drupal

Verify Requirements for Drupal Installation :

Drupal-installation-requirements-review

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.

Installing-Drupal-progress

Specify the Site info :

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

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

configure-site-drupal-install

Save-and-continue-Drupal-installation

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

Drupal-installation-completed

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

404-Not-Found-error-drupal-install

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:

[root@drupal ~]# systemctl restart httpd

Add-content-drupal-sites

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

15 thoughts on “How to Install Drupal 8 On CentOS 7”

    • Hi Kyler ,

      Check the Internet connectivity and DNS server on your CentOS machine and also try to visit the site from the browser.

      I have tested from side it is working fine.

      Reply
  1. 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.

    Reply
  2. 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.
    Cheers.

    Reply
  3. 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).

    Reply
  4. 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 (‘https://www.cloudways.com/en/drupal-cloud-hosting.php’ ) where Debian is already installed. Do you think it is better to install the OS myself?

    Reply
  5. 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?

    Reply
  6. 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.

    Reply
  7. 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

    Reply
  8. Hi,

    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

    Reply

Leave a Comment