To make things right, you must install php_mongo module - mongodb

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.ini
What amb I doing wrong?
The weird thing is that when I run the command "php -v" I get this output:
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:
I would appreciate any help
Thanks!!

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

Related

Install PHP 7.4 PDO driver for PostgreSQL on Centos 7.6

I get the error from PDO when trying to connect to PostgreSQL:
Database Connection Error: could not find driver
I ran command to install driver:
yum install php7.4-pgsql
systemctl restart httpd
Still did not work. I found another possible driver:
yum install php72w-pdo
systemctl restart httpd
Still did not work. Checking phpinfo() page does not show PDO driver for PostgreSQL installed, and checking has no output for pgsql.
php -m | grep pgsql
I also tried installing PostgreSQL on the server, but I don't think I need since the connection is remote server. I also tried other tutorials but most are for PHP 5 and not for PHP 7.4. They said use command:
yum install php-pgsql
But this command will give me error for package conflict and list of required:
Error: Package: php-pgsql-5.4.16-48.el7.x86_64 (base)
Requires: php-pdo(x86-64) = 5.4.16-48.el7
Installed: php-pdo-7.4.11-1.el7.remi.x86_64 (#remi-php74)
php-pdo(x86-64) = 7.4.11-1.el7.remi
Available: php-pdo-5.4.16-48.el7.x86_64 (base)
php-pdo(x86-64) = 5.4.16-48.el7
...
You could try using --skip-broken to work around the problem
You could try running: rpm -Va --nofiles --nodigest
However, I don't think these options should be necessary for Centos 7.4, PHP 7.4.
I can connect from MacOs development environment, but not from the Centos server.
What should I do to install the driver for PDO PostgreSQL?
Turns out I had multiple versions of PHP enabled.
Here is solution to disable all except for the one you want:
php -v
PHP 7.4.24 (cli) (built: Sep 21 2021 11:23:11) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
Check which version you are running (example 7.4)
yum-config-manager --disable 'remi-php*'
yum-config-manager --enable remi-php74
Then install is easy:
yum install php-pdo_pgsql
systemctl restart httpd

How to enable Xdebug on local Macbook?

Need Xdebug extension enabled in my local development environment.
PHP Version: PHP 8.0.10 (CLI)
OS: Mac ( Chip Apple M1 )
Let me summarize the steps that worked for me always.
Reconfirm x-debug installation on the local work desk or enabled in php.ini by running the following command:
➜ ~ PHP -v
Run the below command to install x-debug:
On Apple M1 hardware, you might instead need to use:
➜ ~ arch -arm64 sudo pecl install xdebug
If you have different architecture, below might be suitable.
➜ ~ arch -x86_64 sudo pecl install xdebug
Note: I had installed PHP using Homebrew before like :
➜ ~ brew install php
Now, with above #2, X-debug should be installed and enabled in php.ini.
You might get something similar as below:
Build process completed successfully
Installing '/opt/homebrew/Cellar/php/8.0.10/pecl/20200930/xdebug.so'
install ok: channel://pecl.php.net/xdebug-3.0.4
Extension xdebug enabled in php.ini
Tips:
Usecase 1: Xdebug installed but not enabled in php.ini.
Steps:>
(a) Read the PHP ini file loaded, active with below.
➜ ~ PHP --ini
(b) Use vi editor and add the following line to php.ini: zend_extension="xdebug.so"
( Note: You may also provide the path instead of just xdebug.so. For example, my local machine path is something like this:- /opt/homebrew/Cellar/php/8.0.10/pecl/20200930/xdebug.so
(c) Save and exit editor and try php -v again to confirm x-debug enabled.
Usecase 2: You had run pecl command with the wrong architecture mentioned.
(a) Uninstall x-Debug with below command:
➜ ~ sudo pecl uninstall xdebug
(b) Re-run install command as shared in Step 2 above with caution using correct architecture.

MongoDB php7 driver installation

I'm working on an Ubuntu 16 server and I can't seem to get the mongodb driver for php 7 to work. I installed it successfully on my xampp on my windows machine but Ubuntu and php7 seemingly have vast differences.
I did try to install it via pecl install mongodb and used composer to put in the dependencies but it still does not work. I'm using the same php file from my windows Xampp and when I access the page it throws a 500 status code.
Could someone provide a definitive walkthrough on how to install this driver and maybe also how to revert any changes I made using composer and pecl?
Cool even I tried with pecl but didn't work as expected. It work with pecl7 Also, I received this warning along with error, WARNING: "pecl/mongo" is deprecated in favor of "channel:///mongodb" pecl/mongo requires PHP (version >= 5.3.0, version <= 5.99.99), installed version is 7.1.8. Also, got 500 Internal server error.
Before that MongoDB php7 driver, I needed the memcache and getting phphize error that I solved using this repo. Then finally I use this low level PHP driver for MongoDB.
$ git clone https://github.com/mongodb/mongo-php-driver.git
$ cd mongo-php-driver
$ git submodule sync && git submodule update --init
$ /usr/bin/phpize
$ ./configure
$ make all -j 5
$ sudo make install
You can confirm from the output that mongodb.so driver is installed.
;;;;;;;;;;;;;;;;;;;
; Module Settings ;
;;;;;;;;;;;;;;;;;;;
extension=mongodb.so
Then only step remaining is make it available in your respective path. You can check your extensions_dir in php.ini with the following command,
$ php -i | grep extension_dir
extension_dir => /usr/lib64/php/7.0/modules => /usr/lib64/php/7.0/modules
And, I can verify that mongodb.so is present into the above directory. Then reload the composer and you are good to go ! Hope this helps as it work for me.

The MongoDB PECL extension has not been installed or enabled [duplicate]

I am using Ubuntu 12.04 LTS and installed pecl in /opt/lampp/bin/ .
When installing second time its throwing error -
Command run previously -
pecl install mongo
pecl/mongo is already installed and is the same as the released
version 1.5.1 install failed
Now when I am Checking by -
echo extension_loaded("mongo") ? "loaded\n" : "not loaded\n";
It is showing not Loaded.
However I updated the php.ini with extension=mongo.so and restarted the server, but its not working.
Let me now what I am doing wrong.
EDIT
I re instantiated the command and following is the outcome -
Build process completed successfully
Installing '/opt/lampp/lib/php/extensions/no-debug-non-zts-20100525/mongo.so'
install ok: channel://pecl.php.net/mongo-1.5.1
configuration option "php_ini" is not set to php.ini location
You should add "extension=mongo.so" to php.ini
Finally with the help of Neil Lunn I made it the right way.
I added the full path and added the code at the very last line of my php.ini
extension="/opt/lampp/lib/php/extensions/no-debug-non-zts-20100525/mongo.so"
I got the solution for xampp in ubntu linux.
If this command not work for you pecl install mongo
you should type below command
sudo /opt/lampp/bin/pecl install mongo

MongoDB Install Error

Just setup a fresh server at MediaTemple (dedicated virtual / CentOS Linux) and installed the developer tools, but Mongo won't install, any ideas?
Also, it's trying to DL version 1.2.10 I assume I can run pecl upgrade mongo once it is installed to go to 2.0.6 right?
Here's my output:
[root ~]# pecl install mongo
downloading mongo-1.2.10.tgz ...
Starting to download mongo-1.2.10.tgz (86,463 bytes)
.....................done: 86,463 bytes
36 source files, building
running: phpize
Configuring for:
PHP Api Version: 20041225
Zend Module Api No: 20060613
Zend Extension Api No: 220060519
building in /var/tmp/pear-build-root/mongo-1.2.10
running: /root/tmp/pear/cache/mongo-1.2.10/configure
checking for egrep... grep -E
checking for a sed that does not truncate output... //bin/sed
checking for gcc... gcc
checking for C compiler default output file name... a.out
checking whether the C compiler works... configure: error: cannot run C compiled programs.
If you meant to cross compile, use `--host'.
See `config.log' for more details.
ERROR: `/root/tmp/pear/cache/mongo-1.2.10/configure' failed
You're not installing mongodb with pecl, here you're installing the PHP driver for mongodb.
To install mongodb on CentOS, please follow these instructions here. These instructions show you how to add the 10gen repo, which will then enable you (using yum) to install the latest production-ready mongodb release (2.0.6).
I realise that it's not Ubuntu but egarding your issue with installing the PHP driver, does it make any difference if you run
sudo pecl install mongo
There's some information here on installing the mongo php driver, just replace the 'apt-get' elements with 'yum' as the same libraries, dependencies apply afaik.
Here's a tutorial on using the mongo php driver.