I'm running into a problem getting a valid mongo driver compiled for the API version of PHP that I'm running. Using php - v
PHP 5.6.24-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
What is happening is that even when I use what I think is the correct phpize it is still configuring the build for an older API version.
When I run /usr/bin/phpize -v here is what I get:
Configuring for:
PHP Api Version: 20121113
Zend Module Api No: 20121212
Zend Extension Api No: 220121212
BUT when I try to use the compiled version of the mongo driver I get this warning message:
PHP Warning: PHP Startup: mongo: Unable to initialize module
Module compiled with module API=20121212
PHP compiled with module API=20131226
Here is the whereis php output:
php: /usr/bin/php /usr/bin/php5.6 /etc/php /usr/lib/php /usr/share/php5.6-mysql /usr/share/php5.6-common /usr/share/php5.6-xml /usr/share/php5.6-curl /usr/share/php5.6-mcrypt /usr/share/php5.6-intl /usr/share/php /usr/share/php5.6-readline /usr/share/php5.6-gd /usr/share/php5.6-opcache /usr/share/php5.6-json /usr/share/php5.6-mbstring /usr/share/man/man1/php.1.gz
Can someone please give me step by step instructions on how to properly compile the Mongo driver on Ubuntu 14.04?
I don't know what command you are exactly using, but you should be fine running pecl install on ubuntu.
So to install this official PHP driver for mongo: https://pecl.php.net/package/mongodb just run:
pecl install mongodb
and you should be good to go. Maybe it tells you that some libs are missing, but you can use apt-get install to install them afterwards.
You can read more about the driver here
If pecl command is not found, install it using
apt-get install php-pear
Related
I'm trying to install xdebug.
I've already seen some issues about it (like this one : Installing xdebug with PHP 5.5 ) but it seems outdated and not corresponding to my issue).
When I try
sudo pecl install xdebug
I'm getting the following error
WARNING: channel "pecl.php.net" has updated its protocols, use "pecl channel-update pecl.php.net" to update
downloading xdebug-2.8.0.tgz ...
Starting to download xdebug-2.8.0.tgz (238,122 bytes)
.................................................done: 238,122 bytes
69 source files, building
running: phpize
sh: 1: phpize: not found
ERROR: `phpize' failed
It seems that means phpize isn't installed in my php version
php -v
PHP 7.2.24-0ubuntu0.19.04.1 (cli) (built: Oct 24 2019 11:49:39) ( 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-0ubuntu0.19.04.1, Copyright (c) 1999-2018, by Zend Technologies
So, some topics seems to tell me to change my php version to download a version with phpsize included. But I was more looking for a way to add phpsize to my current php version but I don't know how to do that.
Thanks for your assistance
If Ubuntu first you need install php dev version:
sudo apt install php7.x-dev
And then:
sudo pecl install xdebug
I had some problems with xdebug version too.
I had to install an specific version for php7.1 using PECL,
I don't really know if your question is already solved but let me share you this webpage, it's the compatibility graph to know wich version works with an specific php versions:
https://xdebug.org/docs/compat
As far as I know if you want to install the latest xdebug version you can use the repo, but if you need an old version you'll be forced to install it using PECL.
Hope you find this answer usefull!
I am using php 7.0 in Ubuntu 18.04 LTS.
I have to implement multi-threading in php with help of pthread.
Several method I tried but every time getting
configure: error: pthreads requires ZTS, please re-compile PHP with ZTS enabled
ERROR: `/tmp/pear/temp/pthreads/configure --with-php-config=/usr/bin/php-config' failed
Even I tried to install php from scratch but could not success.
I was follow following website steps :
https://www.rapidspike.com/blog/php7-pthreads/
Please help.
According to your comment:
php -v output is follow : PHP 7.0.31-1+ubuntu18.04.1+deb.sury.org+1
(cli) (built: Jul 25 2018 10:01:10) ( NTS ) Copyright (c) 1997-2017
The PHP Group Zend Engine v3.0.0, Copyright (c) 1998-2017 Zend
Technologies with Zend OPcache v7.0.31-1+ubuntu18.04.1+deb.sury.org+1,
Copyright (c) 1999-2017, by Zend Technologies with Xdebug v2.6.0,
Copyright (c) 2002-2018, by Derick Rethans
You are trying to install a pecl package against the invalid version of PHP which is in your case ( NTS ) instead of ( ZTS ).
To get rid of this you will need one of this possible actions:-
1- Install pecl package for a specific PHP version.
pecl -d php_suffix=X.X-zts install pthreads
2- Update the default version for your environment.
sudo update-alternatives --set php /usr/bin/phpX.X-zts
Note & Warning: this means that all of your php terminal applications will be running under the ZTS version which may cause some unexpected behaviors.
However you can toggle your PHP versions back after installation.
3 - Compile phtread from source and define the target PHP version (complicated but preferred).
$ git clone https://github.com/krakjoe/pthreads.git
$ cd pthreads/
$ phpize
$ ./configure --with-php-config=/path/to/php-zts/bin/php-config
$ make
$ make install
You will may need to update alternatives also for phpize
update-alternatives --set phpize /usr/bin/phpize-zts
Note: All of PHP versions that had been mentioned in this answer may be different from setup to setup, So you may need to check your PHP version name&path using locate bin/php
I am new to PHP. I want to enable Xdebug in Eclipse IDE but when I check Xdebug for my version https://xdebug.org/wizard.php showing error:- here is what
Tailored Installation Instructions
Summary
Xdebug installed: no
Server API: Apache 2.0 Handler
Windows: yes - Compiler: MS VC11 - Architecture: x86
Zend Server: no
PHP Version: 5.6.32
Zend API nr: 220131226
PHP API nr: 20131226
Debug Build: no
Thread Safe Build: yes
Configuration File Path: C:\Windows
Configuration File: E:\xampp1\php\php.ini
Extensions directory: E:\xampp1\php\ext
PHP versions below 7.0 are not supported.
If you like Xdebug, and thinks it saves you time and money, please have a look at the donation page.
Please help to install Xdebug in Eclipse. I've installed XAMPP, Eclipse PDT PHP.
It seams your PHP Version is too low for xdebug:
Your PHP: "PHP Version: 5.6.32"
xDebug log said: "PHP versions below 7.0 are not supported."
So, after you upgrade you PHP version and successfully install xdebug, you should see (example):
# php -v
HP 7.2.3 (cli) (built: Mar 8 2018 10:30:06) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
with Xdebug v2.6.0, Copyright (c) 2002-2018, by Derick Rethans
with Zend OPcache v7.2.3, Copyright (c) 1999-2018, by Zend Technologies
I wanted to update this question because it is still possible to install XDebug against 5.6 and may still be necessary for legacy applications.
The wizard won't help you if you need to install XDebug for an older version of PHP (<7); you'll have to read the documents and work out the process yourself.
At https://derickrethans.nl/xdebug-php5.html the author states that the older source is available for downloading and using with older versions of php, and that 2.5 is the last version to work with PHP 5.6. You can download xdebug 2.5 from https://xdebug.org/download.php (or other versions as required).
The instructions on how to do this are on the XDebug website but maybe a little hard to grasp. A rough guide for installing installing on a CentOS 7.5 with Php 5.6 would be:
wgets https://xdebug.org/files/xdebug-2.5.5.tgz
tar -xvzf xdebug-2.6.0.tgz
cd xdebug-2.6.0
phpize [troubleshoot: yum install php-devel]
./configure --enable-xdebug
make
create a directory keep the xdebug module: mkdir /usr/php/xdebug/255
cp modules/xdebug.so /usr/php/xdebug/255
Find the active php.ini using php -i or phpinfo() in a script.
Restart the webserver: sudo service httpd restart
Make sure XDdebug is reported as enabled.
Edit php.ini: sudo nano /etc/php.ini
Add (or whatever your preferred options are) to php.ini:
zend_extension="/usr/php/xdebug/255/xdebug.so"
xdebug.remote_enable=1
xdebug.remote_autostart = 1
xdebug.remote_port="9000"
xdebug.remote_connect_back=on
Configure your client to connect. I've had this working with vscode.
You can find more information at https://xdebug.org/docs/install.
My php -v
PHP 7.1.15-1+ubuntu14.04.1+deb.sury.org+2 (cli) (built: Mar 6 2018
11:51:39) ( NTS ) Copyright (c) 1997-2018 The PHP Group Zend Engine
v3.1.0, Copyright (c) 1998-2018 Zend Technologies
with Xdebug v2.6.0, Copyright (c) 2002-2018, by Derick Rethans
with Zend OPcache v7.1.15-1+ubuntu14.04.1+deb.sury.org+2, Copyright (c) 1999-2018, by Zend Technologies
I have tried both the pecl way
sudo pecl install redis
sudo service php7.1-fpm restart
And the manual way from https://github.com/phpredis/phpredis
phpize
./configure [--enable-redis-igbinary]
make && make install
I made sure to put
extension=/usr/lib/php/20170718/redis.so
into the php.ini file as shown when I run echo phpinfo();
e.g.
/etc/php/7.1/cli/php.ini
When I run the inbuilt web server I get
PHP Warning: PHP Startup: Unable to load dynamic library
'/usr/lib/php/20170718/redis.so' - /usr/lib/php/20170718/redis.so:
undefined symbol: zend_empty_string in Unknown on line 0
Strangely PHPStorm autocompletes the PHP Redis class, so
$redis = new \Redis();
$redis->connect('127.0.0.1', 6379);
I can click into the Redis class and see it is the correct one.
I wonder if it is a version difference? Maybe because I am using 32-bit?
Another strange thing is, if I just put
extension=redis.so
in php.ini, it seems to be looking for an older build
PHP Startup: Unable to load dynamic library
'/usr/lib/php/20160303/redis.so' - /usr/lib/php/20160303/redis.so:
cannot open shared object file: No such file or directory in Unknown
on line 0
When I run
sudo apt-get install php-redis
it installs and means that no start up error shows, but the web page still shows a
Class 'Redis' not found
One other thing I notice is that in Apache, there is no error, and the class is found. But when I run php's inbuilt web server, the not found error shows up.
May you just need to install this using a ppa package like:
sudo apt-get install php7.1-redis
Ok so I noticed that phpinfo showed
PHP API 20160303
which means that the earlier error makes sense. The PHP version of the web server is 7.1, however, when running the phpredis phpize it shows the one for 7.2.
So I just made sure to remove php7.2-dev and re-install php7.1 via apt-get, then re-run the github repo steps above.
After one of PHP updates (ubuntu) I got an error Class 'AMQPConnection' not found in my application.
I reinstalled latest stable version (1.7.1) of amqp via pecl
sudo pecl uninstall amqp
sudo pecl install amqp
It asks me:
downloading amqp-1.7.1.tgz ...
Starting to download amqp-1.7.1.tgz (79,905 bytes)
..................done: 79,905 bytes
18 source files, building
running: phpize
Configuring for:
PHP Api Version: 20121113
Zend Module Api No: 20121212
Zend Extension Api No: 220121212
Set the path to librabbitmq install prefix [autodetect] :
When I choose one of the variants - builds fails, error always like
configure: error: Please reinstall the librabbitmq distribution itself or (re)install librabbitmq development package if it available in your system
ERROR: `/tmp/pear/temp/amqp/configure --with-librabbitmq-dir=20121113' failed
If I choose autodetect, installation proccessed successfully.
Then I add extension=amqp.so into php.ini and get an error
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php5/20131226/amqp.so' - /usr/lib/php5/20131226/amqp.so: cannot open shared object file: No such file or directory in Unknown on line 0
I found amqp.so via
locate amqp.so
It display
/usr/lib/php5/20121212/amqp.so
Then I change extension=amqp.so to the full path /usr/lib/php5/20121212/amqp.so
And I get very interesting error
PHP Warning: PHP Startup: amqp: 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
As I understand, PHP compiled with version newest than Amqp.
But it is the latest amqp library version.
Pecl shows:
Package Stable/(Latest) Local
amqp 1.7.1 (stable) 1.7.1 Communicate with any AMQP compliant server
PHP version is 5.6.4
PHP 5.6.4-4ubuntu6 (cli) (built: Apr 17 2015 15:47:51)
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2014 Zend Technologies
with Zend OPcache v7.0.4-dev, Copyright (c) 1999-2014, by Zend
Technologies
with Xdebug v2.2.6, Copyright (c) 2002-2014, by Derick Rethans