0

I'm using CentOS 7. I wanted to install PHP 7 so I used remi-php (latest PHP version of yum is 5.4). Since the HTTPD version of yum is too old, I compiled the latest HTTPD version from the source code.

HTTPD compilation goes perfectly, however, when I try to install remi-php using the following command:

yum --enablerepo=remi-php71 install php php-cli php-intl php-mbstring php-mcrypt php-mysqlnd

To install php, yum will also install the old version of httpd (although I have compiled and used the latest HTTPD version). If I continue with the installation, my HTTPD will throw an error (and won't start), but if I don't continue with the installation, I won't have the php*.so file and apache won't parse the .php files.

So, how do I install php without affecting the Apache HTTPD that I have compiled before? I don't want my server to have two instances of Apache HTTPD at the same time and may have problems in the future.

Your answer given will be very helpful to me.

I will appreciate your answer.

3
  • Why did you manually compile httpd rather than use the actual yum package?
    – Shadur
    Jul 29, 2021 at 16:28
  • @Shadur httpd version on centos 7 when using my yum is 2.4.6-97 and php is 5.4.16-48. Do you think it's safe? Jul 29, 2021 at 16:55
  • ... Good bloody grief. Update your centos install to 8.x ASAP. No wonder you're getting errors, your entire install is WAY out of date.
    – Shadur
    Jul 30, 2021 at 6:13

2 Answers 2

1

I suggest using Software Collections (SCL) instead. It provides supported versions of PHP (up to 7.3) and HTTPd (2.4), at least until CentOS 7 reaches end-of-life in 2024. First, install the repos for SCL:

yum install centos-release-scl centos-release-scl-rh

You can then install the SCL versions of PHP and HTTPd:

yum install httpd24 rh-php73

This will pull in the basic dependencies required. To install the additional PHP modules you mentioned below, the package names will be prefixed with rh-php73:

yum install rh-php73-php-cli rh-php73-php-intl rh-php73-php-mbstring rh-php73-php-mysqlnd

I wasn't able to find an SCL version of php-mcrypt for 7.3, so you may need to find a way to build that one on your own. However, it was marked as deprecated in PHP 7.1, and was to be removed from PHP core in 7.2, so this is probably to be expected. The PHP project recommends the following alternatives:

  • Use OpenSSL. Support for this is included with rh-php73-php-common, which will get installed automatically as a dependency.
  • Use Sodium. This requires an additional package, sclo-php73-php-sodium.

Once you have everything installed, you'll discover that the configuration files are not in their usual locations. This is because SCL packages are designed to allow side-by-side installation with the primary packages.

Default Path SCL Path
/etc/httpd /opt/rh/httpd/root/etc/httpd
/etc/php.ini /etc/opt/rh/rh-php73/php.ini
/etc/php.d /etc/opt/rh/rh-php73/php.d
/var/log/httpd /var/log/httpd24

When you're ready to start up HTTPd, the service is also named differently:

systemctl --now enable httpd24-httpd.service

Finally, with respect to version numbers, keep in mind that almost everything from CentOS 7 derives directly from RHEL 7. Even though the version numbers themselves may be slightly out of date, patches to later versions are frequently backported into them. The idea is to maintain ABI stability while still providing necessary bug and security fixes.

1
  • 1
    I think I will use your way. Thanks! Jul 29, 2021 at 17:05
0

You will either have to compile your own PHP like you did with Apache HTTPd, or use the packaged version in Centos7 (which works just fine with Remi’s php7 packages).

Installing random stuff outside of yum won’t inform the package database. You could create a package for your new httpd, but I would really suggest you use the httpd in CentOS, since it should still get severe security updates.

Keep in mind that anything you compile now becomes your responsibility, you have to keep track of vulnerabilities and compile new versions each time there is a new CVE. And if the new version breaks your site, you’ll have to figure out why and update your code. It’s a lot of work.

7
  • The current yum httpd version is httpd 2.4.9 while the latest version is currently 2.4.48. It's too old! Jul 29, 2021 at 13:30
  • @TầnQuảng why do you think it is too old? What features are you missing?
    – jsbillings
    Jul 29, 2021 at 14:08
  • The latest version is 2.4.48, it includes many security patches and supports OpenSSL 1.1.1. Jul 29, 2021 at 14:14
  • @TầnQuảng Security patches are back-ported into REL/CentOS packages. You can check the release notes for specific CVE numbers. What features in OpenSSL 1.1.1 are you looking for?
    – doneal24
    Jul 29, 2021 at 14:41
  • @TầnQuảng A lot of people get confused by RHEL versioning. If you'd like to look at the RPM Changelog (without actually using RHEL), the spec file is hosted in CentOS's Git tree: git.centos.org/rpms/httpd/blob/c7/f/SPECS/httpd.spec#_937 .
    – jsbillings
    Jul 29, 2021 at 19:32

You must log in to answer this question.

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