Wednesday, December 14, 2011

Getting PostgreSQL 9.0.4 module for PHP-5.3.8 on Slackware 13.37

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.

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

Most of my googling results mention that the only solution is to recompile PHP from scratch, including the --with-pgsql flag. Hmm, I'm 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 /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 rootto activate PostgreSQL support in PHP.
Hope this helps other Slackers as well as Linux users in general.
 
In short
You need only the PHP pgsql.so module,  verify with pkgtool what's your PHP version, mine is 5.3.8 (Slackware 13.37). Download in /usr/local/src the PHP sources, I take them from php.net website using this link
http://www.php.net/get/php-5.3.8.tar.bz2/from/a/mirror
replacing the version number
http://www.php.net/get/.tar.bz2/from/a/mirror
Extract the compressed tarball, dive into the newly created directory and as article say type :
./configure --with-pgsql=shared,/usr
then
make
Now copy the module in the corrected directory
#cp -v modules/pgsql.so /usr/lib/php/extensions/
Open with an editor /etc/httpd/php.ini
extension=pgsql.so
#mcedit /etc/https/php.ini
and add this line
extension=pgsql.so
Restart apache
#/etc/rc.d/rc.httpd restart
Done

you can download my PostgreSQL 9.0.4 module for PHP-5.3.8 on Slackware 13.37 HERE

Referensi : Referensi 01 Referensi 02

6 comments:

jefnik said...

Did the same on Slackware 14.0, and the newly generated and copied pgsql.so module does not work. When I do php -m, it does not appear (although pdo_pgsql.so does). When I run a PHP app referencing pg_connect(), I get this:

PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php/extensions/pgsql.so' - /usr/lib/ph
p/extensions/pgsql.so: undefined symbol: executor_globals in Unknown on line 0

Any help would be appreciated.

jefnik said...

To clarify, php -m lists "pdo_pgsql" but not "pgsql". php -i lists:

PDO drivers => pgsql, sqlite

but says nothing else about pgsql.

diantokam said...

I don't have Slackware 14, i will download it today, and see if i can help you.

diantokam said...

Here the solution http://diantokam.blogspot.com/2012/10/solved-getting-postgresql-914-module.html

Anonymous said...

Got the same PHP Warning as jefnik mentioned.
I need pdo_pgsql.so to be installed on Slackware 14.
Is there any Slackbuild for this?

Any help would be welcome.

diantokam said...

Here's my PostgreSQL 9.1.4 modul

http://www.mediafire.com/download.php?e2wbaedagyv4xtb.

Or you can see my instruction that i gived to jefnik

http://diantokam.blogspot.com/2012/10/solved-getting-postgresql-914-module.html