Email This List Email This List Print This List Print This List

How to install Drupal on your Ubuntu Serv­er

Drupal is a robust Con­tent Man­age­ment Sys­tem that runs on a LAMP serv­er. The LAMP serv­er uses MySQL by default, but Post­gr­eSQL can also be used with Drupal.

It can host blogs, for­ums, and a vari­ety of oth­er con­tent. It has a huge selec­tion of add-ons mod­ules for oth­er func­tion­al­ity, such as advert­ising, chat­box, e‑commerce, mul­ti­me­dia tools, instant mes­sen­ger, cus­tom­er rela­tion­ship man­age­ment, print­er-friendly pages, and web-cams.

Recent releases of Ubuntu include both Drupal6 and Drupal7 in the repos­it­or­ies, which are the only two sup­por­ted releases of Drupal. Please read this if you need help choos­ing a Drupal ver­sion.

Access­ory Drupal add-ons mod­ules are not included in the Ubuntu pack­ages how­ever and must be installed manu­ally after ini­tial install­a­tion.

Please refer to the Drupal install­a­tion guide for more advanced host­ing fea­tures.

LAMP serv­er install­a­tion

Use any meth­od to install the LAMP stack pack­ages. Vis­it Apache PHP MySQL for more inform­a­tion on LAMP.

Easy LAMP serv­er install­a­tion

The easi­est meth­od is to use a single com­mand from the com­mand-line ter­min­al, which installs the entire LAMP stack in an integ­rated pack­age:

sudo tasksel install lamp-server

If your sys­tem does­n’t provide the tasksel com­mand, then install it:

sudo apt-get install tasksel

I also (option­ally) recom­mend enabling the rewrite func­tions of Apache2, which helps with many mod­ules in Drupal and with the cor­rect redir­ec­tion of web-pages on your Apache serv­er:

Edit the file “/etc/a­pache2/s­ites-avail­able/de­fault” and replace every occur­rence of “Allo­wOver­ride none” with “Allo­wOver­ride All”, then run:

sudo nano /etc/apache2/sites-available/default
sudo a2enmod rewrite
sudo service apache2 restart

Drupal Install­a­tion

Note: The two meth­ods lis­ted below are not com­pat­ible. The Ubuntu pack­age (from the repos­it­or­ies) installs Drupal6 in dif­fer­ent dir­ect­or­ies from the manu­al meth­od. Choose one meth­od or the oth­er, but do not attempt to use both. You can­not switch back and forth between the two meth­ods.

Install Drupal pack­age from the Ubuntu repos­it­or­ies

You can choose wheth­er to install Drupal6 or Drupal7 from the repos­it­or­ies. As always, repos­it­ory ver­sion are not the most cur­rent ver­sions, but they can be updated eas­ily.

sudo apt-get install drupal6


sudo apt-get install drupal7

Allow dbcon­fig-com­mon to con­fig­ure your data­base (by default: MySQL)

Then, register the Drupal mod­ule with Apache:

sudo cp /etc/drupal/6/apache2.conf /etc/apache2/mods-enabled/drupal.conf


sudo cp /etc/drupal/7/apache2.conf /etc/apache2/mods-enabled/drupal.conf

Finally, restart Apache:

sudo service apache2 restart

Manu­al install­a­tion of Drupal

The fol­low­ing instruc­tions are for ver­sion 7.25 of the Drupal 7 branch, which was the most cur­rent ver­sion at the time of writ­ing. (A sim­il­ar meth­od can be used for the most cur­rent ver­sion of Drupal 6). This install­a­tion does not install Drupal in dir­ect­or­ies that are com­pat­ible with the repos­it­ory pack­ages.

tar -xvzf drupal-7.37.tar.gz
sudo mkdir /var/www/drupal
sudo mv drupal-7.37/* drupal-7.37/.htaccess drupal-7.37/.gitignore /var/www/drupal

It is required to cre­ate a files sub­dir­ect­ory in your drupal default site install­a­tion dir­ect­ory. It will be used for files such as cus­tom logos, user avatars, and oth­er media asso­ci­ated with your new site.

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

It is also required to cre­ate the ini­tial con­fig­ur­a­tion file for the default site.

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

Manu­ally con­fig­ure the MySQL data­base for Drupal

You need to cre­ate a MySQL drupal data­base and then load the data­base schema into it. You can do this with phpMy­Ad­min or via the com­mand line:

mysqladmin -u root -p create drupal

Where drupal is the name you picked for the mysql data­base that Drupal will use. You can call it any­thing you want.

mysql -u root -p


You do not want to have Drupal use the mysql root user to access the data­base. The above com­mand cre­ates a mysql user (oth­er than the mysql root user) with some priv­iledges to use the drupal data­base. You should pick some­thing dif­fer­ent than drupaluser and drupal­pass. If the com­mand was suc­cess­ful, activ­ate the new per­mis­sions:


Quit the mysql prompt:

mysql> \q

Manu­ally con­fig­ure the Post­gr­eSQL data­base for Drupal

Edit the /var/www/drupal/sites/default/settings.php file so that Drupal can know what user, pass­word and data­base to use.

sudo nano /var/www/drupal/sites/default/settings.php
        * Database URL format:
        $db_url = 'pgsql://username:password@localhost/databasename';
        where username = drupaluser  password = drupaluserpass databasename = drupaldb

Reload Apache

Finally, reload Apache2.

sudo service apache2 restart

Com­plete the Drupal Install­a­tion through a Browser

Finally, point your browser to http://localhost/drupal/install.php (or per­haps http://localhost/drupal6/install.php orhttp://localhost/drupal7/install.php if you installed the pack­age from the offi­cial repos­it­ory), cre­ate an account, login, and fol­low the install­a­tion instruc­tions to fin­ish load­ing the data­base and con­fig­ur­ing the site.

admin has written 133 articles