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 installorcheckinstall(if you’re using checkinstall, that is) like you usually would. - Just copy
<php source dir>/modules/pgsql.soto/usr/lib/php/extensions. - As root, edit your
/etc/apache/php.inifile and look for a line sayingextension=mysql.so - Under this line type in:
extension=pgsql.soand 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.









February 12th, 2006 at 10:01 am
Thanks alot man you really saved me some time
February 12th, 2006 at 2:12 pm
Glad the tip helped you
April 7th, 2006 at 11:45 pm
Wouldn’t it be cleaner and just as simple to get the Slackware source for the php package, then modify the php.SlackBuild script to add the one option? Then you would get a package you could install using “installpkg” that would have PHP exactly as Slack has it by default but with only one option different.
April 8th, 2006 at 7:57 am
Just to get one measly library?
In one word; no.
June 21st, 2006 at 9:47 pm
Thanks!
November 30th, 2006 at 11:10 am
yep nice tip, Can-it pro owe you cos i wasnt gonna recompile
December 16th, 2006 at 6:10 am
it works but, when i cant connect and pg_last_error returs a void string.
host,pass,pass and db are ok.
any hint?
December 17th, 2006 at 9:07 pm
vizzz,
That’s more of a connection issue rather than the module.
December 12th, 2008 at 9:49 pm
Many thanks
perfect
January 9th, 2009 at 10:45 pm
Thank you very much for sharing this time-saving hint.
June 8th, 2009 at 4:48 am
I had exactly the same issue trying to run phpPgadmin!! Thanks for this, it works like a champ while retaining the correct slack package configuration.
October 17th, 2009 at 12:53 am
Azmeen, THAAAANK YOU!! After all the problems I met and solved installing Postgresql I was stuck because the PHP installed in my Plesk box was compiled … without Postgresql support and I didn’t want to install PHP from scratch risking to compromise the whole box. So I can confirm your solution works also on CentOS.
Thank you again, now I can conclude my day with a smile upon my face.
Nik
October 17th, 2009 at 3:00 am
No problem Nik. Glad the article helped you
January 30th, 2010 at 8:17 am
Thanks, from Brazil.
Nice tip!
September 30th, 2011 at 10:35 am
[...] Source : http://www.heritage-tech.net/165/getting-additional-php-modules-without-totally-recompiling/ [...]