Weblog entry #35 for simonw

Drupal with Postgres using Sarge Packages
Posted by simonw on Wed 8 Feb 2006 at 20:49
Tags: none.

Goal - install Drupal under Apache2 with a Postgres database under Sarge during my lunchbreak.

Ouch - the Tao of Debian took a knocking.

The Debian "drupal" package doesn't smoothly integrate with postgres, despite what is clearly a lot of work to make it do so by the maintainer(s).

If you have no strong feelings on database choice, and are installing a database server "just for drupal", install MySQL. However I'm a postgres bigot/fan.

First the database connection from the webserver is an issue. If you freshly installed Debian Postgres package for your database server, it defaults to "sameuser ident" for local connections. For web applications (unless using suexec!?!) this is totally useless as the applications run as "www-data", and usually try and use password authentication via localhost (or Unix sockets).

The authentication for Postgres is controlled here;

/etc/postgresql/pg_hba.conf

You probably want to change a number of lines from ending "ident sameuser" to "password", or add a line specifically for the Drupal database, but don't change the first uncommented line, that one lets the "postgres" user access using "ident sameuser" or you'll be in trouble. The file has ample comments, postgres must be restarted (or you can "pg_ctl reload" if you like Apache like control) if you edit this file.

The "drupal" package tried to create a database for you, this failed totally for me in various attempts (Try "dpkg-reconfigure -plow drupal" if you want to keep bashing your head against the brick wall). So I bailed out, and did it manually.

apt-get install drupal ## and fail to get a database working.

# Become DB admin
su - postgres      

# Insert any clean up steps needed if you tried to create a database 
# or user via the menus here....

# Create a user drupal (doesn't need any fancy privileges offered)
createuser drupal  
# Make a database called drupal, and make user drupal the owner.
createdb drupal -O drupal
# Enable the Postgres Procedural language for the database.
createlang plpgsql drupal

psql drupal ## Hey we are postgres we can do anything
 drupal=# alter user drupal password 'a_secret';
 Ctrl-D < to leave psql.

## Login as user drupal and create the database
psql drupal drupal
Passwd: a_secret
  drupal=> \i /usr/share/drupal/database/database.pgsql

There are a couple of warning at the end, due to these two lines.


CREATE FUNCTION plpgsql_call_handler() RETURNS language_handler AS
    '$libdir/plpgsql' LANGUAGE C;

CREATE TRUSTED PROCEDURAL LANGUAGE plpgsql
    HANDLER plpgsql_call_handler;

These appear to do the same as the "createlang" step earlier, so I ignored them. That I tried this a few times shows here.

Now I tried to configure the servers, and failed because the maintainers have quite sensibly put the configuration file in /etc/drupal/conf.php but I read the "drupal" install notes in "/usr/share/doc/drupal" (Oops). You need to set "db_url" (to use Postgres), and "base_url" (I used http://localhost/drupal), others you can play with if you feel brave.

Now I created a "symbolic link" in the default webserver to try it out.

cd /var/www
ln -s /usr/share/drupal drupal

And visting "http://localhost/drupal" I got to clean up a few local Apache2 configuration issues. But it fails to create a session. The error is spot on, in the "sessions" table it had "uid" column set to "not null", and it tried to insert a record with no "uid".

My hack - barely tested, and not good Karma was to run psql as user drupal, and remove the database restrictions on this table.

psql drupal drupal
password: a_secret
drupal=> drop table sessions;
drupal=> create table sessions ( uid integer, sid character varying(32), hostname character varying(128), timestamp integer default 0, session text ) ;

At which point I was away, alas lunch was over, and the boss was wondering when I would get back to some real work.

What I saw of Drupal was quite good, I've used Mambo before, and think I prefer Drupal so far, although Mambo was easier to install for not having a Debian package, and not trying to work with Postgres.

 

Comments on this Entry

Posted by simonw (84.45.xx.xx) on Wed 8 Feb 2006 at 20:59
[ Send Message | View Weblogs ]
Should have mentioned, the Debian Bug Tracking System has bugs on most, possibly all, of these issues, and is probably a better source than I am.

"reportbug" is your friend.

[ Parent | Reply to this comment ]

User Login

Username:

Password:

[ Advanced Login ]

Register Account

Quick Site Search