Drupal is a open source content management system based on PHP and distributed under the GNU General Public License. Drupal is a scalable and open platform for web content management, it's community provides more than 31,000 modules to extend the core functions and Drupal is used by at least 2.1% of all website on the internet. At the end of 2015, the Drupal project has released the new major version Drupal 8 that I will cover in this tutorial.

In this tutorial, I will show you how to install Drupal 8 on Ubuntu 15.10 with Apache as web server, MySQL as database backend and how to secure the website with SSL.

Prerequisites

Ubuntu 15.10 - 64bit.

Root privileges.

Step 1 - Install Apache and PHP

I will install apache and PHP (and some PHP modules that are required by Drupal) with apt, the Ubuntu package installer. Then we will enable the apache modules mod_rewrite and mod_ssl.

Now enable the Apache SSL and rewrite modules with the 'a2enmod' command. Restart apache to apply configuration changes:

a2enmod rewrite sslsystemctl restart apache2

Check that the modules are loaded with the command:

apache2ctl -M | egrep 'ssl|rewrite'

The output shall show the following lines:

#Enabled rewrite_module (shared) ssl_module (shared

So mod-rewrite and mod-ssl are loaded.

Now I will check that Apache and PHP are working well. Create a new file in the "/var/www/html/" directory. The file contains the phpinfo() command:

cd /var/www/htmlecho "<?php phpinfo(); ?>" > info.php

visit the server IP: 192.168.1.100/info.php

The result should be similar to this screenshot.

Delete the info.php file:

rm -f /var/www/html/info.php

As a publicly accessible info.php file is a security risk.

Step 2 - Install and Configure the MySQL Database

In this step, we will install MySQL 5.6 and create a new database for Drupal. We will create a database with the name 'drupaldb', a new user 'drupaluser' with the password '[email protected]', and grant the user access to the database.

Install MySQL with command below:

apt-get install mysql-server mysql-client -y

The installation process will prompt for the MySQL password, choose a secure password.

Now log into the MySQL database with the user "root" and the password that you have chosen above, then create the database and user for drupal.

Step 3 - Install and Configure SSL

We will use SSL to enable secure access to Drupal. Create a new directory for ssl in the apache configuration directory, then create an SSL certificate with the OpenSSL command and change the permission of the certificate file.

Then create a new directory 'files' and change the permission of all files and folders in 'sites/default' directory:

mkdir files/chmod a+w *

Go to the '/var/www/' directory and change the owner of the drupal directory to the user and group 'www-data':

cd /var/www/chown -R www-data:www-data drupal/

The shell part of the Drupal installation is finished, visit the drupal domain of your website "www.mydrupal.co" and you will be switch to https connection automatically.

Choose your language, I will use 'English' here.

Select 'Standard' installation profile.

When your server is ready for Drupal (as our server is when you used the installation steps above) then you will be passed to the 'Verify requirements' section and continue with the database configuration. Fill in the database details of the MySQL database that we created earlier:

Click on "Save and continue" and wait until the installation process finished.

ow Configure the site, admin account, email, site name etc.

Drupal is installed and configured.

Conclusion

Drupal is a content management system based on PHP, it is used by at least 2.1% of all websites on the internet. Until now, Drupal has released version 8 and provides many add-on modules that make Drupal is really useful. We can install Drupal on any server that supports MySQL or MariaDB as database, a web server like Apache or Nginx and the PHP programming language. Drupal is easy to install and configure.

About Muhammad Arul

Muhammad Arul is a freelance system administrator and technical writer. He is working with Linux Environments for more than 5 years, an Open Source enthusiast and highly motivated on Linux installation and troubleshooting. Mostly working with RedHat/CentOS Linux and Ubuntu/Debian, Nginx and Apache web server, Proxmox, Zimbra Administration, and Website Optimization. Currently learning about OpenStack and Container Technology.

Suggested articles

22 Comment(s)

Comments

Thank you so much for this howto, I followed all the steps until I got to the step 4, where it asks to create the vim drupal.conf, I did the copy step but right on the bottom it says "Replace the domain name www.mydrupal.co with the domain name of your Drupal website", my machine is just going to be a local server using localhost or 127.0.1.1, I changed www.mydrupal.co with localhost but when I go to the web browser and type localhost/drupal8 it says "Not Found The requested URL /drupal8 was not found on this server" I have already downloaded likde it says in step 5 and I finished the steps there.

I am experiencing problems with getting Drupal 8 installed and configured. Initially I downloaded LAMP on a new Ubuntu 15.10 install that only had 'gparted' and 'xrdp' installed. I followed instruction to install Drupal on an Ubuntu 14.04 Server that installed Drupal 7.32 but doing a 'wget' of Drupal 8.0.1 prior to Christmas and had no success and ran out of time.

I believe I cleaned up the LAMP items and then reinstalled using these instruction. I am also using my private IP 192.168.0.159 and a hostname without a domain for configuring the Apache Virtualhost (Step 4). In Step 5 "Install and Configure Drupal 8" ('drush' downloaded 8.0.2), it complained about the HTTPS. But was able to perform the configure part using HTTP. The last screen shot comes up. But I am unable to do anything beyond this and it continues to complain about HTTPS.

The only noticeable error was in Step 1 with the "apache2ctl -M | egrep 'ssl|rewite'" which also complained about the hostname and that it would use the loopback IP 127.0.0.1. I looked through the lengthy "<?php phpinfo();" output and saw nothing obvious. The Apache Environment had HTTP.HOST set to 192.168.0.195.

I had an issue in the first step at line apache2ctl -M | egrep 'ssl|rewrite'.

Error message: AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1. Set the 'ServerName' directive globally to suppress this message

The Ubuntu 15.10 version is fresh (18th February 2016) and it is a desktop 64 bit instance.

Fixing this problem is, however, quite easy. Apache wants you to define a ServerName. So let’s add it by first opening terminal and editing the httpd.conf file: sudo nano /etc/apache2/apache2.conf Go to the very bottom of that file and add this line: ServerName localhost

After following this tutorial I got stuck at opening Drupal in the browser. Like others here, I'm running this on a local server and am unable to navigate to the Drupal installation in the browser. I've tried replacing "www.mydrupal.co" in the config file with various things such as the server's IP, localhost... nothing works.

Replace www.mydrupal.co with an arbitrary domain name (or keep as www.mydrupal.co) and then edit the hosts file on the client machine that you will be accessing Drupal from with an entry which redirects the arbitrary domain name to the server IP (I think localhost could even work), on my LAN this entry got it to work from my Mac laptop:

I can access the home page (http://mydrupal.co), but when I clicked any further links (e.g. http://mydrupal.co/admin/structure),

it shows error:

"Not Found

The requested URL /admin/structure was not found on this server."

This happened because an apache not found the .htaccess file in the /var/www/drupal directory. The mv command doesn't copy the hidden files (i.e. .htaccess file). You should copy .htaccess file before deleting the drupal-8.0.x directory.

Thank you for this tutorial. I followed the steps and successfully installed www.mysite1.com. But when I am trying to setup www.mysite2.com then mysite1 has stopped working and getting configuration from mysite2. Any idea why it is happening that site1 is getting configuration from site 2. Or is there something else I need to take care of for installation more than 1 sites in a single server?

This tutorial needs some revising. Drupal 8 is alive, active and being updated. Sadly, the documentation is still lagging behind. Ubuntu is on version 16.04.1 LTS and the standard in php now is version 7 (not 5).

Agreed, updates would be awesome. I can't get past the apache2 configuration. I have a TLD pointed at a box on my home network we'll call 'box.mydomain.com' I have done everything one would expect to pull the initial drupal configuration up in a web browser, but it continues to want to open the /var/www/html structure rather than the /var/www/drupal like it should. Here's my /etc/apache2/sites-available/drupal.conf:

Ideally I'd like to point drupal.mydomain.com to this machine so that box.mydomain.com could continue using the /var/www/html directory. Perhaps my understanding of virtual hosts is fundamentally flawed? Maybe someone could explain this conf file a little better to me? TIA

After hours of messing with the self signed certificate (which I had no problem generating as per instruction), I used "Let's Encrypt" and certbot instead. You can spend hours messing around trying to get Chrome or Firefox to not give you the "Not Secure" error in the browser -or- this solution will just take care of it. I hope this saves someone else literally hours of research and head to desk time.