PHP Fatal error: Uncaught exception 'MongoConnectionException' with message 'Permission denied'

本人转载自http://www.michaeltozzo.com/blog/2010/02/19/mongodb-php-problem/

While at work I was looking into something that we could replace MySQL with since the two trends these days are to not do any JOINS between tables and to work with large datasets. I came across a database called MongoDB which was apparently very good at both of these things and used guides on the internet to get it going on a local Linux box.

I got to a point where it was almost working 100% but for some reason my simple test script couldn’t connect when run by Apache but could when run via command line. I would get the error:

PHP Fatal error: Uncaught exception 'MongoConnectionException' with message 'Permission denied'

I scoured the internet and found only a single reference to my problem but couldn’t find a solution. After direct emails with Kristina Chodorow the primary maintainer for the MongoDB Perl and PHP drivers I found that the solution to my problem was to run the command:

$ /usr/sbin/setsebool -P httpd_can_network_connect 1

Hopefully this helps someone else. Thanks again Kristina :D .

原文地址:https://www.cnblogs.com/google4y/p/2111809.html