Search code examples
mongodbcentospleskphp-mongodb

To make things right, you must install php_mongo module


I am not able to install the php mongo driver in a VPS. I've followed this and this documentantion

I checked this stack here but i can't figure out what I am doing wrong.

The VPS runs on PLESK 12 and CentOS 7.

lets say that I have the domain "mydomain.com" on my plesk and in mydomain.com/info.php a phpinfo script.

PHP INFO

php info

php info 2

PHP.ini

php ini

modules

What amb I doing wrong?

The weird thing is that when I run the command "php -v" I get this output:

php version

Which is not the version that is showing phpInfo.

Finally, I can't install the newest driver versions using pecl because I get the following error:

pecl error

I would appreciate any help

Thanks!!


Solution

  • It's happens because you are call native OS binaries of php and pecl.

    Plesk's PHP 5.6 binaries are stored in /opt/plesk/php/5.6/bin/. So you have to call /opt/plesk/php/5.6/bin/php and /opt/plesk/php/5.6/bin/pecl

    Here full steps how to install mongodb for PHP 5.6:

    [root@cos71x64-plesk12 ~]# /opt/plesk/php/5.6/bin/pecl install mongodb

    /opt/plesk/php/5.6/bin/phpize not found. Run 'yum install plesk-php56-devel' to install it
    

    [root@cos71x64-plesk12 ~]# yum install plesk-php56-devel

    [root@cos71x64-plesk12 ~]# /opt/plesk/php/5.6/bin/pecl install mongodb

    Build process completed successfully
    Installing '/opt/plesk/php/5.6/lib64/php/modules/mongodb.so'
    install ok: channel://pecl.php.net/mongodb-1.1.4
    configuration option "php_ini" is not set to php.ini location
    You should add "extension=mongodb.so" to php.ini
    

    [root@cos71x64-plesk12 ~]# echo "extension=mongodb.so" > /opt/plesk/php/5.6/etc/php.d/mongodb.ini

    [root@cos71x64-plesk12 ~]# /opt/plesk/php/5.6/bin/php --info | grep mongo

    /opt/plesk/php/5.6/etc/php.d/mongodb.ini,
    mongodb
    mongodb support => enabled
    mongodb version => 1.1.4
    mongodb stability => stable
    libmongoc version => 1.3.3
    mongodb.debug => no value => no value