Thread: apache perl cgi script cant load libpq.5.dylib on mac os tiger

apache perl cgi script cant load libpq.5.dylib on mac os tiger

From
Fergus McMenemie
Date:
I have a perl cgi script that wont run on a new mac.  The script runs fine
from the command line, so the perl and postgresql seem good. However
when run as an apache cgi script the postgresql stuff fails as shown
below.  I altered the script to dump %ENV and the paths seem in order.

The script is not using mod perl. It is using the apple os x 10.4.11 supplied
version of apache, postgresql-8.3.0  and perl, v5.8.8 with DBD::Pg, DBI and
JSON installed.

I am at a total loss as to why the library cant be found and would be
very grateful for any help.

Content-type: text/html Software error:

install_driver(Pg) failed:
   Can't load '/usr/local/lib/perl5/site_perl/5.8.8/darwin-2level/auto/DBD/Pg/Pg.bundle'
  for module DBD::Pg: dlopen(/usr/local/lib/perl5/site_perl/5.8.8/darwin-2level/auto/DBD/Pg/Pg.bundle, 1):
  Library not loaded: /usr/local/pgsql/lib/libpq.5.dylib
  Referenced from: /usr/local/lib/perl5/site_perl/5.8.8/darwin-2level/auto/DBD/Pg/Pg.bundle
  Reason: image not found at /usr/local/lib/perl5/5.8.8/darwin-2level/DynaLoader.pm line 230.
 at (eval 45) line 3
  Compilation failed in require at (eval 45) line 3.
Perhaps a required shared library or dll isn't installed where expected at /Library/WebServer/cgi-bin/pgcgi.pl line 383

     $ENV{AUTH_TYPE} = Basic
     $ENV{DOCUMENT_ROOT} = /Library/WebServer/Documents
     $ENV{DYLD_LIBRARY_PATH} = /usr/local/pgsql/lib:/usr/lib:/usr/local/lib
     $ENV{GATEWAY_INTERFACE} = CGI/1.1
     $ENV{HTTPS} = on
     $ENV{HTTP_ACCEPT} =
text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,/;q=0.5
     $ENV{HTTP_ACCEPT_CHARSET} = ISO-8859-1,utf-8;q=0.7,;q=0.7
     $ENV{HTTP_ACCEPT_ENCODING} = gzip,deflate
     $ENV{HTTP_ACCEPT_LANGUAGE} = en,en-us;q=0.5
     $ENV{HTTP_CONNECTION} = keep-alive
     $ENV{HTTP_HOST} = XXXXX.co.uk
     $ENV{HTTP_KEEP_ALIVE} = 300
     $ENV{HTTP_USER_AGENT} = Mozilla/5.0 (Macintosh; U; PPC Mac OS X Mach-O; en-US; rv:1.8.1.14) Gecko/20080404
Firefox/2.0.0.14
     $ENV{LD_LIBRARY_PATH} = /usr/local/pgsql/lib:/usr/lib:/usr/local/lib
     $ENV{PATH} = /usr/local/pgsql/bin:/usr/local/bin:/bin:/sbin:/usr/bin:/usr/sbin
     $ENV{QUERY_STRING} =
     $ENV{REMOTE_ADDR} = XXXXXX
     $ENV{REMOTE_PORT} = 53698
     $ENV{REMOTE_USER} = fergus
     $ENV{REQUEST_METHOD} = GET
     $ENV{REQUEST_URI} = /cgi-bin/pgcgi.pl
     $ENV{SCRIPT_FILENAME} = /Library/WebServer/cgi-bin/pgcgi.pl
     $ENV{SCRIPT_NAME} = /cgi-bin/pgcgi.pl
     $ENV{SERVER_ADDR} = XXXX
     $ENV{SERVER_ADMIN} = fergus@XXXXX
     $ENV{SERVER_NAME} = XXXXX.co.uk
     $ENV{SERVER_PORT} = 443
     $ENV{SERVER_PROTOCOL} = HTTP/1.1
     $ENV{SERVER_SIGNATURE} =  Apache/1.3.41 Server at XXXX.co.uk Port 443
     $ENV{SERVER_SOFTWARE} = Apache/1.3.41 (Darwin) mod_ssl/2.8.31 OpenSSL/0.9.7l

--

===============================================================
Fergus McMenemie               Email:fergus@twig.me.uk
Techmore Ltd                   Phone:(UK) 07721 376021

Unix/Mac/Intranets             Analyst Programmer
===============================================================

Hmmm,

It was the protection on the /usr/local/pgsql directory. Solved, by myself
an hour after making this post. Odd that, its been bugging the heck out of
me for over a week now, and then one hour after posting....



At 16:05 +0100 23/5/08, Fergus McMenemie wrote:
>I have a perl cgi script that wont run on a new mac.  The script runs fine
>from the command line, so the perl and postgresql seem good. However
>when run as an apache cgi script the postgresql stuff fails as shown
>below.  I altered the script to dump %ENV and the paths seem in order.
>
>The script is not using mod perl. It is using the apple os x 10.4.11 supplied
>version of apache, postgresql-8.3.0  and perl, v5.8.8 with DBD::Pg, DBI and
>JSON installed.
>
>I am at a total loss as to why the library cant be found and would be
>very grateful for any help.
>
>Content-type: text/html Software error:
>
>install_driver(Pg) failed:
>   Can't load '/usr/local/lib/perl5/site_perl/5.8.8/darwin-2level/auto/DBD/Pg/Pg.bundle'
>  for module DBD::Pg: dlopen(/usr/local/lib/perl5/site_perl/5.8.8/darwin-2level/auto/DBD/Pg/Pg.bundle, 1):
>  Library not loaded: /usr/local/pgsql/lib/libpq.5.dylib
>  Referenced from: /usr/local/lib/perl5/site_perl/5.8.8/darwin-2level/auto/DBD/Pg/Pg.bundle
>  Reason: image not found at /usr/local/lib/perl5/5.8.8/darwin-2level/DynaLoader.pm line 230.
> at (eval 45) line 3
>  Compilation failed in require at (eval 45) line 3.
>Perhaps a required shared library or dll isn't installed where expected at /Library/WebServer/cgi-bin/pgcgi.pl line
383
>
>     $ENV{AUTH_TYPE} = Basic
>     $ENV{DOCUMENT_ROOT} = /Library/WebServer/Documents
>     $ENV{DYLD_LIBRARY_PATH} = /usr/local/pgsql/lib:/usr/lib:/usr/local/lib
>     $ENV{GATEWAY_INTERFACE} = CGI/1.1
>     $ENV{HTTPS} = on
>     $ENV{HTTP_ACCEPT} =
text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,/;q=0.5
>     $ENV{HTTP_ACCEPT_CHARSET} = ISO-8859-1,utf-8;q=0.7,;q=0.7
>     $ENV{HTTP_ACCEPT_ENCODING} = gzip,deflate
>     $ENV{HTTP_ACCEPT_LANGUAGE} = en,en-us;q=0.5
>     $ENV{HTTP_CONNECTION} = keep-alive
>     $ENV{HTTP_HOST} = XXXXX.co.uk
>     $ENV{HTTP_KEEP_ALIVE} = 300
>     $ENV{HTTP_USER_AGENT} = Mozilla/5.0 (Macintosh; U; PPC Mac OS X Mach-O; en-US; rv:1.8.1.14) Gecko/20080404
Firefox/2.0.0.14
>     $ENV{LD_LIBRARY_PATH} = /usr/local/pgsql/lib:/usr/lib:/usr/local/lib
>     $ENV{PATH} = /usr/local/pgsql/bin:/usr/local/bin:/bin:/sbin:/usr/bin:/usr/sbin
>     $ENV{QUERY_STRING} =
>     $ENV{REMOTE_ADDR} = XXXXXX
>     $ENV{REMOTE_PORT} = 53698
>     $ENV{REMOTE_USER} = fergus
>     $ENV{REQUEST_METHOD} = GET
>     $ENV{REQUEST_URI} = /cgi-bin/pgcgi.pl
>     $ENV{SCRIPT_FILENAME} = /Library/WebServer/cgi-bin/pgcgi.pl
>     $ENV{SCRIPT_NAME} = /cgi-bin/pgcgi.pl
>     $ENV{SERVER_ADDR} = XXXX
>     $ENV{SERVER_ADMIN} = fergus@XXXXX
>     $ENV{SERVER_NAME} = XXXXX.co.uk
>     $ENV{SERVER_PORT} = 443
>     $ENV{SERVER_PROTOCOL} = HTTP/1.1
>     $ENV{SERVER_SIGNATURE} =  Apache/1.3.41 Server at XXXX.co.uk Port 443
>     $ENV{SERVER_SOFTWARE} = Apache/1.3.41 (Darwin) mod_ssl/2.8.31 OpenSSL/0.9.7l
>
>--
>
>===============================================================
>Fergus McMenemie               Email:fergus@twig.me.uk
>Techmore Ltd                   Phone:(UK) 07721 376021
>
>Unix/Mac/Intranets             Analyst Programmer
>===============================================================
>
>--
>Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
>To make changes to your subscription:
>http://www.postgresql.org/mailpref/pgsql-general

--

===============================================================
Fergus McMenemie               Email:fergus@twig.me.uk
Techmore Ltd                   Phone:(UK) 07721 376021

Unix/Mac/Intranets             Analyst Programmer
===============================================================

I found a similar problem only with a slight variation.

postgresql, for me, is installed in /opt/local/ with the particular file
being located at:
/opt/local/lib/postgresql83/libpq.5.dylib

This is all a part of the mac ports installation for apache2 and postgres.

It seems that the problem isn't so much pgsql but apache2 and/or mac
ports.  But would you (or anyone else) have a suggestion on how to
proceed?  I could probably just make a lot of soft links, but that
doesn't seem very robust.

Fergus McMenemie wrote:
> Hmmm,
>
> It was the protection on the /usr/local/pgsql directory. Solved, by myself
> an hour after making this post. Odd that, its been bugging the heck out of
> me for over a week now, and then one hour after posting....
>
>
>
> At 16:05 +0100 23/5/08, Fergus McMenemie wrote:
>> I have a perl cgi script that wont run on a new mac.  The script runs fine
>>from the command line, so the perl and postgresql seem good. However
>> when run as an apache cgi script the postgresql stuff fails as shown
>> below.  I altered the script to dump %ENV and the paths seem in order.
>>
>> The script is not using mod perl. It is using the apple os x 10.4.11 supplied
>> version of apache, postgresql-8.3.0  and perl, v5.8.8 with DBD::Pg, DBI and
>> JSON installed.
>>
>> I am at a total loss as to why the library cant be found and would be
>> very grateful for any help.
>>
>> Content-type: text/html Software error:
>>
>> install_driver(Pg) failed:
>>   Can't load '/usr/local/lib/perl5/site_perl/5.8.8/darwin-2level/auto/DBD/Pg/Pg.bundle'
>>  for module DBD::Pg: dlopen(/usr/local/lib/perl5/site_perl/5.8.8/darwin-2level/auto/DBD/Pg/Pg.bundle, 1):
>>  Library not loaded: /usr/local/pgsql/lib/libpq.5.dylib
>>  Referenced from: /usr/local/lib/perl5/site_perl/5.8.8/darwin-2level/auto/DBD/Pg/Pg.bundle
>>  Reason: image not found at /usr/local/lib/perl5/5.8.8/darwin-2level/DynaLoader.pm line 230.
>> at (eval 45) line 3
>>  Compilation failed in require at (eval 45) line 3.
>> Perhaps a required shared library or dll isn't installed where expected at /Library/WebServer/cgi-bin/pgcgi.pl line
383
>>
>>     $ENV{AUTH_TYPE} = Basic
>>     $ENV{DOCUMENT_ROOT} = /Library/WebServer/Documents
>>     $ENV{DYLD_LIBRARY_PATH} = /usr/local/pgsql/lib:/usr/lib:/usr/local/lib
>>     $ENV{GATEWAY_INTERFACE} = CGI/1.1
>>     $ENV{HTTPS} = on
>>     $ENV{HTTP_ACCEPT} =
text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,/;q=0.5
>>     $ENV{HTTP_ACCEPT_CHARSET} = ISO-8859-1,utf-8;q=0.7,;q=0.7
>>     $ENV{HTTP_ACCEPT_ENCODING} = gzip,deflate
>>     $ENV{HTTP_ACCEPT_LANGUAGE} = en,en-us;q=0.5
>>     $ENV{HTTP_CONNECTION} = keep-alive
>>     $ENV{HTTP_HOST} = XXXXX.co.uk
>>     $ENV{HTTP_KEEP_ALIVE} = 300
>>     $ENV{HTTP_USER_AGENT} = Mozilla/5.0 (Macintosh; U; PPC Mac OS X Mach-O; en-US; rv:1.8.1.14) Gecko/20080404
Firefox/2.0.0.14
>>     $ENV{LD_LIBRARY_PATH} = /usr/local/pgsql/lib:/usr/lib:/usr/local/lib
>>     $ENV{PATH} = /usr/local/pgsql/bin:/usr/local/bin:/bin:/sbin:/usr/bin:/usr/sbin
>>     $ENV{QUERY_STRING} =
>>     $ENV{REMOTE_ADDR} = XXXXXX
>>     $ENV{REMOTE_PORT} = 53698
>>     $ENV{REMOTE_USER} = fergus
>>     $ENV{REQUEST_METHOD} = GET
>>     $ENV{REQUEST_URI} = /cgi-bin/pgcgi.pl
>>     $ENV{SCRIPT_FILENAME} = /Library/WebServer/cgi-bin/pgcgi.pl
>>     $ENV{SCRIPT_NAME} = /cgi-bin/pgcgi.pl
>>     $ENV{SERVER_ADDR} = XXXX
>>     $ENV{SERVER_ADMIN} = fergus@XXXXX
>>     $ENV{SERVER_NAME} = XXXXX.co.uk
>>     $ENV{SERVER_PORT} = 443
>>     $ENV{SERVER_PROTOCOL} = HTTP/1.1
>>     $ENV{SERVER_SIGNATURE} =  Apache/1.3.41 Server at XXXX.co.uk Port 443
>>     $ENV{SERVER_SOFTWARE} = Apache/1.3.41 (Darwin) mod_ssl/2.8.31 OpenSSL/0.9.7l
>>
>> --
>>
>> ===============================================================
>> Fergus McMenemie               Email:fergus@twig.me.uk
>> Techmore Ltd                   Phone:(UK) 07721 376021
>>
>> Unix/Mac/Intranets             Analyst Programmer
>> ===============================================================
>>
>> --
>> Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
>> To make changes to your subscription:
>> http://www.postgresql.org/mailpref/pgsql-general
>