setup mongoDB-extension for php7
<p>I'm trying to install the mongoDB-extension for php7. I started with a brand new installation of Ubuntu-Server 16.04.1. Pre-installed (while OS-installation) packages were LAMP-extension, OpenSSL and MySQL-server. This was installed on a local VirtualBox. It shall to be a development system which is configured equal for every developer.</p>

<p>First I installed MongoDB itself according to these instructions: <a href="https://www.digitalocean.com/community/tutorials/how-to-install-mongodb-on-ubuntu-16-04" rel="noreferrer">install mongoDB on Ubuntu</a></p>

<p>After that, according to this second instruction: <a href="https://stackoverflow.com/questions/34486808/installing-the-php-7-mongodb-client-driver">installing php7-mongoDB-client-driver</a>,</p>

<p>I installed </p>

<ul>
<li>php-pear </li>
<li>phpize</li>
</ul>

<p>It can be recapped in</p>

<pre><code>$sudo apt-get install php-pear phpize
</code></pre>

<p>because these two packages were flagged as missing when using</p>

<pre><code>sudo pecl install mongodb
</code></pre>

<p>the first time.</p>

<p>Then I was suggested to install openssl-extension. About that I found an instruction which told me to execute these 3 commands:</p>

<ul>
<li><code>$sudo apt-get install libssl-dev</code> </li>
<li><code>$sudo apt-get install libcurl4-openssl-dev</code></li>
<li><code>$sudo apt-get install libcurl4-openssl-dev pkg-config libssl-dev libsslcommon2-dev</code></li>
</ul>

<p>(the first package was already installed on my system)</p>

<p>after that </p>

<pre><code>$php -m
</code></pre>

<p>should show "openssl" as a single point on the list.</p>

<p>Then I could finally execute </p>

<pre><code>$sudo pecl install mongodb
</code></pre>

<p>This installation displayed four instructions at the end:</p>

<pre><code>&lt;Installing '/usr/lib/php/20151012/mongodb.so'&gt;
&lt;install ok: channel://pecl.php.net/mongodb-1.1.8&gt;
&lt;configuration option "php_ini" is not set to php.ini location&gt;
&lt;You should add "extension=mongodb.so" to php.ini&gt;
</code></pre>

<p>So I executed:</p>

<pre><code>$php -i | grep extension_dir
</code></pre>

<p>which should show up the same path as displayed in the first line.</p>

<pre><code>$pear config-set php_ini /etc/php5/apache2/php.ini
$pecl config-set php_ini /etc/php5/apache2/php.ini
</code></pre>

<p>to follow the instructions of the third line.</p>

<p>Added <code>extension=mongodb.so</code> to phpini at <code>/etc/php/7.0/apache2/</code> 
to conform to line four.</p>

<p>And finally, after restarted apache2, </p>

<pre><code>$php -i
</code></pre>

<p>should display the same version of mongodb similar in the second line.</p>

<p>After all of these steps I found one last package to install which is</p>

<pre><code>$sudo apt-get install php-mongodb
</code></pre>

<p>But also this this didn't help.</p>

<p>To check if the extension is working I used either:</p>

<pre><code>$m = new MongoClient();  OR

$m = new Mongo\Driver\Manager();
</code></pre>

<p>and then echo $m. I read that <code>Mongo\Driver\Manager</code> is the new version but even with this code it doesn't work. It always tells me that the class "could not be found". Irrespective of the class I tried.</p>

<p>I hope this (hopefully) complete instruction can help someone with a similar problem about mongodb and php. </p>

<p>Additionally I hope that these information can help you to give me a hint what else I can do to fix that problem. Unfortunately I searched a long time but didn't found something to include this extension into this php-version.
There where only part but I cant build them together.</p>