Loading extension apc for php5.4.6 - php

I'm afraid I put quite a mess on my development computer and I could use some help. Basically, I had php5.3.2 on ubuntu installed with apt-get package with apc loaded as a dynamic extension.
Today, I decided to upgrade to php5.4.6 using this PPA: https://launchpad.net/~ondrej/+archive/php5. So, I run now php5.4.6 but apc won't load anymore.
So I did
pecl uninstall apc
then
pecl install apc-3.1.13
to make sure I got a version of apc compatible with php5.4.
Everythin seems to go well but the extension still won't load. It does not show on a phpinfo(). I added extension=apc.so in php.ini of course.
I think I found the origin of the problem but I don't know how to fix it:
According to my phpinfo():
PHP API 20100412
PHP Extension 20100525
Zend Extension 220100525
Zend Extension Build API220100525,NTS
PHP Extension Build API20100525,NTS
When I do, pecl install apc, I got:
54 source files, building
running: phpize
Configuring for:
PHP Api Version: 20090626
Zend Module Api No: 20090626
Zend Extension Api No: 220090626
As a result apc.so will be installed in /usr/lib/php5/20090626 instead of /usr/lib/php5/20100525.
How can I fix this?

Just change the API version in zend_modules.h in your php binary source to the PHP extension API number which is indicates in phpinfo().
For example if the php extension API in phpinfo() is 20100525, you must change the API number in zend_modules.h file to 20100525 and then recompile your project.

I found a way to fix that. A simple
sudo apt-get install php-apc
will do the trick.

Related

PHP - Install mcrypt for PHP 7.2 and API Version 20170718

I need to install mcrypt for php on my Linux server. I have PECL, and PHP 7.2 running on API version 20170718 (i.e., all the PHP *.so extensions are loaded from /usr/bin/php/20170718). But, when I run,
pecl install mcrypt-1.0.1
It says,
Configuring for:
PHP Api Version: 20180731
Zend Module Api No: 20180731
Zend Extension Api No: 320180731
libmcrypt prefix? [autodetect] : ...
And if I install it, the wrong version gets installed, and it doesn't appear because I'm running php API version 20170717, not 20180731. In addition, including it directly from the /usr/bin/php/20180731 directory still causes it to crash since it recognizes it's the wrong API version.
How can I install the proper mcrypt version for PHP API version 20170718?

How to build mongo.so or PHP with the correct module api version

Trying to install mongoDB on my MAMP setup. I have MAMP 3.05, which comes with PHP 5.5.10. Installed mongo using the instructions from the mongo website and it seems to be running properly. Grabbed mongo extension from the mongo github page and followed their instructions for building and adding the extension to php.ini.
Everything seems ok until I restart MAMP. In php_error.log, I see this:
PHP Warning: PHP Startup: mongo: Unable to initialize module
Module compiled with module API=20100525
PHP compiled with module API=20121212
These options need to match
in Unknown on line 0
It looks like the API number for php is a later version, so it would be nice not to have to rebuild an older version of PHP. Is there a way to rebuild the mongo extension with the correct module version, or do I have to discard MAMP and build PHP manually?
Please check with the command which phpize if you use the correct version of the phpize command. This should point to a directory similar to the one you installed your PHP5 into. Mine is found in /usr/bin/phpize which is the default OS X installation.
You can further run phpize -v to check the API version it links against. In my case (the default OS X PHP installation) it outputs:
Configuring for:
PHP Api Version: 20100412
Zend Module Api No: 20100525
Zend Extension Api No: 220100525
If the outputted API version does not match your required number 20121212 (in my case it is 20100412 which does not match) you are using the wrong phpize to configure the extension.
You have to do this first
sudo cp -r /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/S‌​DKs/MacOSX10.10.sdk/usr/include/php /usr/include/php

OSX 10.9 xdebug wrong phpize

Quick background.
Running OSX Mavericks.
Want to run xdebug in NetBeans
Pear runs okay
xdebug stopped running after OSX upgrade. Tried to reinstall. During the install I get:
Configuring for:
PHP Api Version: 20100412
Zend Module Api No: 20100525
Zend Extension Api No: 220100525
But in phpinfo:
PHP API 20121113
PHP Extension 20121212
Zend Extension 220121212
Best thing I can figure out (after hours of trawling through similar issues) is to make sure I am using the correct version of phpize.
which phpize returns:
/Applications/MAMP/bin/php/php5.5.3/bin/phpize
whereis phpize returns:
/usr/bin/phpize
My question is in two parts:
Is the different PHP API Version likely to stop xdebug from running and; how can I make sure that I am using the correct version of phpize?
A wrong API makes Xdebug to not even load, so yes, that is a problem.
To use the correct one, you will need to figure out which php binary you use in the first place. It is likely that if you use MAMP's php binary, its in the same directory as the phpize you need to use. The same for /usr/bin/phpize, which should match /usr/bin/php's API numbers. phpinfo() output might give you hints as to which PHP binary is being used.

Mac 10.6 - unable to install PHP intl

I'm trying to install the PHP intl extension on Mac 10.6 "Snow Leopard" using the following command:
sudo pecl install intl
...but getting the following errors:
running: phpize
grep: /usr/include/php/main/php.h: No such file or directory
grep: /usr/include/php/Zend/zend_modules.h: No such file or directory
grep: /usr/include/php/Zend/zend_extensions.h: No such file or directory
Configuring for:
PHP Api Version:
Zend Module Api No:
Zend Extension Api No:
Cannot find autoconf. Please check your autoconf installation and the
$PHP_AUTOCONF environment variable. Then, rerun this script.
ERROR: `phpize' failed
I am using the bundles Apache server with PHP 5.3.4.
Does anyone know how to install the intl extension?
Have you thought about using MAMP instead? It generally works better than Apple's bundled packages.
I've installed Zend Server CE and everything works 100%.
I removed Zend Server CE later on, and used this instead:
http://php-osx.liip.ch/ which is specifically built for Mac OSX 10.6, and Symfony2 in mind.
This worked better for me in the end, as I'm a Netbeans user, this means I can use xdebug bundled with the liip distribution.
I found it a bit cumbersome getting xdebug installed on Zend Server CE, and also, the liip PHP installation doesn't install an additional Apache and MySQL, it uses what is already included with the OS.
Try installing autoconf
brew install autoconf
Regards
This might be an old post, but for me, I found the easiest option was to install PHP using the liip service (http://php-osx.liip.ch/). Using one simple command, it installed the latest version of PHP, configured it with the existing apache server installed on my mac all along with the intl extension. A number of hours frustration solved in a couple of minutes!

Problems installing PHP's PECL sphinx module

I've installed the sphinx binaries and libraries and am now trying to install the PECL sphinx module.
My system is running OS X 10.6 with MAMP 1.8.2 installed. I try to install sphinx using the following command:
sudo pecl install sphinx
The PECL command outputs the following:
running: phpize
Configuring for:
PHP Api Version: 20090626
Zend Module Api No: 20090626
Zend Extension Api No: 220090626
The versions above don't match the versions listed when doing a phpinfo(). It seems that PECL is trying to complie against the built-in version of PHP.
If I ignore the errors and continue the it will successfully compile and place the sphinx.so file in:
/usr/lib/php/extensions/no-debug-non-zts-20090626/sphinx.so
when in fact it should be:
/Applications/MAMP/bin/php5/lib/php/extensions/no-debug-non-zts-20060613/
I've tried copying the sphinx.so file to the MAMP extensions dir but when I restart apache PHP displays the following warning:
PHP Startup: Unable to load dynamic library '/Applications/MAMP/bin/php5/lib/php/extensions/no-debug-non-zts-20060613/sphinx.so
I think this is because MAMP is 32bit and the built-in PHP is 64bit so PECL complies for 64bit. I might be completely wrong but I did read this when I goggled on the topic.
Does anyone know how to get PECL to map to the MAMP version of PHP instead of the built-in version?
If the "correct" version of PHP is installed in something like /Applications/MAMP/bin/php5/, and has the development tools included, you should have some version of the pecl command to go with it, some next to that directory.
If so, running that pecl command that corresponds to your "correct" version of PHP should help : it'll run the correct version of phpize, and will allow the extension to be compiled against the (once again) correct version of PHP.
You just have to hope that MAMP includes those commands -- I cannot check, as I don't have a mac.

Categories