On Fri, Jun 09, 2006 at 11:37:06AM +0200, Joachim Schipper wrote:
> This is most likely an issue with httpd living in a chroot jail, no?
> 

If you are using unix sockets to connect to PostgreSQL, rather than TCP
sockets over the loopback, try this:

mkdir /var/www/tmp
chown www:_postgresql /var/www/tmp
chmod 1775 /var/www/tmp

Then in /etc/rc.local do this:

su -l _postgresql -c "nohup /usr/local/bin/pg_ctl start \
        -D /var/postgresql/data"
su -l _postgresql -c "ln -s /var/www/tmp/.s.PGSQL.5432 /tmp"
su -l _postgresql -c "ln -s /var/www/tmp/.s.PGSQL.5432.lock /tmp"
        echo -n ' postgresql'


And in /etc/rc.shutdown:

echo -n ' postgresql '
su -l _postgresql -c "/usr/local/bin/pg_ctl stop -m fast \
        -D /var/postgresql/data"
        rm -f /var/postgresql/data/postmaster.pid \
        /var/www/tmp/.s.PGSQL.5432 \
        /var/www/tmp/.s.PGSQL.5432.lock \
        /tmp/.s.PGSQL.5432 \
        /tmp/.s.PGSQL.5432.lock

And in /var/postgresql/data/postgresql.conf, change to this:

unix_socket_directory = '/var/www/tmp'


This permits _postgresql to create its sockets in apache's chroot, and
the symlinks permit users outside of the chroot to use the command psql
without issue.

Restart PostgreSQL with the commands in rc.shutdown & rc.local, then
scripts run by www can communicate to PostgreSQL via unix sockets,
without moving the database into the chroot.

Of course, check your pg_hba.conf.

-- 
Craig Skinner | http://www.kepax.co.uk | [EMAIL PROTECTED]

Reply via email to