2

I've just installed PHP 5.5 and I am no longer able to use MongoClient and I'm getting frustrated trying to figure out why.

This doesn't work:

$m = new MongoClient("mongodb://workplz.com");

My nginx error log shows:

2013/07/05 10:40:16 [error] 4163#0: *698 FastCGI sent in stderr: "PHP message: PHP Fatal error: Class 'MongoClient' not found in /blah/test.php on line 2" while reading response header from upstream, client: 123.123.123.123, server: blah, request: "GET /test.php HTTP/1.1", upstream: "fastcgi://unix:/var/lib/php5-fpm/freecookies.sock:", host: "blah"

I do have extension=mongo.so in my php.ini.

When I do phpinfo() it shows under Mongo Version 1.4.1

Extra info:

  • PHP Version 5.5.0-1ubuntu2~precise1
  • nginx/1.4.1

Edit

When I try to execute it from php-cli I get the same thing:

PHP Fatal error: Class 'MongoClient' not found in /blah/test.php on line 2

6
  • 1
    Sure you're executing the same PHP version using the same php.ini in both cases? Commented Jul 5, 2013 at 15:15
  • 1
    I think php-fpm has it's own php.ini - perhaps try running from CLI? (pretty much what he said ^^) Commented Jul 5, 2013 at 15:18
  • I'm pretty sure the same php.ini is being used in both cases. When I try to run it from the CLI I get the same thing PHP Fatal error: Class 'MongoClient' not found in /blah/test.php on line 2 Commented Jul 5, 2013 at 15:24
  • 1
    Looks like you were right. I checked my CLI and discovered the mongo driver wasn't being loaded there either. Added it to the CLI php.ini and it started working. Commented Jul 5, 2013 at 15:44
  • @deceze post as answer and take credit? Commented Jul 5, 2013 at 15:46

1 Answer 1

2

Double check your php.ini, you're probably using the wrong one. There are several for different ways to invoke PHP.

Sign up to request clarification or add additional context in comments.

1 Comment

Thank you deceze and Paul for your help!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.