WDTUTORIALS
Web & Game Development Tutorials
Unity, Django, Drupal, C#, Python…
menu
Samuli Natri 2015.11.11
Entrepreneur. Software developer since the 90's.
Attended Helsinki University Of Technology (Computer Science) and Helsinki University (Social Sciences).

Drupal - How To Install Drupal In Linux

Tutorial on how to install Drupal with LAMP in Linux.

Install LAMP

An easy way to install LAMP (Linux Apache MySQL PHP) 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 apache default landing page:

In this tutorial I'm accessing a physical server in the local network from my Mac. You can get the server ip with ifconfig command (search for a line like this: inet addr:192.168.10.12). 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:

CREATE DATABASE tut_d8_02 CHARACTER SET utf8;

Grant permissions:

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

Tthe first tut_d8_02 is the database name, second tut_d8_02 is the username and the last one is the password.

You can use Ctrl + R to search for previous commands so you don't have to memorize these.

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 from here and download the package:

cd /var/www/drupal/tut/d8
sudo wget http://ftp.drupal.org/files/projects/drupal-8.0.0-rc1.tar.gz

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 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
    &lt;Directory /var/www/drupal&gt;
            Options Indexes FollowSymLinks MultiViews
            AllowOverride All
            Order allow,deny
            allow from all
    &lt;/Directory&gt;

    ServerAdmin mail@example.com

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

</VirtualHost>

dev1 is the hostname of my server. I have this line in my Mac /etc/hosts file: SERVER_IP drupal.dev1. Replace SERVER_IP with your server ip.

Enable the configuration and reload apache:

sudo a2ensite drupal
sudo service apache2 reload

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.

Check How To Install Drupal With MAMP tutorial for more about the final phase of the installation.