1

We have two versions of PHP on our Linux CentOS6 machine, 5.3.3 and 5.6.7, and wanted to install PHP extensions, memcache and imagick, to 5.6.7.

Logged in as root, using yum, we installed both of these, but realised they were only usable in 5.3.3 and not in the latest version. This are the commands we used:

$ yum install ImageMagick ImageMagick-devel
$ pecl install imagick
$ echo "extension=imagick.so" > /etc/php.d/imagick.ini

We tried copying imagick.so and memcache.so from the old extension directory to 5.6.7's extension directory, but without any luck.

How do we install these extensions to our latest version, PHP 5.6.7? Or is there a way to resolve this without reinstalling anything?

Edit:

To install PHP 5.6.7, I used the steps given in this gist:

https://gist.github.com/Stayallive/dbb91ffa6f0fc6ca6ac3
  • The standard available RPMs from Centos will only be PHP 5.3.3. How did you get the 5.6.7 installed as well? Either you compiled from source yourself (in which case, to install the modules you would have to recompile with options for those modules enabled), or you got RPMs from a nonstandard repo which "should" also provide the RPMs for that new version. – Joe Apr 6 '15 at 15:33
  • @Joe - I have just update my question with the link to the gist I used for installing 5.6.7 - I compiled it myself. – PaparazzoKid Apr 6 '15 at 16:20
  • If that's the case, then Vaibhav Panmand's answer should work for you. The important piece being that you use the correct path to the phpize from 5.6.7, and then move the .so files into the 5.6.7 extensiondir – Joe Apr 6 '15 at 16:29
  • Thanks for your time, Joe. I followed the steps given by Vaibhav and all seemed to go perfectly fine until I checked phpinfo() and found the extension was still not there. I copied the .so file, checked php.ini for the extension, restarted httpd, but still nothing. – PaparazzoKid Apr 6 '15 at 18:55
  • your phpinfo() clearly shows it is the php 5.6.7? What folder does that phpinfo() state is the extensiondir? Are the exact (case-sensitive) file names in that dir? – Joe Apr 6 '15 at 19:13
2

You can build ImageMagick extension for latest version of PHP using below steps.

#cd imagemagick-x.x
#path_to_php_home_dir/bin/phpize
#./configure --with-imagick=/opt/imagemagick
#make
#make install

imagick.so will be build in module directory, now copy it to your extension path of php-5.6.7 instance.

MEMCACHE

#cd /usr/src/
#wget http://pecl.php.net/get/memcache-2.2.4.tgz
#tar -zxvf memcached-2.2.4.tgz
#cd memcached-2.2.4
#path_to_php_home_dir/bin/phpize && ./configure --enable-memcache && make

Now copy memcached extension from module directory to php extension directory

-- UPDATE

You need to specify correct extension_dir path in php.ini which is located at php_install_dir/lib/php.ini.

If php.ini not present then you have to copy php.ini.production from php_source_dir to php_install_dir/lib/ with name php.ini

php.ini parameter for extension dir

extension_dir=/php_install_dir/lib/php/extensions/no-debug-non-zts-20121212/

Also it can be possible that you have php.ini exists in your web application directory (/var/www/app_dir). In that case you have to make changes in both php.ini.

  • Thank you for taking the time to respond. I followed the steps you gave for the first extension, imagick. Everything installed perfectly ok, I copied the .so file to the php5.6.7's extension directory using the modules path that was given at the end of the install and restarted httpd. Phpinfo() doesn't show this extension and fails in an application with 'Fatal error: Class 'Imagick' not found in /var/www/.....'. I have added the extension to php.ini. Any ideas? – PaparazzoKid Apr 6 '15 at 18:40
  • You need to specify correct extension_dir path in php.ini which is located at php_install_dir/lib/php.ini. ----->>> extension_dir=/php_install_dir/lib/php/extensions/no-debug-non-zts-20121212/ – Vaibhav Panmand Apr 7 '15 at 5:23
1

how about using CentOS Software collections? Those are specifically designed for parallel version installs. I would also suggest getting familiar with the process of building those so that you can create your own if needed. Use Copr for build infrastructure as needed.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.