Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have tried to run my script via cron, but it was not working...

*/1 * * * * /usr/local/bin/php -f /usr/local/www/maintain.php > /usr/local/www/php.log

So I decided to try to run this script from the command line in putty like this:

/usr/local/bin/php -f /usr/local/www/maintain.php > /usr/local/www/php.log

And then I've received the following warning/error message:

# /usr/local/bin/php /usr/local/www/maintain.php > /usr/local/www/php.log
PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/local/lib/php/20090626/' - Cannot open "/usr/local/lib/php/20090626/" in Unknown on line 0

But this script is running great, when I'm running it via www like

I'm using PHP 5~ with Lighttpd running od FreeBSD. Where is my problem?

share|improve this question
Does /usr/local/lib/php/20090626/ exist? Are you sure it's running from lighttpd and you don't just have error display off? – Andy Feb 23 '12 at 16:07
It does exist, but in /usr/local/lib/ – Cyclone Feb 23 '12 at 16:18
When I create a symlink in /usr/local/lib/php/20090626/ it does print another message: PHP Warning: PHP Startup: Invalid library (maybe not a PHP library) '' in Unknown on line 0 – Cyclone Feb 23 '12 at 16:23
Nothing more than the file is required, try copying it instead. Alternatively update the reference in the file in /etc/php.d/X.ini, or it may be in your master php.ini – Andy Feb 23 '12 at 17:04
Look for grep -r libpcre /usr/local/etc/php* and remove it. – SaveTheRbtz Feb 24 '12 at 18:20
up vote 2 down vote accepted

Run this command (replacing /usr/bin/php with the path you're using to the PHP binary, in this case, /usr/local/bin/php):

# ldd /usr/bin/php =>  (0x00932000) => /lib/ (0x00f16000) => /usr/lib/ (0x008dd000) => /lib/ (0x00791000) => /usr/lib/sse2/ (0x00de8000)

It allows you see precisely what shared libraries the binary depends on. I had this problem a while back with some cryptographic PHP library. The errors from PHP provided no useful information about why the script wasn't running, until I ran this command and could see what was missing. Whilst the error you are seeing complains about one specific library, there is a good chance that library depends on yet another one, which PHP is not telling you about in the error. ldd gives you this vital missing information.

Note I am running CentOS Linux here. For BSD, the ldd command might be called something else (I have never used BSD so can't comment on that).

share|improve this answer

/usr/local/lib/ is the C library.

Did you compile php yourself or from ports?

It looks like it was compiled with a custom PCRE library, because normally php should include pcre support.

share|improve this answer
From ports, php does include this library by default, while using lighttpd everything is fine, but when I run a PHP script from a command line, it throws this error... – Cyclone Feb 28 '12 at 8:26
Shouldnt it be a comment? – Cyclone Feb 28 '12 at 9:15
yes, but on that day i didn't have the privilege to add comments :). lighttpd uses php-cgi, since you are not reading any variables, you might try to use php-cgi from the commandline – arved Feb 28 '12 at 9:40
I already did :/. Throws the same as normal php. – Cyclone Feb 28 '12 at 9:45
FreeBSD ports don't install a php.ini per default. Some examples are installed as /usr/local/etc/php.ini-development and -production. Do you by chance have the php5-pcre port installed? it was deleted when php was updated to 5.3.2. See /usr/ports/UPDATING 20100409 entry – arved Feb 28 '12 at 13:21

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.