How I installed Drupal 8 on Ubuntu 16.04

Drupal 7 or Drupal 8?

With some research, I had an idea on which Drupal version to opt for. I got to know that D7 is more documented and actually has more modules than D8 whereas D8 is more user-friendly with improved editing flexibility but with some modules not ported yet. Finally, I decided to give a chance to the latest Drupal version. As a beginner, I do not think I will need to work with advanced modules. Therefore in this step by step document, we will be installing Drupal 8!

Step 1: Make sure everything is up to date

First, I made sure all of my system packages are up to date by running the following commands. Using sudo su was very useful for not to waste time entering the same password again and again.

sudo su

sudo apt-get update

sudo apt-get upgrade

Step 2: Install LAMP(Linux, Apache, Mysql, Php)

Using Tasksel allowed me to install all packages LAMP server contain. During the process, I had to enter a password for Mysql. This password was found to be needed later on. Commands:

sudo apt-get install tasksel

sudo tasksel install lamp-server


Optional: I tested if Apache is working by going to your web browser and search “localhost”. A similar web page appeared.

Installing Php extensions:

I actually missed some extensions (in orange) and had some problems later on. Here’s the correct way to do it:

sudo apt-get install php7.0 php7.0-mysql php7.0-gd php7.0-curl libapache2-mod-php7.0 php7.0-mbstring php7.0-xml nginx mysql-server php7.0-fpm php7.0-mcrypt

Enable clean URLs on Apache: 

I did not do this step correctly and had a warning later on. To me, vim was kind of tricky to use but ended up finding it pretty easy at the end. That is, press x for editing mode, esc for normal mode, :wq to save and quit. Without sudo command, it was found to be unwritable. The correct command was:

sudo vim /etc/apache2/apache2.conf

Then, I scrolled down till

Options Indexes FollowSymLinks
AllowOverride None
Require all granted

and changed the None to All as shown above. I finished up by restarting apache with:

sudo service apache2 restart

Optional: Once LAMP was installed, it was easy to check if Php was correctly configured by entering these terminal commands one after the other.

sudo nano /var/www/html/test.php

I was then able to go to ‘localhost/test.php’ on my browser. Therefore Php was configured correctly!

Step 3: Install Drupal 8

From, I took the download link location of the latest release of Drupal. For instance, here it is “”

From terminal,

I installed Drupal from the copied link location,


Once done, I then 1) extracted the file,

tar -xvzf drupal-8.2.3.tar.gz

2) created a root directory for Drupal,

mkdir /var/www/html/drupal

3) moved Drupal files to localhost,

mv drupal-8.2.3/* drupal-8.2.3/.htaccess /var/www/html/drupal

4) created some file directories for Drupal,

mkdir /var/www/html/drupal/sites/default/files

5) changed permission of these new directories so that Drupal can access it,

sudo chown www-data:www-data /var/www/html/drupal/sites/default/files

6) created a Drupal configuration file,

sudo cp /var/www/html/drupal/sites/default/default.settings.php /var/www/drupal/sites/default/settings.php

7) changed access authorization of the Drupal configuration file for Drupal.

sudo chown www-data:www-data /var/www/html/drupal/sites/default/settings.php

Step 4: Create a database and user for drupal 8

I then logged into MariaDB shell as root and proceeded by setting up a database name, username and password.
Here is how (changing the green texts),

mysql -u root -p

create database [database name];

create user [drupaluser]@localhost;

set password for [drupaluser]@localhost= password[“your-password”];

grant all privileges on [database name].* to [drupaluser]@localhost identified by ‘your-password’;

flush privileges;


Step 5: Finish Drupal installation on my web browser!

I went the setup page using the place where I installed Drupal files (it could be an IP address, localhost or a domain name) followed by /drupal.
For example, it could be or, in my case, simply localhost/drupal.

Then I was to choose my preferred language, which was English.

Right after, I was able to select my profile.Being a beginner, I preferred the Standard choice over the minimal one.

Then, coming to requirements verification, in my case, I had 2 errors.

To resolve this, I just installed any missing extension. For e.g:

sudo apt-get install php7.0-gd [As gd extension was missing]

Followed by reinstalling some extensions

sudo apt-get install –reinstall php-common php-mysql

and reloading apache.

sudo /etc/init.d/apache2 reload

Concerning the clean URLs, the solution was then found. (Step 2)

Then, for database set up, previous database name, username and passwords were needed.

It should then proceed to 40 Drupal core modules installation.

Finally, I was to fill the site maintenance account & site information. In fact, these can be re-configured again if needed in the Drupal main page!

Here is how I installed Drupal 8 on Ubuntu 16.04!

* To me, the hardest part was to configure Apache and install the missing Php extensions. They took me quite some time and research. In the end, the process was wonderful as it made me acquire some terminal commands and Ubuntu knowledge while discovering Drupal at the same time.

Thank you for reading my blog!
Comments and suggestions are always welcome. 😃

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s