Installing mod_php for Apache after installing Remi repo version of PHP 5.6
I followed this guide on how to install PHP 5.6 from the Remi repository on my Amazon Linux 2 instance. Now I need to connect that installation, which was placed in /opt/remi/php56/, to already installed apache that was previously using a different version of PHP, which I uninstalled.
How can I do this?
From what I understood, I can accomplish this with either CGI or mod_php. The old CGI folder was deleted when I uninstalled the other php version. I can't seem to find a way to find or install mod_php. When I type:
yum install mod_phpI am prompted to download the latest version of PHP from the Amazon repo. The guide I followed already installed a version of PHP that I want.
I've read many guides that just tell you to do:
yum install httpd phpAnd then just restart the Apache service, and everything works fine. That's how my first installation of the wrong PHP version went as well. Now I have to consider that I install a specific version of PHP from a specific repo which modifies the deployment location, and uninstalled PHP previously, which could have removed certain files.
11 Answer
When you run this command:
yum install mod_phpIt will automatically default to the Amazon repository.
So if you installed PHP 5.6 via Remi’s repo, you should use this command:
yum install php56-mod_phpNote that php56- prefix. That is the key to getting this working. This holds true for any extensions you install in the future.
That said, you might be better off uninstalling PHP the way you have and instead do this.
Go and use the Remi’s RPM repository configuration wizard located here. And follow those instructions.
Basically you should point to the correct repos, which I believe you have done. Then run this command.
sudo yum install yum-utilsThen run this command:
sudo yum-config-manager --enable remi-php56And then with that done, you can just install PHP 5.6 stuff the way you initially tried without worries:
yum install mod_phpNo need for a prefix!
2