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_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.

  • What is the RedHat/CentOS equivalent for Amazon OS? RedHat 6 or RedHat 7? – JakeGould Nov 6 '18 at 21:59

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!

  • 1
    I 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. – Cohaven Nov 6 '18 at 21:33
  • @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. – JakeGould Nov 7 '18 at 0:04

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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