SoSLUG Archive

Drupal Howto

Drupal on your Localhost Desktop PC

SoSLUG is changing, with membership increasing almost weekly we have decided to provide more help and assistance to our members by providing formal workshops on a monthly basis covering subjects that as a group, our members would like more information on. These formal workshops will take place each 2nd Thursday in the month starting with me Derek Shaw on the 9th April covering the Drupal installation. Future workshops will include MPD (Mplayer deamon) and client applications by Dan Patynski and Ardour and Jack workshops by Gary Cordery.

Drupal Workshop presentation Notes for Thursday 9th April 2009 @ 9:00pm by Derek Shaw


Before I can answer the question what is Drupal we need to reflect on what preceded it and to cut a very long story short that was “html or (Hyper Text Markup Language)” and it was this, that was the pivotal language that started the explosion which is the internet we recognise today.

In 1980, physicist Tim Berners-Lee, who was an independent contractor at CERN, proposed and prototyped ENQUIRE, a system for CERN researchers to use and share documents. In 1989, Berners-Lee and CERN data systems engineer Robert Cailliau each submitted separate proposals for an Internet-based hypertext system providing similar functionality. The following year, they collaborated on a joint proposal, the WorldWideWeb (W3) project, which was accepted by CERN.

Quite simply using this language allowed for something quite remarkable within it’s then static pages. Linking was just one of it’s attributes but by simply adapting a chosen word within some text markers placed at the beginning and end of the chosen word you could link that word to another site, bookmark or image.

This code then still in it’s infancy had all browser companies developing for the Internet and with more and more people placing value on the site’s being constructed it quickly became apparent that not everyone was playing the on same field. Netscape then was then the most stable and trusted of Internet applications which was quickly adopted by commercial and individuals alike, this because Netscape was the only real contender Micro$oft was yet to realise how big the Internet was to become and wealth of information it would eventually unlock to it’s users and client base. Micro$oft on the pretext of added functionality would introduce there own standards for browsers and web servers, this had the inevitable effect Micro$oft was by now getting really big and throwing it’s weight around demanding a bigger market share of the Internet, this would have been fine but they adopted practices to squeeze out all but the most determined of it competitors. New software was introduced to cope with the code differences between different browsers, but all this really offered was a way to check the html code on the different browsers.

I was about this time that some people dabbled in something called dynamic content this allowed the html code to be generated on the fly for any given page being accessed. This was the for runner to Drupal and CMS (Content Management Systems) in particular Zope was one of the earliest contenders.


Drupal (is a free and open source modular framework and Content Management System (CMS) written in PHP. It is used as a “back end” system for many different types of websites, ranging from small personal blogs to large corporate and political sites.

The standard release of Drupal, known as “Drupal core”, contains basic features common to most CMSs. These include the ability to register and maintain individual user accounts, administration menus, RSS-feeds, customizable layout, flexible account privileges, logging, a blogging system, an Internet forum, and options to create a classic “brochureware” website or an interactive community website.

Drupal was also designed to allow new features and custom behavior to be added by third parties. For this reason, Drupal is sometimes described as a “Content Management Framework”. Although Drupal offers a sophisticated programming interface for developers, no programming skills are required for basic website installation and administration.

Drupal can run on any computing platform that supports:

  • a web server capable of running PHP (version 4.3.5+), including Apache, IIS, Lighttpd, and nginx.
  • a database, such as MySQL or PostgreSQL, to store content and settings

With simply thousands of CMS systems available Zope was one of the earlier contenders but many have sprung up like WordPress and Joomal each have there merits but Drupal just seems to have caught on better than most. There structure for the most part contain cascading style sheets and PHP templates that access information held within some sought of database. This surprisingly enough makes websites created this way very portable and flexible. Drupal like many CMS systems are cross platform meaning they can be used on very nearly any operating system.


This tutorial will focus on providing a Drupal installation method via a vanilla Ubuntu Desktop install a LiveCD is as vanilla as you can possibly get and is only as permanent as the RAM it resides in. This makes it very easy for you to repeat your Drupal installation as many or as few times as you wish.

  • Run Ubuntu as a LiveCD
  • Download Drupal to Desktop
  • Install all dependant and necessary packages
  • Configure Apache
  • Starting and Stopping Apache
  • Installing Drupal
  • Drupal structure and overview
  • Drupal file system and settings
  • File Permissions
  • Mysql database
  • Questions


We will begin this tutorial as though you had a completely vanilla installation to your PC Desktop or Laptop we would stress that Drupal sites require an installation to something like Ubuntu Server not a Desktop. However it is always very risky to install anything to a live server so for the purpose of this tutorial we will step back a little and install this Drupal to something that does not matter a vanilla install or LiveCD.

    1. Run Ubuntu as a LiveCD – Place a Live CD or Usb pendrive into your system and boot from it, this tutorial is focused on Ubuntu as the Operating System but the package installation should apply with very minor differences regardless and can be ported to many OS’s without to much trouble.
    2. Download Drupal – Drupal has many downloadable packages for installation at the time of writing these notes we recommend you select the latest stable release for Drupal Version 6 you can download a later version if you wish but for the purposes of this tutorial nothing additional will be gained if you do so. These packages are just as valid for Window$ as it is for Macs and Linux. This because all the files are written as text editable files there are to my knowledge no binary executables within it’s files, we are further aware that Drupal is within the Ubuntu repositories we recognise this, but its integration although not complex, it’s file structure is all over the place and difficult to understand and therefore to edit and configure. Ubuntu may have reasons, probably good security reasons why it has adopted the method it has, for the purpose of this tutorial however we recommend you use Drupal’s own installation profile the file structure of which is much easier to understand and locate as the tree is visible from only one folder.

Open the Drupal compressed file and for now uncompress and leave the contents on your Desktop, the reason should become apparent later in this tutorial. Using your mouse place the mouse icon on the downloaded compressed file and using a double left click in quick succession open the File Roler application or use a right mouse button click to activate the alternative menu and select “Open”. This is by no means the only way to open this compressed file we could use the command line via a terminal window.
Drupal Down

  • Install Dependant packages – Next we need to download some additional packages not available for a normal Desktop installation these comprise of “Apache2.x” (Web Server), “Mysql” (An Open Source System Query Language Server and Clients), “PHP5” (PHP: Hypertext Preprocessor). We can download each of these as individual packages or as a single package bundle neither method has merit over the other as these packages in the end are exactly the same. This can be achieved in any one of a number of different ways essentially you require these files.



  • apache2
  • mysql client
  • mysql server
  • php5
  • php5-gd
  • php5-mysql

You can download, install all these files and there dependencies using apt-get, Synaptic Package Manager, Aptitude and so on. We will show you one such method you may not have come across called tasksel, this is a command line tool usually used on Ubuntu and Debian servers rather than Desktop’s but the principle is exactly the same.

#> sudo apt-get install lamp-server^

The “lamp-server” is an acronym for Linux, Apache, Mysql & PHP” and the “^” is rather special as lamp-server will not install without it, you will find it has most of the separate packages needed. In addition to “lamp-server^” we will also need to install the “php5-gd” library package, we can use “apt-get” for this:

#> sudo apt-get install php5-gd

Lampserver  Lampserver1  Lampserver2  Lampserver3  Lampserver4  Lanpserver5

  • Configure Apache – On installation of “lamp-server”, “Apache” would have already been started this we can test this by opening a browser and replacing the URL (“Uniform Resource Locator”) with the word “localhost” & press enter, if displayed on the browser window are the words “it works” then apache is installed and working.

Whilst apache is working it is not yet configured at least not for Drupal the main purpose of this installation tutorial, so we need to reconfigure how apache is going to work. Drupal likes to use clean URLs these are URL addresses that do not include “?=” characters in them however to enable this feature of “Apache” we need to edit one of it’s configuration files in “/etc/apache2/site-available” the file we are interested in is called “default”

#> sudo vim /etc/apache2/sites-available/default

Sample file “default” original

DocumentRoot /var/www/

Options FollowSymLinks
AllowOverride None

Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all

Let’s have a look at the format of this file “default” the first line specifies the location of the website document root that is to say where in this case drupal will start from. Let’s look at some scenarios to clarify this statement:

In simplest term’s with a DocumentRoot specified as “/var/www” when you type localhost in your browser whatever “index.html” files exist in this directory the contents will be displayed in the browser window. If we then place the Drupal folder into this directory without changing DocumentRoot we would need to specify the drupal folder name on the URL address to access our Drupal site. Please note any changes made to this file and saved will have no effect until the apache server is again restarted.

denotes the default root of the DocumentRoot if we now place drupal now uncompressed into “/var/www” in order to access drupal as a site we need to specify the drupal folder in addition to localhost for example http://localhost/drupal to change this so localhost is the root but drupal is called, we need to alter the DocumentRoot specified by default file.

DocumentRoot /var/www/drupal6

Options FollowSymLinks
AllowOverride None

Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all

If we alter the file named default to the above and restart apache server when we type localhost as a url into our browser we should now be able to access our drupal site. in addition to the change above we also want to make possible clean URL’s to accomplish this we need to change a different line of this configuration file.

DocumentRoot /var/www/drupal6

Options FollowSymLinks
AllowOverride None

Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all

This finishes what we do by way of file configuration changes, but as you so rightly guessed we have one thing more to do before this section is complete. In addition to the last entry we made in the default file we also have to add a module to allow Apache to rewrite our URL so clients that access the site are unaware of the file structure of the website. Another command line utility that comes with apache allows us to switch certain apache modules on or off. “a2” stands for apache2 “en” stands for enable and “mod” will refer to module so “a2enmod” actually means “apache2 enable module”

#> sudo a2enmod rewrite

Activating the above command will initiate a warning on the command line that for the change to take effect you need to restart apache.

  • Restarting Apache – For any administrator starting, stoping and restarting the apache server is essential stuff to know and not really very difficult.

    #> sudo /etc/init.d/apache2 restart

    This about the only command you need commit to memory, however by replacing restart with the words “start” and “stop” you now have the full range of commands you need know for controling apache.

  • Drupal structure and overview – Without worrying to much about drupal file permissions and settings lets just take a quick look at the file structure of drupal, we can achieve this best whilst drupal remains on the Desktop uncompressed

    Drupal is a collection of CSS and PHP files these are accessed in the same way we access a series of html files allowing us to jump from page to page within the website, unlike html files this collection of files can do a great deal more than any series of html files. What separates drupal apart from static html files is it’s ability to dynamically update reconfigure virtually any aspect of the website and that of it’s design.

    Drupal has about three folders that you need to be aware of as these are likely to be the folders you will access and therefore alter the contents of the most. These would be the “modules”, “sites” and “themes” folders. The modules folder contains a number of modules used by drupal that is standard with any installation this can have virtually any number of additional modules that would increase the functionality of any given site. In addition to this the, sites folder would imply that more than one site could reside within this server, whilst this is true it would require a change to the apache server configuration to enable this to function. The themes folder contains obviously enough a limited number of themes drupal uses by default here again we can add new themes from a massive library, however so called contributed themes should be placed in “sites/all/themes” these change instantly the style feel and mood of the site being created.

    Drupal Folder  Drupalfiles  Drupalmodules  Drupalsite  drupalthemes

    Now copy this drupal directory to the “/var/www/” folder you can do this with the command below.

    #> sudo mv ~/Desktop/drupal-6.10 /var/www
    #> cd /var/www
    #> sudo mv drupal-6.10 drupal6

    You may also what to rename this folder after it has been moved so that drupal-6.10 is change to drupal6 this can be achieved using the mv command as above.

  • Drupal settings – Going back to the sites folder for a moment this contains two folders of interest the “all” and the “default” the “all” folder is the directory that should be used to place downloaded and custom modules and themes which are common to all sites. This will allow you to more easily update Drupal core files. These modules and themes should be placed in subdirectories called modules and themes.

    Modules and themes that are for a specific site should be stored in the “sites/domain-name/modules” and “sites/domain-name/themes” folder for a given site, this would apply to sites that are custom made for a client

    The “default” folder on the other hand contain the defaults files settings, modules and themes that are copied to the domain name folder within the sites folder here’s an example.

    #> sudo cp -r /var/www/drupal6/sites/default /var/www/drupal6/sites/

    Once this folder has been copied we can then alter the settings file to reflect the domain the database access details we wish to use. There are only two lines we need to change in this file, these relate to the mysql the base URL with fully qualified domain name of the site.

    #> sudo vim /var/www/drupal6/sites//default-settings.php

    As we are not setting up a new domain and this will be the only drupal installation we can construct our website using the default folder and the copied default setting’s.php.

    #> sudo cp /var/www/drupal6/sites/default/default.settings.php /var/www/drupal6/sites/default/settings.php
    #> sudo vim /var/www/drupal6/sites/default/settings.php

    When editing this drupal configuration file we recommend you adopt the mysql settings outlined towards the bottom of this page or your own settings, however all these values are case sensitive so double check that username, password and database name are identical. The base URL should be for this installation http://localhost be sure to remove the remark statement at the begining of the line.

    Rather than display the entire file we will just show the snippets from the file to highlight the changes necessary.

    * Database URL format:
    * $db_url = ‘mysql://username:password@localhost/databasename’;
    * $db_url = ‘mysqli://username:password@localhost/databasename’;
    * $db_url = ‘pgsql://username:password@localhost/databasename’;
    $db_url = ‘mysql://username:password@localhost/databasename’;
    $db_prefix = ”;

    Alter the settings marked with < and > to reflect the settings for your mysql database

    * Database URL format:
    * $db_url = ‘mysql://username:password@localhost/databasename’;
    * $db_url = ‘mysqli://username:password@localhost/databasename’;
    * $db_url = ‘pgsql://username:password@localhost/databasename’;
    $db_url = ‘mysql://<mysql_user_name>:<mysql_password>@localhost/<mysql_databasename>’;
    $db_prefix = ”;

    * It is not allowed to have a trailing slash; Drupal will add it
    * for you.
    # $base_url = ‘’; // NO trailing slash!

    Change this portion to your domain with which the website is to be recognised by


* It is not allowed to have a trailing slash; Drupal will add it
* for you.
$base_url = ‘http://<>’; // NO trailing slash!


  • File Permissions – Now that we have moved the drupal folder to “/var/www” we need to remember that we have in fact transfered these files to a reserved system area of our file system. So that we can continue to add themes and modules we need to change the permmissions of these files as they where transfered as user root. Because of this we need root user to change the permissions so we can alter and amend the files and folders in this directory as a normal ubuntu liveCD user.

    #> sudo chown -R www-data:ubuntu /var/www/drupal6

  • Mysql database – There are a couple of ways you can create a database in Mysql “Phpmyadmin” is one of them, this is a web application that is used to create delete or modify new or existing databases, but we are not going to use this application and not because it doesn’t have it’s good points it does. I am just of the opinion that “Phpmyadmin” deserves a tutorial in itself. So for the purposes of this tutorial we will use the command line, once you have the necessary info it is very easy and quick.

    #> mysql -uroot
    mysql> create database SWAGGER;
    mysql> use SWAGGER;
    mysql> grant all privileges on SWAGGER.* to ‘swagger_dbu’@’localhost’ identified by ‘swagg3r’;
    mysql> flush privileges;
    mysql> quit

    Although, we for the purpose of this tutorial and expediency have refrained from using passwords where possible, we strongly suggest the use of strong memorable usernames and passwords when dealing with Mysql. Do not under any circumstance build a website with weak or non existent passwords, we also suggest a strong and memorable password when setting up “lamp-server” with a “root” user password in a previous section. If you are learning about “mysql” or “drupal” for the first time as some of you will be a desktop installation is quite safe enough, having usernames and passwords at different levels through a website construction adds a great deal of complexity to an already difficult installation. At no time do we suggest such installation methods as described in this tutorial be adopted to server or Ubuntu server installations especially if the website in question is to sit on the internet. (When you set a root password for mysql you need to add -p to -uroot to be able to login i.e. “mysql -uroot -p”)

  • Drupal Installation Script – We are rapidly reaching the conclusion to this tutorial, this is the final step, when we type in http://localhost we are presented with a mysql error this is good really good. Mysql is working passwords and usernames are working all that in missing is to populate the database with a base website installation, the next few screens or so should be self explanatory. If you haven’t guessed yet you will need to append the localhost url with install.php thus: http://localhost/install.php

    drupal_ins1  drupal_ins2  drupal_ins3 drupal_ins4  drupal_ins5  drupal_ins6
    drupal_ins7  drupal_ins8 drupal_ins9  drupal_ins10


Summary – The procedures written above are the first steps into the world of drupal, the data retained on this installation is volatile, that is to say that once the power has been removed from the machine or laptop that drupal was installed to, all data and configuration will be lost. This is very much the point of this exercise, it is the basis by which you can test out repeatedly your server and website construction ability which will do no harm to your personal machine or alter it’s usual desktop use. You should consider this method as a learning platform before proceeding to the next logical step which would be a dedicated Ubuntu server installation with Drupal. We hope this tutorial has dispelled any fear or worry you may have had about drupal, apache and mysql and that this tutorial has served some useful purpose.

Author: Derek Shaw - Page reference: 2088
Last modified: Alan Campion - 2015-09-16

Categories: Archive Drupal

Add a Comment