4

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.

0

3 Answers 3

7

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
  • 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, 2018 at 21:33
2

Nowadays, this package seems to be called php<majmin>-php. If you go looking for mod_php in the output of yum search, you'll turn up empty-handed.

For the example of PHP 8.2.x, after enabling the Remi repo, you get the Apache module by installing the following:

# this brings in php82-php-cli, php82-php-common, and php82-runtime
# as dependencies
sudo yum install php82

# then…
sudo yum install php82-php

Note that this will also attempt to bring httpd (the Apache web server) from the Remi repo, which may conflict with the installed httpd, and may be an out-of-date version with respect to what's available from e.g. the Software Collections Library.

Unfortunately, I don't have any specific advice for how to work around this, i.e, keep http24-http from SCL and use PHP from the Remi repo. Please suggest an edit if you do.

2
  • Wrong, there is no "httpd" in my repository. Jan 16 at 7:16
  • @RemiCollet OK, thanks, I'll look closer and update my answer.
    – Kevin E
    Jan 16 at 17:25
0

I followed this guide on how to install PHP 5.6 from the Remi repository on my Amazon Linux 2 instance.

Please, be aware that this is based on EL-7 which will be EOL in June.

So I heartily recommend using a more modern distribution (BTW, most won't have PHP 5.6 which is EOL for > 5 years)

For a proper repository configuration and usage, you should follow the Wizard instructions instead of some random HowTo found on the internet.

Especially, if you need a single version, you don't need the php56-* packages, designed for parallel installation of multiple versions, but rather the php-* package from the remi-php56 repository. As explained in the FAQ.

If you really need multiple versions, you can't use mod_php, but you have to use php-fpm instead (which is now used by default in EL-8 and EL-9)

If you want to use httpd24 SCL, you also need to use php-fpm (as mod_php is designed to work with default httpd).

You can read PHP Configuration Tips or My PHP Workstation

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .