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.
I also run Drupal on Postgresql
I run Drupal on Postgresql without any major problems. I have also submitted a fix for gsitemap which will now run on Postgresql as well.
Our main blog is at The File High Club, which mentions Drupal and Postgresql fairly frequently.
With a little more support, hopefully Drupal on Pgsql will become more common.
Good tutorial
This is a good tutorial, however, I am using postgreSQL 8.0.4 and have encountered errors when loading the database schema. The errors give a HINT of using createlang. I didn't know how to use it, so I checked the Drupal site, where I found the following how-to that worked for me:
1) Create a new database user (I used "drupal").
As the postgres user:
postgres$ createuser --pwprompt
Enter name of user to add: drupal
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
2) Create the new drupal database owned by the user created in 1) above
As the postgres user:
postgres$ createdb -O drupal drupal
3) Add the plpgsql language to the database
As the postgres user:
postgres$ createlang plpgsql drupal
4) Finally, read in the supplied database.pgsql file.
As root postgres user:
postgres$ psql -U drupal -d drupal -f database/database.pgsql
plpgsql installation
One way to avoid this issue is to make sure plpgsql is created in template1 of the database cluster. Then any new database you create will automatically have it. If you are using shared hosting, you'll have to ask your provider to do it.
After I upgraded it to
After I upgraded it to v8.1.4, I get an error about plpgsql being an invalid language, I find it need to install by running the following at the command line:
->createlang plpgsql drupal
Then go back and rerun the final part of the database.pgsql file - where the "greatest" function is created.
----------------------
software reviews
PostgreSQL was too old
Yup, you were right. The culprit was a too old PostgreSQL version. After I have upgraded it to v8.1.4, search started working flawlessly.
Thanks again!
Thanks for info
Very good, this is just the info that I needed. Now I see it would be wise to upgrade PostgreSQL before everything else. I'm not sending error messages because I turned the search off because it just floods logs. I'll see first what good will postgres upgrade bring. Thanks!
RE: Drupal/PostgreSQL/search
It could be the old PostgreSQL version. I'm using the search feature with on another site with Drupal 4.6 and PostgreSQL 8.0. Posting the error output might get you better hints and suggestions.
Also, Drupal 4.7 has done a lot more work with multi-byte characters and Unicode. I don't think 7.2 had any kind of Unicode support.
Drupal/PostgreSQL/search
The Linux Portal is also a Drupal site running with the PostgreSQL database as the backend. And quite old one if I might add, v7.2.1.
Well, everything seems to work as it should except searching. I'm getting some strange database errors when I try to use the search module. Has anyone else been successful in deploying search?
I need to ask because it might be specific to this old version of PostgreSQL and I would like to get some hints before I try to debug it myself. The Drupal CMS is the latest one - v4.7.0.
RE: Drupal Search Enhancement
I might have some time to help, but I'm curious about the advantages of using tsearch2 (I have not used it).
What features does it offer that are not readily available with the Drupal built in search module?
Since Drupal already implements search indexing, have you done any kind of performance analysis to estimate the expected speedup?
Drupal Search Enhancement
Does anyone want to work with me integrating tsearch2 into drupal?
Currently there is a trip_search (SQL search) module, and they have mySQL FTI feature.
I would like to put tsearch2 into drupal's search.
Any interest?