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:
- Download the PHP source code (be sure to use the PHP version that’s the same with your installation).
- Unpack the archive and go to the source directory (well, duh!).
- Run
./configure ---with-pgsql=shared,/usr
(I know it’s too short, but just trust me on this, OK). - Run
make
. - Don’t run
make install
orcheckinstall
(if you’re using checkinstall, that is) like you usually would. - Just copy
<php source dir>/modules/pgsql.so
to/usr/lib/php/extensions
. - As root, edit your
/etc/apache/php.ini
file and look for a line sayingextension=mysql.so
- Under this line type in:
extension=pgsql.so
and save the file. - 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.