3

I have a Debian web server on which I installed Apache/Mysql/PHP5 around ISPConfig 3. I manually installed an additionnal PHP version (PHP 7.0.5) in order to have one website on PHP 5, and one website on PHP 7, and everything was working. (I used the following tutorial for installing PHP 7: https://www.howtoforge.com/tutorial/how-to-install-php-7-on-debian/)

Now I want to install the new MongoDB driver (PHP 7 friendly) so it works with my PHP 7 website (I got the legacy driver working on PHP 5).

To do this I used pecl install mongodb and added extension=mongodb.so to the PHP 7 ini file. The installation is OK but when I check the extension status on PHP 7, it tells me the extension is not loaded.

The reason seems to be the MongoDB driver installed on the PHP 5 version and not the PHP 7 one.

How can I tell the MongoDB driver to install on the PHP 7 version with PECL (or maybe another way to install it)?

5
  • This depends on how you installed PHP 7, which you did not disclose. May 19, 2016 at 12:41
  • I compiled PHP 7 myself, following the tutorial provided. Is it bad doctor? :-\ May 19, 2016 at 12:42
  • If you want to reference the tutorial, you need to at least provide a link for it
    – Colt
    May 19, 2016 at 12:49
  • The mongodb PECL extension states "This package has been superseded, but is still maintained for bugs and security fixes." which may be why it's not installing right in PHP7.
    – ceejayoz
    May 19, 2016 at 13:18
  • You're talking about the legacy MongoDB driver. I'm trying to install the new one, which is maintained and PHP 7 friendly (pecl.php.net/package/mongodb). I did install it on a full PHP 7 web server before and it was working. My problem here is that I have two PHP versions and it's installing on the wrong one. May 19, 2016 at 13:21

2 Answers 2

1
+50

When you call pecl binary without full path your shell likely runs /usr/bin/pecl, which in turn is likely installed by PHP5 from a .deb package. You need to run the pecl binary installed with PHP7. Where is it placed it can only be known for sure by you as paths are configured at compile time. Try /usr/local/bin/pecl and $PREFIX/bin/pecl ($PREFIX being another configure option).

1
  • Wow, tank you so much man! Following your indications, I was able to find the PHP7 pecl binary, which was located in /opt/php-7.0.5/bin/pecl. I executed the installation of the mongodb driver using this binary and now my extension is installed and working fine on PHP7! You shall get my bounty mate ;) Thx again May 24, 2016 at 13:52
0

just use: sudo apt-get install php7.0-mongodb check php info: https://www.php.net/manual/es/mongodb.installation.pecl.php

Regards, Amic.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .