title: PHP fails to create connection to mongoDB
body: <p>I try to figure out why PHP  driver can't connect to mongoDB</p>
  
  <ul>
  <li>PHP Version 5.3.16 (64bit)</li>
  <li>MongoDB:    mongodb-linux-x86_64-2.4.3</li>
  <li><p>OS: CentOS  release 5.2 (Final)</p></li>
  <li><p>Added link: <code>mongo -&gt; mongodb-linux-i686-2.4.3</code></p></li>
  <li><p>Created <code>data</code> folder: <code>mkdir /home/max/mongo/data</code></p></li>
  <li><p>initiated mongo: </p></li>
  </ul>
  
  <blockquote>
    <p>mongo/bin/mongod --dbpath=mongo/data --fork --logpath /var/wefi/logs/feederliteRC/mongodb.log</p>
  </blockquote>
  
  <p>All works fine and can connect with mongoVUE monitor tool. (from Windows7)</p>
  
  <p>Now, I try to connect to BongoDB from PHP:</p>
  
  <p>I installed driver for PHP:</p>
  
  <blockquote>
    <p>sudo pecl install mongo</p>
  </blockquote>
  
  <p>on: <code>php -i | grep mongo</code> I get:</p>
  
  <pre><code>mongo
  mongo.allow_empty_keys =&gt; 0 =&gt; 0
  mongo.chunk_size =&gt; 262144 =&gt; 262144
  mongo.cmd =&gt; $ =&gt; $
  mongo.default_host =&gt; localhost =&gt; localhost
  mongo.default_port =&gt; 27017 =&gt; 27017
  mongo.is_master_interval =&gt; 15 =&gt; 15
  mongo.long_as_object =&gt; 0 =&gt; 0
  mongo.native_long =&gt; 0 =&gt; 0
  mongo.ping_interval =&gt; 5 =&gt; 5
  OLDPWD =&gt; /usr/share/pear/doc/mongo
  _SERVER["OLDPWD"] =&gt; /usr/share/pear/doc/mongo
  </code></pre>
  
  <p>I added to <code>php.ini</code> (<code>nano /etc/php.ini</code>): <code>extension=mongo.so</code></p>
  
  <p>and restarted <code>httpd</code>: <code>/etc/init.d/httpd restart</code></p>
  
  <p>from code: </p>
  
  <pre><code> try {
          // open connection to MongoDB server
          $conn = new Mongo('localhost');
  } catch (MongoConnectionException $e) {            
          die('Error connecting to MongoDB server');
          } catch (MongoException $e) {           
          die('Error: ' . $e-&gt;getMessage());
      }
  </code></pre>
  
  <p>PHP sees <code>new Mongo</code> but I get exception: <code>"Error connecting to MongoDB server</code>.</p>
  
  <p>Strange, mongoDB runs, driver for PHP works but it doesn't see mongoDB.</p>
  
  <p>Can someone help me,</p>
  
  <p><strong>[EDIT]</strong></p>
  
  <blockquote>
    <p>"Error connecting to MongoDB server Failed to connect to: localhost:27017: Connection refused"</p>
  </blockquote>
  
  <p>Do I need add smoething to <code>php.ini</code>?</p>