Installing mod_php for Apache after installing Remi repo version of PHP 5.6
When you run this command:
yum install mod_php
It 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_php
Note 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-utils
Then run this command:
sudo yum-config-manager --enable remi-php56
And then with that done, you can just install PHP 5.6 stuff the way you initially tried without worries:
yum install mod_php
No need for a prefix!
Related videos on Youtube
Cohaven
Updated on September 18, 2022Comments
-
Cohaven over 1 year
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 installmod_php
. When I type:yum install mod_php
I 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 php
And 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.
-
Giacomo1968 over 5 yearsWhat is the RedHat/CentOS equivalent for Amazon OS? RedHat 6 or RedHat 7?
-
-
Cohaven over 5 yearsI did try the yum-config-manager --enable remi-php56 stuff, but yum still defaulted to the amazon repo in the following command. I'm thinking uninstalling httpd and php and then installing php again may solve the connectivity issue, as I think there is a dependency between them that yum picks up and sets the configs accordingly.
-
Giacomo1968 over 5 years@Cohaven Hope it works! If you found this answer helpful, please be sure to upvote it. If it’s the answer that solved your problem, please be sure to check it off as such.