Drupal is a free and open source content management system. Drupal aka Drupal core can server as a website, a single or multi-user blog, or even can be used as a forum. Drupal offer a sophisticated API for developers but its basic website installation & administration requires no programming knowledge.

Drupal can run on any operating system that supports a web server with PHP & a database. So Drupal can be installed on Windows machine, Linux or Mac OS. Drupal provides a number of featured like user account registration and maintenance, menu management, RSS feeds, taxonomy, page layout customization etc.

In this tutorial, we will learn to install Drupal 8.4.0 on Linux machines. So let's start with pre-requisites..

(Recommended Read: WordPress Installation on CentOS/RHEL)

(Also Read: Create your website with Joomla)

Pre-requisites

-> Drupal requires LAMP installed on systems, so we should have one ready. We have already covered LAMP installation on CentOS/RHEL & Ubuntu, so refer to these articles to install LAMP server (Install PHP from the below mentioned tutorial).

-> PHP 7 is required. If you are using older version of PHP i.e. 5XXX, than you need to install/upgrade the PHP to php 7. Install the php 7, run the following command to install php 7 onto your system,

$ sudo yum install -y http://dl.iuscommunity.org/pub/ius/stable/CentOS/7/x86_64/ius-release-1.0-14.ius.centos7.noarch.rpm

$ sudo yum -y install php70u php70u-pdo php70u-mysqlnd php70u-opcache php70u-xml php70u-mcrypt php70u-gd php70u-devel php70u-intl php70u-mbstring php70u-bcmath php70u-json php70u-iconv

Also go through the detailed tutorial to upgrade the php on your machine.

Installation

Once we have our LAMP server ready, we can start he installation of Drupal. We will first grab latest version of Drupal, which at the time of writing this article is 8.4.0. Use the following command to download the tar package,

$ wget https://ftp.drupal.org/files/projects/drupal-8.4.0.tar.gz

Now extract the package,

$ tar -xvf drupal-8.4.0.tar.gz

& copy all its content to 'var/www/html/',

$ cd drupal-8.4.0

$ mv * /var/www/html

Configuring MySql

Next we will create a database for Drupal to use, to store the data on. Login to MySql & create the database,

$ mysql -u root -p -e "CREATE DATABASE drupaldb CHARACTER SET utf8 COLLATE utf8_general_ci"

Next create a user for accessing 'drupaldb';

$ mysql -u root -p

mysql> create user drupaluser@localhost identified by 'drupalpasswd';

Now grant privileges to the user,

mysql> GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER, CREATE TEMPORARY TABLES ON drupaldb.* TO 'drupaluser'@'localhost' IDENTIFIED BY 'drupalpasswd';

Now, implement the changes made to db with following command;

mysql> flush privileges;

than exit the database,

mysql> exit

We now have our DB & DB user ready. Same process is to be done, if using MariaDB instead of MySql server.

Configuring Apache

Now we will make some changes to apache server. We will enable rewrite functionality for the web server as this will allow Drupal to modify URLs to human friendly strings. Enable mod_rewrite in CentOS machines by adding following line to httpd.conf,

$ vim /etc/httpd/conf/httpd.conf

LoadModule rewrite_module modules/mod_rewrite.so

For Ubuntu machines, open terminal & run the following command to enable mod_rewrite,

$ sudo a2enmod rewrite

Next we will allow the use of .htaccess file for Drupal installation. Open the file where you have mentioned the virtual host entries, it can be one of the following files,

/etc/httpd/conf/httpd.conf (for Centos)

/etc/apache2/apache2.conf (for Ubuntu)

or it can be custom host config file like

/etc/apche2/sites-available/website.conf

or /etc/apache2/sites-enabled/000-default.conf

Make the following entry to the file you are using to define virtual hosts,

For Apache 2.2

<VirtualHost *:80>

ServerName drupal-test.com

ServerAdmin admi@drupal-test.com

DocumentRoot /var/www/html

<Directory /var/www/html>

Options FollowSymlinks

AllowOverride All

</Directory>

</VirtualHost>

For Apache 2.4

<VirtualHost *:80>

ServerName drupal-test.com

ServerAdmin admi@drupal-test.com

DocumentRoot /var/www/html

<Directory /var/www/html>

Options FollowSymlinks

AllowOverride All

Require all granted

</Directory>

</VirtualHost>

Now save the file & exit. Next restart the service to implement the changes.

$ service apache2 restart (For Ubuntu)

$ service httpd restart (For CentOS)

Installing Drupal

We will start the Drupal installation, but first copy the default settings file and rename the duplicate. Do not rename the default file as we require both files for the Drupal installation.

$ cd /var/www/html/sites/default

$ cp default.settings.php settings.php

$ cp default.services.yml services.yml

Now modiy the permissions of the file, so that it has writer permssions,

$ chmod 666 settings.php services.yml

We also need to create a folder named ‘files’ in the same directoru i.e. /var/www/html/sites/default/

$ mkdir files

Now, open the web-browser & enter the following URL to start the Drupal installation,

http://drupal-test.com

Setup will start as soon as the page is loaded, follow the on screen steps to install Drupal. On the first screen, we need to select the language & continue,

install drupal

On the next screen, select the profile. We are using the default profile i.e. standard,

install drupal

On this screen, setup will review the requirements & will provide the errors or warnings that are needed to resolved to proceed with the setup,

install drupal

Resolve any error & click continue to move further. On the next screen, we need to enter the database details,

install drupal

Upon pressing ‘Save and continue’, installation will now start,

install drupal

After the installation has been completed, we will be directed to configuration screen. Make the configurations as needed & proceed further,

install drupal

Congratulations, we have now configured our website with Drupal.

install drupal

This was our tutorial on how to install Drupal to create your own website/blog. Please do mention your queries or suggestions using the comment box below.

If you think we have helped you or just want to support us, please consider these :-

Connect to us: Facebook | Twitter | Google Plus

Donate us some of you hard earned money: [paypal-donation]

Linux TechLab is thankful for your continued support.