How to force httpd to use rh-php56 from red hat software collections

17,230

Solution 1

rh-php56 provides mod_php only for httpd24 (not for base system)

Simpler way is to use php-fpm (which also allow to run apache in threaded mode)

See:

To summarize above post, use in /etc/httpd/conf.d/php.conf

# Redirect to local php-fpm is mod_php not available
<IfModule !mod_php5.c>
    <FilesMatch \.php$>
        SetHandler "proxy:fcgi://127.0.0.1:9000"
    </FilesMatch>
</IfModule>

Solution 2

Add the LoadModule command to your httpd.conf and point it to the php56 module from RHSCL:

LoadModule php5_module /opt/rh/httpd24/root/usr/lib64/httpd/modules/librh-php56-php5.so

This generally seems to work for me, but I have only tested basic page rendering. I wouldn't be surprised if there are some bugs related to loading a Special Collections module in the regular Apache config. After all, RH Special Collections packages intentionally install to a completely different part of the filesystem to avoid conflicts. You may want to consider using HTTPD24 from the RHSCL along with PHP56 to avoid configuration issues.

Share:
17,230
Mike Broyles
Author by

Mike Broyles

Updated on June 14, 2022

Comments

  • Mike Broyles
    Mike Broyles almost 2 years

    Anyone have any luck with making httpd use rh-php56 from the Red Hat Software Collections?

    I see documentation on how to enable the newer version of php at the CLI...but not for making Apache use the new version of PHP installed via the rh-php56 package.

    (I should clarify -- this is for a RHEL 7.x box)

  • Odyss3us
    Odyss3us over 8 years
    Have there been any new developments around this? I am struggling with the same problem on CentOS 7, not being able to have httpd make use of rh-php56. I'd prefer not to have to redirect requests through php-fpm, it seems wrong? Or am I just being too ocd about this...
  • Remi Collet
    Remi Collet over 8 years
    IMHO mod_php should die ;) FPM is much better for security (separate process), and for performance (allow to run apache in thread mode).