Page 1 of 1

PHP errors when running from shell

Posted: Wed Jun 01, 2005 3:38 pm
by pickle
Hi all,

I get the following errors when I run a PHP file from the command line.

Code: Select all

$ ./migrate-cron.php

PHP Fatal error:  PDFlib error: Version mismatch in wrapper code in Unknown on line 0
PHP Warning:  Unknown(): Unable to load dynamic library './gd.so' - ./gd.so: cannot open shared object file: No such file or directory in Unknown on line 0
PHP Warning:  Unknown(): Unable to load dynamic library './imap.so' - ./imap.so: cannot open shared object file: No such file or directory in Unknown on line 0
PHP Warning:  Unknown(): Unable to load dynamic library './ldap.so' - ./ldap.so: cannot open shared object file: No such file or directory in Unknown on line 0
PHP Warning:  Unknown(): Unable to load dynamic library './mysql.so' - ./mysql.so: cannot open shared object file: No such file or directory in Unknown on line 0
PHP Warning:  Unknown(): Unable to load dynamic library './pgsql.so' - ./pgsql.so: cannot open shared object file: No such file or directory in Unknown on line 0
PHP Warning:  Unknown(): Unable to load dynamic library './readline.so' - ./readline.so: cannot open shared object file: No such file or directory in Unknown on line 0
The file executes just fine - it even uses mysql. All those extensions are located in the /usr/lib/php/extensions directory. How do I tell my command-line script where to look for them? Is it something with php.ini that I have to fix up (include_path maybe?)

Thanks!

Posted: Wed Jun 01, 2005 3:53 pm
by Ambush Commander
Yeah, the temporary fix is to comment off the extensions in Php.ini. Although those are some pretty important extensions.

Posted: Wed Jun 01, 2005 4:08 pm
by pickle
Well, my php.ini file doesn't load those extensions (I think) - the string 'gd.so' is nowhere to be found. I did find a variable called 'extension_dir' that was set to './'. I changed that to '/usr/lib/php/extensions/' and got a bunch more errors:

Code: Select all

PHP Warning:  Function registration failed - duplicate name - gd_info in Unknown on line 0
PHP Warning:  Function registration failed - duplicate name - imagearc in Unknown on line 0
....
and so on for every function in gd, ldap, and mysql.

I can run command line scripts on every other server where I work, and don't get any errors like this. However, those PHP installations don't have a php.ini file at all.

Any ideas?

Posted: Wed Jun 01, 2005 4:11 pm
by Ambush Commander
But have PHP ini files they do... Hmm...

I have a feeling you have another PHP ini file lying around and it's already doing the extension initialization, so what's happening is PHP is attempting to re-initialize it (thus the function failed registrations).

Posted: Wed Jun 01, 2005 4:47 pm
by pickle
That's what I thought too, but if there is another php.ini file, my server doesn't know where it is. This is what I get from calling 'locate' after running 'updatedb'

Code: Select all

# locate php.ini

/usr/share/doc/libphp_common430-430/php.ini-recommended
/usr/share/doc/libphp_common430-430/php.ini-dist
/home/anded/php-4.3.3/php.ini-dist
/home/anded/php-4.3.3/php.ini-recommended
/home/anded/php-4.3.3/pear/tests/php.ini
/etc/php.ini
/etc/php.ini~
I think you're right that those .so files are being referenced elsewhere because when I call the script from whithin the /usr/lib/php/extensions/ directory, I get those 'function registration failed' errors.

There are no extensions being loaded automatically using the extension=extension_name.so format. Could these extensions be called from anywhere else?

Posted: Wed Jun 01, 2005 5:01 pm
by timvw
with "ldd /usr/bin/php" you can check which modules the php binary uses...

Posted: Wed Jun 01, 2005 5:06 pm
by pickle
Using "ldd /usr/bin/php" I got the following output:

Code: Select all

libcrypt.so.1 => /lib/libcrypt.so.1 (0x40020000)
        libnsl.so.1 => /lib/libnsl.so.1 (0x4004d000)
        libpdf.so.2 => /usr/local/lib/libpdf.so.2 (0x40061000)
        libm.so.6 => /lib/i686/libm.so.6 (0x4011e000)
        libz.so.1 => /lib/libz.so.1 (0x40140000)
        libpng.so.3 => /usr/lib/libpng.so.3 (0x4014e000)
        libldap-2.2.so.7 => /usr/local/lib/libldap-2.2.so.7 (0x40173000)
        liblber-2.2.so.7 => /usr/local/lib/liblber-2.2.so.7 (0x4019f000)
        libintl.so.2 => /lib/libintl.so.2 (0x401ab000)
        libc.so.6 => /lib/i686/libc.so.6 (0x401b4000)
        libfreetype.so.6 => /usr/lib/libfreetype.so.6 (0x402e7000)
        libssl.so.0.9.7 => /usr/lib/libssl.so.0.9.7 (0x40335000)
        libcrypto.so.0.9.7 => /usr/lib/libcrypto.so.0.9.7 (0x40363000)
        libresolv.so.2 => /lib/libresolv.so.2 (0x40451000)
        libdl.so.2 => /lib/libdl.so.2 (0x40462000)
        /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x40000000)
Does this mean all those other .so files are loaded when PHP is loaded (as opposed to being compiled in?)