Drupal is a robust Content Management System that runs on a LAMP server. The LAMP server uses MySQL by default, but PostgreSQL can also be used with Drupal.
It can host blogs, forums, and a variety of other content. It has a huge selection of add-ons modules for other functionality, such as advertising, chatbox, e‑commerce, multimedia tools, instant messenger, customer relationship management, printer-friendly pages, and web-cams.
Recent releases of Ubuntu include both Drupal6 and Drupal7 in the repositories, which are the only two supported releases of Drupal. Please read this if you need help choosing a Drupal version.
Accessory Drupal add-ons modules are not included in the Ubuntu packages however and must be installed manually after initial installation.
Please refer to the Drupal installation guide for more advanced hosting features.
LAMP server installation
Easy LAMP server installation
The easiest method is to use a single command from the command-line terminal, which installs the entire LAMP stack in an integrated package:
sudo tasksel install lamp-server
If your system doesn’t provide the tasksel command, then install it:
sudo apt-get install tasksel
I also (optionally) recommend enabling the rewrite functions of Apache2, which helps with many modules in Drupal and with the correct redirection of web-pages on your Apache server:
sudo nano /etc/apache2/sites-available/default
sudo a2enmod rewrite sudo service apache2 restart
Note: The two methods listed below are not compatible. The Ubuntu package (from the repositories) installs Drupal6 in different directories from the manual method. Choose one method or the other, but do not attempt to use both. You cannot switch back and forth between the two methods.
Install Drupal package from the Ubuntu repositories
You can choose whether to install Drupal6 or Drupal7 from the repositories. As always, repository version are not the most current versions, but they can be updated easily.
sudo apt-get install drupal6
sudo apt-get install drupal7
Allow dbconfig-common to configure your database (by default: MySQL)
Then, register the Drupal module 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
Manual installation of Drupal
The following instructions are for version 7.25 of the Drupal 7 branch, which was the most current version at the time of writing. (A similar method can be used for the most current version of Drupal 6). This installation does not install Drupal in directories that are compatible with the repository packages.
wget http://ftp.drupal.org/files/projects/drupal-7.37.tar.gz 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 create a files subdirectory in your drupal default site installation directory. It will be used for files such as custom logos, user avatars, and other media associated 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 create the initial configuration 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
Manually configure the MySQL database for Drupal
You need to create a MySQL drupal database and then load the database schema into it. You can do this with phpMyAdmin or via the command line:
mysqladmin -u root -p create drupal
Where drupal is the name you picked for the mysql database that Drupal will use. You can call it anything you want.
mysql -u root -p mysql> GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER, CREATE TEMPORARY TABLES, LOCK TABLES ON drupal.* TO 'drupaluser'@'localhost' IDENTIFIED BY 'drupalpass';
You do not want to have Drupal use the mysql root user to access the database. The above command creates a mysql user (other than the mysql root user) with some priviledges to use the drupal database. You should pick something different than drupaluser and drupalpass. If the command was successful, activate the new permissions:
mysql> FLUSH PRIVILEGES;
Quit the mysql prompt:
Manually configure the PostgreSQL database for Drupal
Edit the /var/www/drupal/sites/default/settings.php file so that Drupal can know what user, password and database 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
Finally, reload Apache2.
sudo service apache2 restart
Complete the Drupal Installation through a Browser
Finally, point your browser to http://localhost/drupal/install.php (or perhaps http://localhost/drupal6/install.php orhttp://localhost/drupal7/install.php if you installed the package from the official repository), create an account, login, and follow the installation instructions to finish loading the database and configuring the site.