How to Install Drupal 8 On CentOS 7

Channel: Linux
Abstract: [[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.

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.

[[email protected] ~]# rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
[[email protected] ~]# 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.

[[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/multi-user.target.wants/httpd.service'
[[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
success
[[email protected] ~]# firewall-cmd --permanent --zone=public --add-service=https
success
[[email protected] ~]# firewall-cmd --reload
success
[[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/multi-user.target.wants/mariadb.service'
[[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)

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

MariaDB [(none)]> exit
Bye
[[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 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.

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

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 : drupal.example.com
  • 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 ?

Ref From: linuxtechi

Related articles