I have an error saying MongoClient class is not found.
I've tried both the instructions on the MongoDB website and these answers.
Upon php -v there is
PHP Startup: Unable to load dynamic library '/usr/lib/php/20131226/mongo.so'
PHP 5.6.30-1+deb.sury.org~trusty+1 (cli)
Copyright (c) 1997-2016 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies
with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2016, by Zend Technologies
with Xdebug v2.5.0, Copyright (c) 2002-2016, by Derick Rethans
with sudo grep -rnw /etc -e "mongo.so"
I have
/etc/php/5.6/fpm/php.ini:2033:extension=mongo.so
/etc/php/5.6/cli/php.ini:2032:extension=mongo.so
/etc/php/5.6/apache2/php.ini:2033:extension=mongo.so
Then I tried the manual installation.
When I run phpize
PHP Api Version: 20121113
Zend Module Api No: 20121212
Zend Extension Api No: 220121212
At the make test output I get
PHP Warning: PHP Startup: mongo: Unable to initialize module
Module compiled with module API=20121212
PHP compiled with module API=20131226
How do I compile the correct module?
I've removed php 7 entirely
sudo apt-get purge php7.*
I guess you had installed the wrong extension for your system.
I suggest to start fresh and use pecl to install and compile mongo extension properly.
Install pecl (assuming that you are using Debian-based distribution with correct apt repos, pecl comes bundled with php-pear)
sudo apt-get install php5-dev php-pear
Install the legacy mongo driver from pecl
sudo pecl install mongo
Add extension=mongo.so on php.ini
sudo su
echo "extension=mongo.so" >> /etc/php5/mods-available/mongo.ini
ln -rs /etc/php5/mods-available/mongo.ini /etc/php5/cli/conf.d/30-mongo.ini
ln -rs /etc/php5/mods-available/mongo.ini /etc/php5/fpm/conf.d/30-mongo.ini
ln -rs /etc/php5/mods-available/mongo.ini /etc/php5/apache2/conf.d/30-mongo.ini
Note that the legacy driver is not compatible with PHP 7+ and the lastest version of MongoDB one can use with this driver is 3.0. See the compatibility chart from MongoDB Docs.
Related
I have Centos 7 and Virtualmin installed, with the tipycal php-fpm 5.4, 7.0, 7.1 that you can choice between the versions you prefer on every virtualhost via Virtualmin control panel, and everything works well.
But when I access to the server via SSH and check php -v I get this:
PHP 5.4.16 (cli) (built: Oct 30 2018 19:30:51)
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2013 Zend Technologies
How can I select another php default/base version for the shell system?
When you issue the php command on the shell it uses the default php version on the server which in your case is php-5.4.16
To use another php version, you have to check where the binaries for those php versions are and invoke them with their full path rather than just typing php.
For example, on CentOS, for PHP 7.2 for example, the full path of the php binary is: /opt/rh/rh-php72/root/usr/bin/php
root#virtualmin /root
ยป /opt/rh/rh-php72/root/usr/bin/php -v
PHP 7.2.24 (cli) (built: Nov 4 2019 10:23:08) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
with Zend OPcache v7.2.24, Copyright (c) 1999-2018, by Zend Technologies
Install versions of PHP in centos 7
Setup Yum Repository
First of all, you need to enable Remi and EPEL yum repositories on your system. Use the following command to install EPEL repository on your CentOS and Red Hat 7/6 systems
Use this command to install EPEL yum repository on your system
sudo yum install epel-release
and now execute one of the following commands as per your operating system version to install the Remi repository.
sudo rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-7.rpm
Install PHP 7 on CentOS
Your system is prepared for the PHP installation from yum repositories. Use one of the following commands to install PHP 7.4 or PHP 7.3 or PHP 7.2 or PHP 7.1 on your system based on your requirements.
Install PHP 7.4
yum --enablerepo=remi-php74 install php
Install PHP 7.3
yum --enablerepo=remi-php73 install php
Install PHP 7.2
yum --enablerepo=remi-php72 install php
.
Check version PHP install
php -v
.
PHP 7.4.1 (cli) (built: Dec 17 2019 16:35:58) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
Install PHP Modules
You may also need to install additional PHP modules based on your application requirements. The below command will install some more useful PHP modules.
For PHP 7.4
yum --enablerepo=remi-php74 install php-xml php-soap php-xmlrpc php-mbstring php-json php-gd php-mcrypt
For PHP 7.3
yum --enablerepo=remi-php73 install php-xml php-soap php-xmlrpc php-mbstring php-json php-gd php-mcrypt
For PHP 7.2
yum --enablerepo=remi-php72 install php-xml php-soap php-xmlrpc php-mbstring php-json php-gd php-mcrypt
Whenever I try to run this code
example#testserver:~$ sudo apt-get install php5-xdebug
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package php5-xdebug
I get this error "E: Unable to locate package php5-xdebug"
Please help
Thanks
If you're running the default apt installation of PHP on Ubuntu 16.04, then it should be PHP7. If I had to guess from php5-xdebug, then I'd say you were using a command intended for Ubuntu 14.04 or older where the default PHP installation was PHP5. You can verify your PHP version with:
php --version
This is what I see:
PHP 7.0.8-0ubuntu0.16.04.2 (cli) ( NTS )
Copyright (c) 1997-2016 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2016 Zend Technologies
with Zend OPcache v7.0.8-0ubuntu0.16.04.2, Copyright (c) 1999-2016, by Zend Technologies
with Xdebug v2.4.0, Copyright (c) 2002-2016, by Derick Rethans
At any rate, you should be able to search available packages for your configuration with:
apt search xdebug
From my relatively fresh Ubuntu 16.04 install without any added PPA's, I get one result:
php-xdebug - Xdebug Module for PHP
So you can install this package by name (note the missing "5" from your command):
sudo apt install php-xdebug
You might also have to restart your webserver. If you're running the stock build of Apache for Ubuntu 16.04:
sudo service apache2 restart
I have a vagrant box with LAMP. Linux distribution is Ubuntu 14.04.1
My PHP project has got a composer package and it's package use gd extension. I install php5-gd and added to php.ini file but it's not sold the problem. I type "php -v" to terminal it's return:
PHP Warning: PHP Startup: gd: Unable to initialize module
Module compiled with module API=20121212
PHP compiled with module API=20131226
These options need to match in Unknown on line 0
PHP 5.6.20-3+donate.sury.org~trusty+1
Does anyone help me? I think this problem maybe experienced from anyone before me.
Solve of this problem
PHP 5.6.20+ version is not stable and packages maybe incompatible. You should be see in here which version is stable. I want to find specific version of extensions and found in here.
I get with wget debian package of php-gd extension:
wget http://http.us.debian.org/debian/pool/main/p/php5.6/php5.6-gd_5.6.20+dfsg-3_amd64.deb
And install with dpkg:
sudo dpkg - i php5.6-gd_5.6.20+dfsg-3_amd64.deb
It's continue to return error message like this:
dpkg: warning: downgrading php5.6-gd from 5.6.20+dfsg-3+donate.sury.org~trusty+1 to 5.6.20+dfsg-3
(Reading database ... 73009 files and directories currently installed.)
Preparing to unpack .../php5.6-gd_5.6.20+dfsg-3_amd64.deb ...
Unpacking php5.6-gd (5.6.20+dfsg-3) over (5.6.20+dfsg-3+donate.sury.org~trusty+1) ...
dpkg: dependency problems prevent configuration of php5.6-gd:
php5.6-gd depends on php5.6-common (= 5.6.20+dfsg-3); however:
Version of php5.6-common on system is 5.6.20+dfsg-3+donate.sury.org~trusty+1.
php5.6-gd depends on libgd3 (>= 2.1.1); however:
Version of libgd3:amd64 on system is 2.1.0-3.
php5.6-gd depends on libjpeg62-turbo (>= 1.3.1); however:
Package libjpeg62-turbo is not installed.
php5.6-gd depends on libpng16-16 (>= 1.6.2-1); however:
Package libpng16-16 is not installed.
dpkg: error processing package php5.6-gd (--install):
dependency problems - leaving unconfigured
Processing triggers for php5.6-fpm (5.6.20+dfsg-3+donate.sury.org~trusty+1) ...
php5.6-fpm stop/waiting
php5.6-fpm start/running, process 11382
Errors were encountered while processing:
php5.6-gd
This informations say our "php5.6-common" package must be install at system. For fix this problem is this command:
sudo apt-get -f install
After this command will upgrade "php5.6-gd" and installed correct package. I type terminal "php -v" and it's say me everything is good:
PHP 5.6.20-3+donate.sury.org~trusty+1 (cli)
Copyright (c) 1997-2016 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies
with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2016, by Zend Technologies
with Xdebug v2.4.1-dev, Copyright (c) 2002-2016, by Derick Rethans
I followed this tutorial:
$ apt-get install php-pear php5-dev libmagic-dev
$ pecl install fileinfo
$ sudo echo "extension=fileinfo.so" > /etc/php5/fileinfo.ini
$ sudo apachectl restart
But when I run this, it said failing message:
root#111:~/mine/Fileinfo-1.0.4# pecl install fileinfo
WARNING: "pear/Fileinfo" is deprecated in favor of "channel://php-src/ext/fileinfo/in php sources"
downloading Fileinfo-1.0.4.tgz ...
Starting to download Fileinfo-1.0.4.tgz (5,835 bytes)
.....done: 5,835 bytes
3 source files, building
WARNING: php_bin /alidata/server/php/bin/php appears to have a suffix /bin/php, but config variable php_suffix does not match
running: phpize
Cannot find config.m4.
Make sure that you run '/alidata/server/php/bin/phpize' in the top level source directory of the module
ERROR: `phpize' failed
Here is my machine information:
root#111:~/mine/Fileinfo-1.0.4# lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 12.04.1 LTS
Release: 12.04
Codename: precise
Here is my PHP version information:
root#111:~/mine/Fileinfo-1.0.4# php --version
PHP 5.4.27 (cli) (built: Jun 12 2014 22:20:06)
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2014 Zend Technologies
with Zend Guard Loader v3.3, Copyright (c) 1998-2013, by Zend Technologies
My system is Ubuntu 12.04, PHP 5.3, and I'm trying to run some basic Intl code like this:
<?php
$coll = collator_create('en_US');
$result = collator_compare($coll, "string#1", "string#2");
and it outputs
PHP Fatal error: Call to undefined function collator_create()
Wasn't Intl extension supposed to be bundled with PHP since version 5.3?
PHP was installed via apt-get with this command line (I don't use Apache):
apt-get install php5 php5-cli php5-mysql php5-cgi php5-fpm php5-curl php-apc php5-memcache php5-memcached php5-common php5-gd php-xml-parser php-pear php5-imap php5-mcrypt php5-xdebug php5-suhosin
And here is what php -v produces:
PHP 5.3.10-1ubuntu3.5 with Suhosin-Patch (cli) (built: Jan 18 2013 23:40:19)
Copyright (c) 1997-2012 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2012 Zend Technologies
with Xdebug v2.1.0, Copyright (c) 2002-2010, by Derick Rethans
with Suhosin v0.9.33, Copyright (c) 2007-2012, by SektionEins GmbH
You have specify --enable-intl when installing to use the bundled version of intl, or you can install it via PECL. See: http://www.php.net/manual/en/intl.installation.php
apt-get install php5-intl will also work.
Add php5-intl to the list of things you install.
It looks like it's just not part of the core PHP5 release, even though it is an option to be included, similar to how php-apc is now a standard part of PHP, though you have to explicitly install it.
Try in php.ini uncomment extension intl "extension = php_intl.dll", should be removed ";" before "extension", and then restart the server.