How to install Drupal in CentOS

To install Drupal in CentOS

Drupal is an open source content Management System used for creating Websites without any PHP coding. It is programmed in PHP and provides GUI for the users to create websites. Installation of Drupal in CentOS is explained in this article.

To install Drupal

Utilize the following command to install PHP by establishing epel repository and webtatic repository.

[root@linuxhelp ~]# rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm 
Retrieving https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
warning: /var/tmp/rpm-tmp.Q0hUa7: Header V3 RSA/SHA256 Signature, key ID 352c64e5: NOKEY
Preparing...                          ################################# [100%]
Updating / installing...
   1:epel-release-7-8                 ################################# [100%]
[root@linuxhelp ~]# rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
Retrieving https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
warning: /var/tmp/rpm-tmp.whnHaR: Header V4 RSA/SHA1 Signature, key ID 62e74ca5: NOKEY
Preparing...                          ################################# [100%]
Updating / installing...
   1:webtatic-release-7-3             ################################# [100%]


Then install LAMP server with PHP by running the following command.

[root@linuxhelp ~]# yum install httpd php55w php55w-opcache php55w-mbstring php55w-gd php55w-xml php55w-pear php55w-fpm php55w-mysql mariadb mariadb-server -y 
Loaded plugins: fastestmirror, langpacks                                                                                                                                                        
Loading mirror speeds from cached hostfile
 * base: centosmirror.go4hosting.in
 * epel: mirror01.idc.hinet.net
 * extras: centosmirror.go4hosting.in
 * updates: centosmirror.go4hosting.in
 * webtatic: sp.repo.webtatic.com
Resolving Dependencies
-->  Running transaction check
--->  Package httpd.x86_64 0:2.4.6-40.el7.centos.4 will be installed
-->  Processing Dependency: httpd-tools = 2.4.6-40.el7.centos.4 for package: httpd-2.4.6-40.el7.centos.4.x86_64
-->  Processing Dependency: /etc/mime.types for package: httpd-2.4.6-40.el7.centos.4.x86_64
-->  Processing Dependency: libaprutil-1.so.0()(64bit) for package: httpd-2.4.6-40.el7.centos.4.x86_64
-->  Processing Dependency: libapr-1.so.0()(64bit) for package: httpd-2.4.6-40.el7.centos.4.x86_64
--->  Package mariadb.x86_64 1:5.5.50-1.el7_2 will be installed
.
.
.
Updated:
  dracut.x86_64 0:033-360.el7_2.1                                                      initscripts.x86_64 0:9.49.30-1.el7_2.3                                                     

Dependency Updated:
  dracut-config-rescue.x86_64 0:033-360.el7_2.1    dracut-network.x86_64 0:033-360.el7_2.1    kmod.x86_64 0:20-8.el7_2                 libgudev1.x86_64 0:219-19.el7_2.13        
  mariadb-libs.x86_64 1:5.5.50-1.el7_2             systemd.x86_64 0:219-19.el7_2.13           systemd-libs.x86_64 0:219-19.el7_2.13    systemd-python.x86_64 0:219-19.el7_2.13   
  systemd-sysv.x86_64 0:219-19.el7_2.13           

Complete!


Start and enable the services for Apache and MariaDB by using the following command.

[root@linuxhelp ~]# systemctl start httpd
[root@linuxhelp ~]# systemctl enable httpd 


Created a symlink from /etc/systemd/system/multi-user.target.wants/httpd.service to /usr/lib/systemd/system/httpd.service.

[root@linuxhelp ~]# systemctl start mariadb
[root@linuxhelp ~]# systemctl enable mariadb 


Created symlink from /etc/systemd/system/multi-user.target.wants/mariadb.service to /usr/lib/systemd/system/mariadb.service.
Then Set root password for Mariadb database

[root@linuxhelp ~]# mysql_secure_installation  
/usr/bin/mysql_secure_installation: line 379: find_mysql_client: command not found

NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!

In order to log into MariaDB to secure it, we' ll need the current
password for the root user.  If you' ve just installed MariaDB, and
you haven' t set the root password yet, the password will be blank,
so you should just press enter here.

Enter current password for root (enter for none): 
OK, successfully used password, moving on...

.
.
.

By default, MariaDB comes with a database named ' test'  that anyone can
access.  This is also intended only for testing, and should be removed
before moving into a production environment.

Remove test database and access to it? [Y/n] y
 - Dropping test database...
 ... Success!
 - Removing privileges on test database...
 ... Success!

Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.

Reload privilege tables now? [Y/n] y
 ... Success!

Cleaning up...

All done!  If you' ve completed all of the above steps, your MariaDB
installation should now be secure.

Thanks for using MariaDB!


Create Database and Database user for Drupal inside the Mariadb database.

[root@linuxhelp ~]# mysql -u root -p 
Enter password: 
Welcome to the MariaDB monitor.  Commands end with   or g.
Your MariaDB connection id is 10
Server version: 5.5.50-MariaDB MariaDB Server

Copyright (c) 2000, 2016, Oracle, MariaDB Corporation Ab and others.

Type ' help '  or ' h'  for help. Type ' c'  to clear the current input statement.

MariaDB [(none)]>  create database drupaldb 
Query OK, 1 row affected (0.03 sec)

MariaDB [(none)]>  CREATE USER drupaluser@localhost IDENTIFIED BY ' 123'  
Query OK, 0 rows affected (0.62 sec)

MariaDB [(none)]>  GRANT ALL PRIVILEGES ON drupaldb.* TO drupaluser@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


Move to the document root and download the Drupal package by executing the following command.

[root@linuxhelp ~]# cd /var/www/html/
[root@linuxhelp html]# wget https://ftp.drupal.org/files/projects/drupal-8.0.2.tar.gz 
--2016-10-08 09:56:48--  https://ftp.drupal.org/files/projects/drupal-8.0.2.tar.gz
Resolving ftp.drupal.org (ftp.drupal.org)... 151.101.8.68
Connecting to ftp.drupal.org (ftp.drupal.org)|151.101.8.68|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 11720487 (11M) [application/octet-stream]
Saving to: ‘ drupal-8.0.2.tar.gz’ 

100%[=========================================================================================================================================> ] 11,720,487   423KB/s   in 26s    

2016-10-08 09:57:14 (445 KB/s) - ‘ drupal-8.0.2.tar.gz’  saved [11720487/11720487]


Now its time to extract the downloaded zip package.

[root@linuxhelp html]# tar -xzvf drupal-8.0.2.tar.gz  
drupal-8.0.2/
drupal-8.0.2/robots.txt
drupal-8.0.2/example.gitignore
drupal-8.0.2/.eslintignore
drupal-8.0.2/update.php
drupal-8.0.2/themes/
drupal-8.0.2/themes/README.txt
drupal-8.0.2/.htaccess
.
.
.
drupal-8.0.2/autoload.php
drupal-8.0.2/.editorconfig
drupal-8.0.2/.gitattributes
drupal-8.0.2/.csslintrc
drupal-8.0.2/index.php
drupal-8.0.2/.eslintrc
drupal-8.0.2/composer.json
drupal-8.0.2/web.config
drupal-8.0.2/LICENSE.txt
drupal-8.0.2/profiles/
drupal-8.0.2/profiles/README.txt


After extracting, rename the directory

[root@linuxhelp html]# ls 
drupal-8.0.2  drupal-8.0.2.tar.gz
[root@linuxhelp html]# mv drupal-8.0.2 drupal 


Change the group and user ownership for Drupal directory to Apahce and change the file permissions along with its selinux context.

[root@linuxhelp html]# chown -R apache:apache /var/www/html/drupal
[root@linuxhelp html]# chmod -R 775 /var/www/html/drupal
[root@linuxhelp html]# chcon -Rt httpd_sys_content_rw_t /var/www/html/drupal 


Move the below mentioned directory and rename the file as shown below.

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


Trigger the browser and point to http://< IP_address> /drupal


Choose the language and click Save and continue.

Then choose the type of installation profile.


Enter the required fields to configure database.


Then fill the following details for Site Configuration.

Tag : Drupal
FAQ
Q
What is the Drupal Association?
A
The Drupal Association is the non-profit organization dedicated to helping Drupal flourish. It helps the Drupal community with funding, infrastructure, events, promotion, and distribution.
Q
Purpose of uisng the Drupal ?
A
Drupal is an open source content Management System used for creating Websites without any PHP coding. It is programmed in PHP and provides GUI for the users to create websites.
Q
Can I migrate a WordPress site to Drupal?
A
Yes. There are modules like WordPress Migrate to help you.
Q
Where can I find the Drupal community near me?
A
Drupal is global. Check out our multinational list of communities and our list of regional groups and meetups.
Q
Can I migrate a WordPress site to Drupal?
A
Yes. There are modules like WordPress Migrate to help you.