Thread: Trying to use PGSql with PHP
I'm trying to setup PostgreSQL on Redhat Linux 6.2 and access it with PHP. I have Apache installed and working, PHP installed and working, and PostgreSQL installed and working. However, I'm trying to get PHP to talk to the PostgreSQL system. I believe I need to install php-pgsql-3.0.15-2.rpm, but when I try, I get an error saying the that package depends on 'libpq.so.2.0'. I have PostgreSQL v7.0.2 (all of the RPMS's) and PHP 3.0.15 installed. What am I missing? I'm a bit of a newbie with Linux, so any help will be grateful! Thanks, -------------------------------- John Tsombakos johnts@ziplink.net <*>
one thing you could try is to compile php. I've found in the past that even thoughthe rmp version of php is great, most of the time it doesn't work. ----- Original Message ----- From: "John Tsombakos" <johnts@ziplink.net> To: <pgsql-general@postgresql.org> Sent: Saturday, October 07, 2000 10:20 PM Subject: [GENERAL] Trying to use PGSql with PHP > I'm trying to setup PostgreSQL on Redhat Linux 6.2 and access it with PHP. I > have Apache installed and working, PHP installed and working, and PostgreSQL > installed and working. However, I'm trying to get PHP to talk to the > PostgreSQL system. I believe I need to install php-pgsql-3.0.15-2.rpm, but > when I try, I get an error saying the that package depends on > 'libpq.so.2.0'. I have PostgreSQL v7.0.2 (all of the RPMS's) and PHP 3.0.15 > installed. > > What am I missing? I'm a bit of a newbie with Linux, so any help will be > grateful! > > Thanks, > -------------------------------- > John Tsombakos > johnts@ziplink.net <*> >
on 10/8/00 2:56 AM, Frank Joerdens at frank@joerdens.de wrote: > How did you install PHP & Apache? Did you configure & compile the > sources or get the rpm's from somewhere? If you're compiling PHP from > the sources, you need to configure PHP with the --with-pgsql switch. You > can check whether this is the problem (i.e. missing pgsql support) by > making a page that just contains <? phpinfo(); ?> which, if opened in a > browser, should show all the options your PHP supports. > > Also, in the Support section of the PHP homepage at www.php.net, you can > subscribe to a list that is devoted entirely to PHP installation issues. > > Regards, Frank > > On Sun, Oct 08, 2000 at 01:20:21AM -0400, John Tsombakos wrote: >> I'm trying to setup PostgreSQL on Redhat Linux 6.2 and access it with PHP. I >> have Apache installed and working, PHP installed and working, and PostgreSQL >> installed and working. However, I'm trying to get PHP to talk to the >> PostgreSQL system. I believe I need to install php-pgsql-3.0.15-2.rpm, but >> when I try, I get an error saying the that package depends on >> 'libpq.so.2.0'. I have PostgreSQL v7.0.2 (all of the RPMS's) and PHP 3.0.15 >> installed. >> >> What am I missing? I'm a bit of a newbie with Linux, so any help will be >> grateful! >> >> Thanks, >> -------------------------------- >> John Tsombakos >> johnts@ziplink.net <*> No, I installed PostgreSQL and PHP with the RPM's, and I believe Apache was already installed when I installed Redhat. Please note that PHP _does_ work. I can use PHP commands and it works fine. It's just when I try to use the PostgreSQL commands, I get an error. For example, if I do something like: <?php $connection=ph_connect("dbname=testdb") ?> I get an error: "Fatal error: Call to unsupported or undefined function pg_connect in /home/httpd/html/mypage.php on line 10" So, PHP works, Apache works, PSQL works by itself, it's just PHP and PSql don't work and I can't get what I assume is the "missing link" (php-pgsql-3.0.15-2.rpm) to install. -------------------------------- John Tsombakos johnts@ziplink.net <*>
On Sun, Oct 08, 2000 at 12:07:00PM -0400, John Tsombakos wrote: > on 10/8/00 2:56 AM, Frank Joerdens at frank@joerdens.de wrote: > > No, I installed PostgreSQL and PHP with the RPM's, and I believe Apache was > already installed when I installed Redhat. > > Please note that PHP _does_ work. I can use PHP commands and it works fine. > It's just when I try to use the PostgreSQL commands, I get an error. > > For example, if I do something like: > > <?php > $connection=ph_connect("dbname=testdb") > ?> > > I get an error: "Fatal error: Call to unsupported or undefined function > pg_connect in /home/httpd/html/mypage.php on line 10" > > So, PHP works, Apache works, PSQL works by itself, it's just PHP and PSql > don't work and I can't get what I assume is the "missing link" > (php-pgsql-3.0.15-2.rpm) to install. ...I don't like Red Hat for this reason--it usually doesn't give you much information about problems... For a production machine, I typically build and install my entire "mission-critical" chain of apps. Postgres, PHP, Apache, etc. This helps avoid a few problems: Red Hat may suddenly upgrade to a newly incompatible version, or may just change a configuration. At a guess, I would say that you are probably missing an .rpm for the postgres-client or pgsql-client, but that is based on my view dealings with Red Hat. -- Adam Haberlach | A billion hours ago, human life appeared on adam@newsnipple.com | earth. A billion minutes ago, Christianity http://www.newsnipple.com | emerged. A billion Coca-Colas ago was '88 EX500 | yesterday morning. -1996 Coca-Cola Ann. Rpt.
> For a production machine, I typically build and install my entire > "mission-critical" chain of apps. Postgres, PHP, Apache, etc. This helps > avoid a few problems: Red Hat may suddenly upgrade to a newly incompatible > version, or may just change a configuration. I agree. I'd also compile PHP as a module, rather than rolling it into the Apache binary. If you find that you, for instance, forgot xml support, or decide that you suddenly need it, you can just reconfigure and compile PHP. This is significantly less painful than having to recompile apache as well. The performance penalty you incur there is negligible (some people seem to confuse that with compiling PHP as a cgi binary - this is not recommended and will be much slower). > > At a guess, I would say that you are probably missing an .rpm for the > postgres-client or pgsql-client, but that is based on my view dealings with > Red Hat. Yep. That's what it sounds like.
on 10/8/00 1:32 PM, Frank Joerdens at frank@joerdens.de wrote: >> At a guess, I would say that you are probably missing an .rpm for the >> postgres-client or pgsql-client, but that is based on my view dealings with >> Red Hat. > > Yep. That's what it sounds like. I had downloaded and installed all of the RPM's for PostgreSQL. Unless I missed one for PHP, which I could not find, beyond the php-pgsql-3.0.15-2.rpm one (which won't install). -------------------------------- John Tsombakos johnts@ziplink.net <*>
The PHP RPM you installed wasn't built with PostGres support, and you can't add it in without recompiling PHP. I'd grab the source for PHP (probably version 4.02, I've been playing with it and it seems pretty stable) and recompile it yourself via the instructions. It should just be a matter of: ./configure --with=pgsql=/usr/local/pgsql --with-apxs=/usr/local/apache/bin/apxs --without-mysql make make install but you can read the INSTALL file and the output from ./configure --help for more details. At 03:26 PM 10/8/00, Adam Haberlach wrote: >On Sun, Oct 08, 2000 at 12:07:00PM -0400, John Tsombakos wrote: > > on 10/8/00 2:56 AM, Frank Joerdens at frank@joerdens.de wrote: > > > > No, I installed PostgreSQL and PHP with the RPM's, and I believe Apache was > > already installed when I installed Redhat. > > > > Please note that PHP _does_ work. I can use PHP commands and it works fine. > > It's just when I try to use the PostgreSQL commands, I get an error. > > > > For example, if I do something like: > > > > <?php > > $connection=ph_connect("dbname=testdb") > > ?> > > > > I get an error: "Fatal error: Call to unsupported or undefined function > > pg_connect in /home/httpd/html/mypage.php on line 10" > > > > So, PHP works, Apache works, PSQL works by itself, it's just PHP and PSql > > don't work and I can't get what I assume is the "missing link" > > (php-pgsql-3.0.15-2.rpm) to install. > >...I don't like Red Hat for this reason--it usually doesn't give you much >information about problems... > >For a production machine, I typically build and install my entire >"mission-critical" chain of apps. Postgres, PHP, Apache, etc. This helps >avoid a few problems: Red Hat may suddenly upgrade to a newly incompatible >version, or may just change a configuration. > >At a guess, I would say that you are probably missing an .rpm for the >postgres-client or pgsql-client, but that is based on my view dealings with >Red Hat. > >-- >Adam Haberlach | A billion hours ago, human life appeared on >adam@newsnipple.com | earth. A billion minutes ago, Christianity >http://www.newsnipple.com | emerged. A billion Coca-Colas ago was >'88 EX500 | yesterday morning. -1996 Coca-Cola Ann. Rpt.
I found this page: http://fsr.ku.dk/people/troels/rpms/php/ that has precompiled rpm's for PHP 4. I downloaded the RPM for PHP and the PHP-PostgreSQL link and installed the files. And they worked! No need to recompile anything! Thanks anyway to everyone. -------------------------------- John Tsombakos johnts@ziplink.net <*>
Odds are what your problem is mitch-matched support. the rpm version of php you are using is probably for postgres 6.5.x. Between that and version 7, there was a library upgrade and the rpm dependencies are out of wack (rpms tend not to be very "forward compatable" in many instances that I've encountered). In a nutshell, I had the same problem... What did I do? I un rpm'd Apache, PHP, and postgres. I had to recompile them from their source so they find all the updated libraruies you are using. Unfortunately, that sucks. Compiling Apache and PHP is a bit tricky because you have to compile Apache... then compile php ... then go back and compile part of apache again... etc. Compiling the postgres isn't that bad... only have issues with the man pages... never got that to work past the "make". php.net has pretty decent documentation on how to compile php and apache though. Adam Lang Systems Engineer Rutgers Casualty Insurance Company ----- Original Message ----- From: "John Tsombakos" <johnts@ziplink.net> To: <pgsql-general@postgresql.org> Sent: Sunday, October 08, 2000 1:20 AM Subject: [GENERAL] Trying to use PGSql with PHP > I'm trying to setup PostgreSQL on Redhat Linux 6.2 and access it with PHP. I > have Apache installed and working, PHP installed and working, and PostgreSQL > installed and working. However, I'm trying to get PHP to talk to the > PostgreSQL system. I believe I need to install php-pgsql-3.0.15-2.rpm, but > when I try, I get an error saying the that package depends on > 'libpq.so.2.0'. I have PostgreSQL v7.0.2 (all of the RPMS's) and PHP 3.0.15 > installed. > > What am I missing? I'm a bit of a newbie with Linux, so any help will be > grateful! > > Thanks, > -------------------------------- > John Tsombakos > johnts@ziplink.net <*>
How did you install PHP & Apache? Did you configure & compile the sources or get the rpm's from somewhere? If you're compiling PHP from the sources, you need to configure PHP with the --with-pgsql switch. You can check whether this is the problem (i.e. missing pgsql support) by making a page that just contains <? phpinfo(); ?> which, if opened in a browser, should show all the options your PHP supports. Also, in the Support section of the PHP homepage at www.php.net, you can subscribe to a list that is devoted entirely to PHP installation issues. Regards, Frank On Sun, Oct 08, 2000 at 01:20:21AM -0400, John Tsombakos wrote: > I'm trying to setup PostgreSQL on Redhat Linux 6.2 and access it with PHP. I > have Apache installed and working, PHP installed and working, and PostgreSQL > installed and working. However, I'm trying to get PHP to talk to the > PostgreSQL system. I believe I need to install php-pgsql-3.0.15-2.rpm, but > when I try, I get an error saying the that package depends on > 'libpq.so.2.0'. I have PostgreSQL v7.0.2 (all of the RPMS's) and PHP 3.0.15 > installed. > > What am I missing? I'm a bit of a newbie with Linux, so any help will be > grateful! > > Thanks, > -------------------------------- > John Tsombakos > johnts@ziplink.net <*> -- frank joerdens joerdens new media urbanstr. 116 10967 berlin germany e: frank@joerdens.de t: +49 (0)30 69597650 f: +49 (0)30 7864046 h: http://www.joerdens.de pgp public key: http://www.joerdens.de/pgp/frank_joerdens.asc