How to Install Drupal 8 with Apache, MySQL and SSL on Ubuntu 15.10

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.


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

Update the Ubuntu repository and install Apache:

sudo su
apt-get update
apt-get install apache2 -y

Then install PHP 5  and the PHP modules with the command below:

apt-get install -y php5 libapache2-mod-php5 php5-mysqlnd php5-curl php5-gd php5-intl php-pear php5-imagick php5-imap php5-mcrypt php5-memcache php5-ming php5-ps php5-pspell php5-recode php5-snmp php5-sqlite php5-tidy php5-xmlrpc php5-xsl php5-apcu

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

a2enmod rewrite ssl
systemctl restart apache2

Check that the modules are loaded with the command:

apache2ctl -M | egrep 'ssl|rewrite'

The output shall show the following lines:

 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/html
echo "<?php phpinfo(); ?>" > info.php

visit the server IP:

phpinfo result.

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 'drupaluser@', 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.

Enter the MySQL 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.

You can use commands below:

mysql -u root -p

create database drupaldb;
create user drupaluser@localhost identified by 'drupaluser@';
grant all privileges on drupaldb.* to drupaluser@localhost identified by 'drupaluser@';
flush privileges;

Create a MySQL database for Drupal.

The Database configuration is finished.

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.

Go to the apache directory, create a ssl directory and enter it:

cd /etc/apache2/
mkdir ssl
cd ssl/

Generate a self-signed SSL certificate:

sudo openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /etc/apache2/ssl/drupalssl.key -out /etc/apache2/ssl/drupalssl.crt

Change the permission of the certificate file:

chmod 600 *

The new SSL certificate file is created.

Step 4 - Configure the Apache Virtualhost

In this step, we will create a directory for Drupal inside the /var/www directory and add a new virtual host configuration file for Drupal.

mkdir -p /var/www/drupal
cd /etc/apache2/sites-available

Now create a new file called 'drupal.conf' with vim that will contain the Apache virtual host configuration:

vim drupal.conf

Paste the virtual host configuration below:

        <VirtualHost *:80>
                DocumentRoot /var/www/drupal

                # Redirect http to https
                RedirectMatch 301 (.*)$1

        <VirtualHost _default_:443>

                # Server Info
                ServerAdmin webmaster@localhost

                # Web root
                DocumentRoot /var/www/drupal

                # Log configuration
                ErrorLog ${APACHE_LOG_DIR}/drupal-error.log
                CustomLog ${APACHE_LOG_DIR}/drupal-access.log combined

                #   Enable/Disable SSL for this virtual host.
                SSLEngine on

                # Self signed SSL Certificate file
                SSLCertificateFile      /etc/apache2/ssl/drupalssl.crt
                SSLCertificateKeyFile /etc/apache2/ssl/drupalssl.key

                <Directory "/var/www/drupal">
                        Options FollowSymLinks
                        AllowOverride All
                        Require all granted

                <FilesMatch "\.(cgi|shtml|phtml|php)$">
                                SSLOptions +StdEnvVars
                <Directory /usr/lib/cgi-bin>
                                SSLOptions +StdEnvVars

                BrowserMatch "MSIE [2-6]" \
                                nokeepalive ssl-unclean-shutdown \
                                downgrade-1.0 force-response-1.0
                # MSIE 7 and newer should be able to use keepalive
                BrowserMatch "MSIE [17-9]" ssl-unclean-shutdown


Replace the domain name with the domain name of your Drupal website.

Save the file and exit.

Now test the apache configuration with command:

apachectl configtest

If you see "Syntax ok", then the apache configuration is correct.

Now activate the Drupal virtual host and restart the Apache:

a2ensite drupal
systemctl restart apache2

The virtual host is created and configured.

Step 5 - Install and Configure Drupal 8

We have to install git and drush before we will install Drupal. So let's install them with the following apt command:

apt-get install git drush -y

Now go to the Drupal directory and download the new Drupal 8 version with the 'drush command'.

cd /var/www/drupal
drush dl drupal-8

Move all Drupal files to "/var/www/drupal":

mv drupal-8.0.1/* .
rm -rf drupal-8.0.1/

Go to the directory 'sites/default' and copy the two configuration files 'settings.php' and 'services.yml':

cd sites/default
cp default.settings.php settings.php
cp services.yml

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 "" and you will be switch to https connection automatically.

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

Chose language in Drupal installer.

Select 'Standard' installation profile.

Chose Drupal 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:

Drupal database settings.

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

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

Drupal site configuration.

Drupal is installed and configured.

The Drupal installation is finished.


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.

Share this page:

23 Comment(s)