Installed PHP extensions to wrong PHP version

General Tech Bugs & Fixes 2 years ago

0 1 0 0 0 tuteeHUB earn credit +10 pts

5 Star Rating 1 Rating

Posted on 16 Aug 2022, this text provides information on Bugs & Fixes related to General Tech. Please note that while accuracy is prioritized, the data presented might not be entirely correct or up-to-date. This information is offered for general knowledge and informational purposes only, and should not be considered as a substitute for professional advice.

Take Quiz To Earn Credits!

Turn Your Knowledge into Earnings.

tuteehub_quiz

Answers (1)

Post Answer
profilepic.png
manpreet Tuteehub forum best answer Best Answer 2 years ago

 

I just bought a VPS and it came with PHP5.3.3 and that wasn't good for our website, so I successfully (so it seemed, anyway) installed PHP5.6.7 and successfully registered it with Plesk.

For the website in question, I chose 5.6.7 in Plesk's hosting settings and everything worked fine. I can see by looking at phpinfo() that the correct version is being used.

After I was happy with that, I went on to install imagick and memcache, two other extensions needed for our site. Both seemed to install fine without any errors and added the extensions to the correct php.ini file (getting the correct path from phpinfo) and restarted apache:

extension=memcache;
extension=imagick;

$ service httpd restart

This is where I see things going wrong. I check phpinfo and the extensions are not visible, and I confirm this in my application:

if (extension_loaded('imagick')) {
    echo 'IMagick extension loaded okay.';
} else {
    echo 'IMagick extension not loaded! Meh!';
}

I then ran this command to find out which folder was being used for extensions:

$ php-config --extension-dir

It returns:

/usr/lib64/php/modules

But when I check my phpinfo for extensions_dir it that has this:

/php/php-5.6.7/lib/php/extensions/no-debug-non-zts-20131226

I then investgated more by seeing which of these extension directories had an imagick.soextension; /usr/lib64/php/modules had the extension but the directory phpinfo is saying it should be in doesn't have the extension. I also confirmed this by going into Plesk and switching back to 5.3.3 and checked what phpinfo said. Both the extensions I installed were listed and worked fine! It installed ok, but for the wrong PHP version it seems.

I thought I would try copying the extension from where it is, to where it should be:

$ cp /usr/lib64/php/modules/imagick.so /php/php-5.6.7/lib/php/extensions/no-debug-non-zts-20131226/imagick.so

And tested that the file existed in the new folder before restarting httpd - but again, without any luck.

It's very clear that the extensions, and possibly the modules, were installed into PHP5.3.3 directories, and not 5.6.7, but how did it happen? Should I have changed into cd /php/php-5.6.7 directory first and then ran the install commands? These are similar commands I used to install imagick, right after logging in as root:

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

Can somebody very kindly share with me the commands needed to run a fresh, new imagick install, but to the correct PHP version? Or maybe share a way to easily fix the problem as it is?

I really appreciate any help to get me over the line on this problem.

This is the GIST I used for installing PHP5.6.7, in case that helps:

https://gist.github.com/Stayallive/dbb91ffa6f0fc6ca6ac3

No matter what stage you're at in your education or career, TuteeHub will help you reach the next level that you're aiming for. Simply,Choose a subject/topic and get started in self-paced practice sessions to improve your knowledge and scores.