pgsql.so is not loaded in PHP
Asked Answered
T

4

9

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?

Tungsten answered 14/5, 2010 at 7:35 Comment(2)
That looks like a question for ServerFault.Tanah
hope you already solved your problem. If not, you can download the required rpms and install using rpm command. wget mirrors.gigenet.com/centos/5.4/os/x86_64/CentOS/… wget mirrors.gigenet.com/centos/5.4/os/x86_64/CentOS/… rpm -ivh *.rpm if it tells you that some deps are missing, you can find it here mirrors.gigenet.com/centos/5.4/os/x86_64/CentOS the download link is assuming that your CentOS is 5.4 x86_64Stockstill
S
10

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
Stockstill answered 14/5, 2010 at 7:51 Comment(1)
Dude I added some comments aboveTungsten
T
3

On CentOS extensions create separate *.ini file one per each php extension in /etc/php.d

So, don't alter main *.ini file, but create /etc/php.d/pgsql.ini and add there a line

extension=pgsql.so

Then you will need to restart Apache using

service httpd restart

But the best automated way is to just type

yum install php-pgsql

In your case that didn't work because of some problems in yum configuration. Go to /etc/yum-repos.d Type

nano /etc/yum.repos.d/CentOS-Base.repo

Scroll down to [extras] section and ensure it is like this:

#additional packages that may be useful
[extras]
priority=1
name=CentOS-$releasever - Extras
=extras
#baseurl=http://mirror.centos.org/centos/$releasever/extras/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5

Correct it if needed, save file (Ctrl-X) and do the following:

yum clean all
yum upgrade

Afterwards try to repeat

yum install php-pgsql
Tanah answered 14/5, 2010 at 8:21 Comment(2)
it says: Config Error: File contains parsing errors: file://///etc/yum.repos.d/CentOS-Base.repo [line 41]: '=extras\n'Tungsten
Who says? What's your CentOS version? May be, you should remove "priority" string?Tanah
C
1
  • Remove the .so file you've copied from the other machine (though it might work, there's no need to take the risk)
  • Use the distribution's package manager to install the php_pgsql/php5_pqsql module
  • Restart the apache and try again. Maybe the module has been added to an .ini file automagically
  • If not, run <?php echo 'ini: ', get_cfg_var('cfg_file_path'); to see which php.ini you have to edit
  • edit this ini file
  • restart the apache
Chainey answered 14/5, 2010 at 7:52 Comment(0)
I
-1

My operation system Linux mint kde and there was same issue

pg_connect()

You must install if you are use php5.6

sudo apt-get install php5.6-pgsql

After you must change extention name in "php.ini" file.

;extension=php_pgsql.dll

'dll' to 'so'

For example

extension=php_pgsql.so
Iggy answered 13/1, 2017 at 17:44 Comment(1)
This seems like a different issue. For a start, the OP already had that config line exactly as written.Granvillegranvillebarker

© 2022 - 2024 — McMap. All rights reserved.