Samuli Natri
Nov. 11, 2015
Updated: Mar. 08, 2017
By Samuli NatriNov. 11, 2015
(Updated: Mar. 08, 2017)

Drupal 8 Installation With Linux (Drupal 8 Tutorial #2) (Article + Video)

How to install Drupal 8 in Linux server (Ubuntu 14.04.3 LTS), set permissions and setup virtual hosts. In the video I also show how to remotely edit the files from Mac with Atom editor.

Install LAMP

An easy way to install LAMP is to use Tasksel:

sudo tasksel

You can install tasksel with sudo apt-get install tasksel

Just select LAMP server with space and go through the installation:


After the installation you should see the default apache landing page in http://:


You can get the server ip with this command: ifconfig (search for a line like this: inet addr:
If you are accessing the web server from a local machine, then navigate to: http://localhost
This default page is located in /var/www/html/index.html

Create database and grant permissions

Access MySQL with the password you created in the LAMP installation:

mysql -uroot -p

Create a database:


Grant permissions:

GRANT ALL PRIVILEGES ON tut_d8_02.* TO 'tut_d8_02'@'localhost' IDENTIFIED BY 'tut_d8_02';

TIP: You can use Ctrl + R to search for previous commands so you don't have to memorize these. In my privileges example the first tut_d8_02  is the database name, second tut_d8_02 is the username and the last one is the password.

Setup folder structure and Download the core

Create a folder for Drupal sites:

sudo mkdir /var/www/drupal

You can create subfolders here like /var/www/drupal/clients. I will use a subfolder /var/www/drupal/tut/d8 in this example.

Copy the download address for Drupal core here and download the package:

cd /var/www/drupal/tut/d8
sudo wget

Extract it and rename the folder:

sudo tar -zxvf drupal-8.0.0-rc1.tar.gz 
sudo mv drupal-8.0.0-rc1 tut_d8_02

Setup permissions

Change the owner of the site folder and files to www-data:

sudo chown -R www-data:www-data tut_d8_02 

Setup virtual hosts

Copy the 000-default.conf as drupal.conf:

cd /etc/apache2/sites-available 
sudo cp 000-default.conf drupal.conf 
sudo nano drupal.conf 

Here is an example of my drupal.conf file:

<VirtualHost *:80>
        ServerName drupal.dev1
        DocumentRoot /var/www/drupal

        <Directory /var/www/drupal>
                Options Indexes FollowSymLinks MultiViews
                AllowOverride All
                Order allow,deny
                allow from all


        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined

dev1 is the hostname of my server.

sudo a2ensite drupal
sudo service apache2 reload

I have this line in my Mac /etc/hosts file:

server-ip drupal.dev1

So now I can access the sites in /var/www/drupal from my Mac with this address: http://drupal.dev1

Go through the installation

Navigate to the site http://drupal.dev1/tut/d8/tut_d8_02/ and go through the installation.

I already went through the installation in my previous tutorial so check it out:
How to install Drupal 8 with MAMP (Article + Video)


One of the most difficult operations for a Drupal Server is setting the correct choices for Postfix MTA (Message Transfer Agent), as most email sever and Virtual host supplies disable port 25 SMTP (Simple Mail Transfer Protocol). That means you need setup mail out for Postfix in order to make use of it rich host of features using secure mail protocols. Such a tutorial for 14.04 and 16.04 server installs I have yet to find. As this is part of getting a Drupal server to work I thing its worth bringing some light to this dark Postfix mystery.

Unfortunately this is beyond me. I have had success using the SMTP module for basic mailing needs.

Add new comment