Install Drupal with PostgreSQL
Drupal is an excellent PHP content management system. It supports both MySQL and PostgreSQL as the back end database for content management. Unfortunately, PostgreSQL comes up short in the documentation department: it is not even mentioned in the Drupal INSTALL.txt file. So here we do our small part for the cause and provide some instructions to get Drupal up and running with PostgreSQL.
- Download Drupal
- Create the Drupal database
- Load the Drupal database schema
- Connecting to Drupal
Just like INSTALL.txt tells you: Download Drupal and extract the archive in your web server's document root or public HTML directory.
Next we need to create a database in the PostgreSQL cluster for Drupal. Drupal has its own permission system for managing content, so I find it easiest to create a separate user for the Drupal database with the same name as the database:
% createuser test_drupal --pwprompt --encrypted Enter password for new user: Enter it again: Shall the new user be allowed to create databases? (y/n) n Shall the new user be allowed to create more new users? (y/n) n CREATE USER
% createdb test_drupal --owner=test_drupal CREATE DATABASE
Your Drupal installation has a top level folder called 'database' where you will find an installation script called 'database.pgsql'. Simply run the script with psql:
psql -U test_drupal -f /path/to/drupal/database/database.pgsql
The file 'sites/default/settings.php' has the configuration information to connect to the database and set things up for the web server. The two important values to change are the $db_url and the $base_url.
The $db_url specifies how to connect to PostgreSQL. For our sample installation the $db_url line should look like this:
$db_url = "pgsql://test_drupal:password@localhost/test_drupal";
The $base_url establishes Drupal's location in the web site directory structure. So if you put Drupal at the root, the $base_url line would look like this:
$base_url = "http://www.example.com";
or like this if you put it in a subdirectory called 'drupal':
$base_url = "http://www.example.com/drupal";
Now you should be ready to connect to Drupal at the $base_url with your web browser and start creating content. See INSTALL.txt for more configuration options and administration details.