Gentoo Wiki


This article is part of the HOWTO series.
Installation Kernel & Hardware Networks Portage Software System X Server Gaming Non-x86 Emulators Misc

Apache2 Series



Addons & Tunnels




Image:Drupal logo.png


Drupal is software that allows an individual or a community of users to easily publish, manage and organize a great variety of content on a website. SpreadFirefox and KernelTrap are examples of sites powered by Drupal.

Installing Drupal


At the time of writing, www-apps/drupal is masked as experimental only. If you run a "stable" system, you'll have to add it to your /etc/portage/package.keywords.

File: /etc/portage/package.keywords


Now we can get on with emerging:

# emerge drupal

If you have the vhosts USE flag set, you will have to run webapp-config manually.

# webapp-config -I -h <FQDN_hostname> -u root -d /drupal drupal 4.6.2

where <FQDN_hostname> is the FQDN (fully qualified domain name) hostname of your virtual host.

If you do not have the vhosts USE flag set, then webapp-config will get run for you during the emerge.

Create Drupal database

Drupal requires a bit of setup to get working. So here's what you'll need to do. Copy this script to your drupal/ directory. [Where is the drupal/ directory?]

File: drupal-script
USE mysql;
INSERT INTO user (host, user, password, select_priv, insert_priv, update_priv) VALUES ('localhost', 'drupal', PASSWORD('passwd'), 'Y', 'Y', 'Y'); 
CREATE database drupal;
USE drupal;
GRANT ALL PRIVILEGES ON drupal.* TO drupal@'%' IDENTIFIED BY 'passwd';
FLUSH privileges;

Where 'passwd' is the password required to log in as the MySQL user.

Then execute the script:

# mysql -u root -p < drupal-script

This will create a new user 'drupal' and a database 'drupal' for your Drupal site and load the drupal database scheme.

Note: For Drupal 5.2: There is not an install script, to install pick your browser to http://localhost/drupal/install.php

Configure drupal base options

Before you can run Drupal, you must set the database URL and the base URL to the web site. Open the configuration file and edit the line to match the database defined in the previous steps:

File: /var/www/localhost/htdocs/drupal/sites/default/settings.php

username and passwords are the ones you used with the GRANT command in mysql.

$db_url = 'mysql://drupal:passwd@localhost/drupal';

Drupal will make all links start with this, so make sure you are using something accessible to everyone. If you are installing drupal somewhere other than the root directory, add a slash followed by your directory within the quotation. Never leave a slash at the end.

$base_url = '';

Add drupal entry to cron

Many Drupal modules have periodic tasks that must be triggered by a cron job. To activate these tasks, you must call the cron page. This will pass control to the modules and the modules will decide if and what they must do.

The following example crontab line will activate the cron script on the hour (you can edit the crontab with crontab -e:

0 * * * * wget -O - -q http://localhost/cron.php

You can now point your browser to http://localhost/install.php .. your drupal database will be setup, and you are ready to go!!

Installing Drupal modules

Installing and configuring modules for Drupal is a lot of fun. You can browse the list at . Untar the packages to drupal/modules but remember, you have to update the database manually for most modules! Installation instructions come with the tar package.

For example, if you want to install the Daily module, and your user for mysql is drupal:

$ mysql -u drupal -ppassword drupal < daily.mysql

PHP5 notes

dev-lang/php5 must be built with pcre and session USE flags.

If you rebuild php5 changing flags you will need to restart apache2.

Retrieved from ""

Last modified: Mon, 04 Aug 2008 09:55:00 +0000 Hits: 22,924