pgsql.so is not loaded in PHP

Obay picture Obay · May 14, 2010 · Viewed 37.2k times · Source

I've been tasked to create a PHP app which accesses an existing PostgreSQL database. This is my first time working with Postgre, not to mention the PHP has already been installed in the Linux box on which the app is supposed to run. I have no experience setting up this stuff, I just code.

My question is that I can't seem to get the Postgre extension working in PHP. I checked the php.ini file, there were no "extension=..." lines. So I added "extension=pgsql.so". I then checked the "extension_dir" and found that there were only 2 files in there (ldap.so, phpcups.so), I added a pgsql.so file taken from another Linux box. I restarted httpd. And it does not work. I couldn't find any "pgsql" or "postgre" in phpinfo().

Forgive my noobness. I know too little Linux. I would really appreciate it if you can point me to the right direction.


I used the suggestion given by number5:

Dude, I'm on RedHat. I used the "yum" version of the command you gave, and I got this:

[root@perseus ~]# yum install php-pgsql Loading "installonlyn" plugin Setting up Install Process Setting up repositories Could not retrieve mirrorlist http://mirrorlist.centos.org/?release=5&arch=x86_64&repo=extras error was [Errno 4] IOError: Error: Cannot find a valid baseurl for repo: extras


UNFORTUNATELY, the Linux server I'm using is NOT connected to the Internet. Any other way to install?

Answer

number5 picture number5 · May 14, 2010

It depends on which Linux distro you are using.

If you are using Ubuntu/Debian, you need to:

sudo apt-get install php5-pgsql

Fedora/CentOS

yum install php-pgsql

usually you can find out which distro you are on by:

ls /etc/*-release