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
PaparazzoKid
  • 332
  • 1
  • 3
  • 15
  • 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 06 '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 06 '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 06 '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 06 '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 06 '15 at 19:13
  • Yes, it shows 5.6.7 and shows php.ini changes too. The installation said the extension was in `/usr/lib64/php/modules/`, so ran `cp /usr/lib64/php/modules/imagick.so /php/php-5.6.7/lib/php/extensions/no-debug-non-zts-20131226/imagick.so` which is where phpinfo says my extension directory is under `extension_dir` variable. I also tried copying it from the modules directory `cp /root/imagick-3.1.1/modules/imagick.so /php/php-5.6.7/lib/php/extensions/no-debug-non-zts-20131226/imagick.so`. Before I did this, the 5.6.7 extension directory was empty, and so checked there was a file there after copy – PaparazzoKid Apr 06 '15 at 20:20
  • I meant the new extension directory didn't have imagick.so before copying the extension and did after. It wasn't empty. – PaparazzoKid Apr 06 '15 at 20:33
  • if you have `extension=imagick.so` in php.ini and the file is in the right place, it should load it. If phpinfo() still doesn't show it, then there should be a error_log somewhere showing why. Either the apache error_log location, or a error_log file in the location the phpinfo() was run are most likely places – Joe Apr 06 '15 at 20:48
  • Another cause of concern, is for one of our hosted websites in Plesk, I chose that it used 5.6.7 - this probably means that pre-existing websites and new ones I add will default at 5.3.3. Now, logging in as root - which is how I installed extensions - I run `php -v` and it tells me 5.3.3 is being used. Is 5.3.3 being the default version causing this problem I'm seeing? – PaparazzoKid Apr 06 '15 at 21:28
  • It is highly likely that having both installed is leading to the confusion. That's why I asked to check the files and everything are all in the 5.6.7 sections – Joe Apr 06 '15 at 21:39
  • Have you followed this document for Plesk with multiple versions of PHP: http://download1.parallels.com/Plesk/Doc/en-US/online/plesk-administrator-guide/index.htm?fileName=72042.htm Once this is setup properly, you should be able to change each accounts version between the two as appropriate – Joe Apr 06 '15 at 21:41

2 Answers2

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.

Vaibhav Panmand
  • 1,038
  • 7
  • 17
  • 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 06 '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 07 '15 at 05: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.

Droopy4096
  • 680
  • 4
  • 8