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 .

posted @ 2011-07-20 16:35  google4y  阅读(919)  评论(0编辑  收藏  举报
不在家,就在公司,不在公司,就在去公司的路上,無家無根,如風如萍,只有漂