10

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)

Dominic Cleal
  • 3,205
  • 19
  • 22
Mike Broyles
  • 119
  • 1
  • 1
  • 8

3 Answers3

5

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>
Remi Collet
  • 6,198
  • 1
  • 20
  • 25
  • 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... – Odyss3us Jan 23 '16 at 01:11
  • 2
    IMHO mod_php should die ;) FPM is much better for security (separate process), and for performance (allow to run apache in thread mode). – Remi Collet Jan 23 '16 at 07:32
1

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.

GracefulCode
  • 141
  • 7
0

I just recently had to deal with upgrading to php56 for some PHP webapps on a RHEL 7 machine. I looked into the httpd24 route and for some reason it seems much simpler to just use the stock nginx RHEL package with rh-php56-php and rh-php56-php-fpm.

  1. Install the rh-php56-php packages you need
  2. enable and start the rh-php56-php-fpm systemd service and configure php-fpm in /etc/opt/rh/rh-php56/ (i.e., edit the php-fpm.conf and php-fpm.d/www.conf files). You'll need to decide if you want php-fpm to listen on a unix socket or via TCP at the minimum and it's also a good idea to configure logging properly to help troubleshoot.
  3. Configure nginx to proxy to your php-fpm unix socket or TCP address, e.g., localhost:9000. There's plenty of googleable resources on nginx configuration for php-fpm and Drupal / Mediawiki / Wordpress / etc.
A Lee
  • 7,828
  • 4
  • 35
  • 49