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.25.tar.gz tar -xvzf drupal-7.25.tar.gz sudo mkdir /var/www/drupal sudo mv drupal-7.25/* drupal-7.25/.htaccess drupal-7.25/.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 or http://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.
The first account will automatically become the main administrator account with total control.
Issues specific to Drupal 7
When installing Drupal 7 on a local machine you may encounter problems with installing "Modules" and Themes", with "Email authentication" and also with "cron" maintenance jobs.
Howto Install Modules When trying to install a module this error may be displayed
"WARNING: You are not using an encrypted connection, so your password will be sent in plain text. Learn more." "To continue, provide your server connection details"
The warning message is a bit misleading, The problem is write access to directory's on the web server.
If you not to worried about security then changing write access is the quick method
When the user is www-data:
sudo chown www-data:www-data -R /var/www/drupal/sites
From a security point of view it appears that the preferred method is to manually install modules over SSH with command line. This method will be slower but more secure. see Install Modules
Example: Install Wysiwyg
wget http://ftp.drupal.org/files/projects/wysiwyg-7.x-2.1.tar.gz tar -xvzf wysiwyg-7.x-2.1.tar.gz sudo mkdir -p /var/www/drupal/sites/all/modules/wysiwyg sudo mv wysiwyg/* /var/www/drupal/sites/all/modules/wysiwyg
Wysiwvg requires a client-side editors, for CKEditor run the following
wget http://download.cksource.com/CKEditor/CKEditor/CKEditor%203.6.1/ckeditor_3.6.1.tar.gz tar -xvzf ckeditor_3.6.1.tar.gz sudo mkdir -p /var/www/drupal/sites/all/libraries/ckeditor sudo mv ckeditor/* /var/www/drupal/sites/all/libraries/ckeditor
For email authentication the server email may need to be set-up. This example routes the mail through GMail SMTP servers. Make sure you have a gmail account setup with POP/IMAP enabled.
sudo apt-get install exim4
sudo dpkg-reconfigure exim4-config
Choose mail sent by smarthost; received via SMTP or fetchmail
Type System Mail Name: e.g. company.com (Any name will do)
Type IP Adresses to listen on for incoming SMTP connections: 127.0.0.1
Leave Other destinations for which mail is accepted blank
Leave Machines to relay mail for: blank
Type Machine handling outgoing mail for this host (smarthost): smtp.gmail.com::587
Choose NO, don’t hide local mail name in outgoing mail.
Chose NO, don’t keep number of DNS-queries minimal (Dial-on-Demand).
Choose YES, split configuration into small files
- Mail for postmaster. Leaving blank will not cause any problems though it is not recommended
sudo nano /etc/exim4/passwd.client
And add the following lines, substituting yourAccountName and y0uRpaSsw0RD as appropriate
gmail-smtp.l.google.com:yourAccountName@gmail.com:y0uRpaSsw0RD *.google.com:yourAccountName@gmail.com:y0uRpaSsw0RD smtp.gmail.com:yourAccountName@gmail.com:y0uRpaSsw0RD
Finally for all versions of Debian, run
sudo /etc/init.d/exim4 restart
That should be it. You can test by using the command line mail client.
- Give a subject and press enter
- Type something and press enter
- Type a single . (dot) and press enter
- Press enter for a blank CC:
"Cron" maintenance jobs
The URL of the cron.php page requires a "cron key" which is automatically generated during installation. The full URL of the page, with the cron key, is available in the "Cron maintenance tasks" section of the Status report page at Administration > Reports > Status report.
If you installed the package from the official repository, add the cron key from the report above to the $cron_key variable in site's settings.php or in cronkey.php under /etc/drupal/7/sites/default.
to see how things work.
If the "cron key" is not properly configured, warnings will be emailed to www-data user. You can read them with:
mail -f /var/mail/www-data
Modify the RewriteBase if you are using Drupal in a subdirectory or in a VirtualDocumentRoot and the rewrite rules are not working properly. For example if your site is at http://example.com/drupal uncomment and modify the following line:
sudo nano /var/www/drupal/.htaccess
# RewriteBase /drupal
or maybe (configuration dependant)
sudo sed -i 's/# RewriteBase \/drupal/ RewriteBase \/drupal6/' /etc/drupal/6/htaccess
Adjust PHP memory limit
You should increase the default PHP memory limit value (the amount of memory dedicated to running scripts), since the default 8 MB is not sufficient. Use 96 MB (or even 160M) if you intend to use graphics (although for simple uses 32 MB may be sufficient).
In newer versions of Drupal6, you can simply edit the settings.php file and add the line:
In older versions of Drupal5, or if using PHP for many different uses, it is best to increase the amount of PHP memory using this method:
Edit the /etc/php5/apache2/php.ini file and increase the memory_limit value to 96M (or another value of your choice).
If using PostgreSQL, you can also edit the /etc/php5/apache2/php.ini file to accommodate PostgreSQL options by adding the line:
Adjust PHP Error Reporting
An adjustment to the error reporting is required for the install.php page to come up properly. Edit your settings.php file (e.g., /etc/drupal/6/sites/default/settings.php) and add the following ini_set line after the existing ini_set lines:
This is based upon the recommendations from the drupal.org forms: http://drupal.org/node/514334#comment-1912924
Adjust PHP extensions (Drupal 7 only)
Drupal 7 will only support MySQL 5.0.15 or higher, and requires the PDO database extension for PHP. The PHP extension for connecting to your chosen database must be installed and enabled. Drupal's currently supported database connectors are: mysql (the original MySQL extension), mysqli (an improved connector for newer MySQL installations), and pgsql (for PostgreSQL). Note: PHP 5.x no longer enables the mysql extension by default. Please read the links above for installing and enabling your chosen connector. Additionally, Drupal 6.x does not provide the option to select the mysql connector if mysqli is enabled in your PHP configuration.
sudo apt-get install php5-gd
For more details see http://drupal.org/requirements
* Ubuntuguide Drupal tips -- installation tips for installing Drupal 7 in Ubuntu. Includes advanced configuration options.
* Ubuntuguide for Kubuntu -- general guide for Kubuntu
TurnKey Drupal Appliance
Some users may prefer to skip manual installation by using the unofficial pre-integrated TurnKey Drupal Appliance based on Ubuntu LTS.
Drubuntu minimal cd
If you like to use a premade ubuntu user thatis still under development and made for Drupal beginners and Drupal Pros you could try Drubuntu This includes Drupal 7 currently.