I wanted to play around with PostgreSQL on the test server at work today, and found the slackpack over at LinuxPackages. I was very pleased that I wouldn’t have to compile PostgreSQL from source, as such complex apps will take more time than I would like to invest.

Anyway, once I’ve installed the package, and initialised the database, I decided to give phpPgAdmin a whirl on my freshly baked PostgreSQL installation, but when I try to use it I get an error message telling me that I have not compiled proper database support into my PHP installation.

Bargh, I checked out my phpinfo(); and sure enough, Slackware‘s package was not built with the --with-pgsql option.

Most of my googling results metion that the only solution is to recompile PHP from scratch, including the --with-pgsql flag. Hmm, I’d really hate to replace my original PHP installation which was done in the “proper” way, ie. via the available slackpack. Who know what the hell I can possibly misconfigure and break!

Anyway, here’s how I got my PostgreSQL to work with the default Slackware PHP installation:

  1. Download the PHP source code (be sure to use the PHP version that’s the same with your installation).
  2. Unpack the archive and go to the source directory (well, duh!).
  3. Run ./configure ---with-pgsql=shared,/usr (I know it’s too short, but just trust me on this, OK).
  4. Run make.
  5. Don’t run make install or checkinstall (if you’re using checkinstall, that is) like you usually would.
  6. Just copy <php source dir>/modules/pgsql.so to /usr/lib/php/extensions.
  7. As root, edit your /etc/apache/php.ini file and look for a line saying extension=mysql.so
  8. Under this line type in: extension=pgsql.so and save the file.
  9. Restart your apache service by running /etc/rc.d/rc.httpd restart (again, as root)to activate PostgreSQL support in PHP.

Hope this helps other Slackers as well as Linux users in general.

Tags: , ,

What Say You?

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>