PHP errors when running from shell

XML, Perl, Python, and other languages can be discussed here, even if it isn't PHP (We might forgive you).

Moderator: General Moderators

Post Reply
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

PHP errors when running from shell

Post 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!
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
User avatar
Ambush Commander
DevNet Master
Posts: 3698
Joined: Mon Oct 25, 2004 9:29 pm
Location: New Jersey, US

Post by Ambush Commander »

Yeah, the temporary fix is to comment off the extensions in Php.ini. Although those are some pretty important extensions.
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Post 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?
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
User avatar
Ambush Commander
DevNet Master
Posts: 3698
Joined: Mon Oct 25, 2004 9:29 pm
Location: New Jersey, US

Post 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).
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Post 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?
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post by timvw »

with "ldd /usr/bin/php" you can check which modules the php binary uses...
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Post 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?)
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
Post Reply