Apache Webserver, PHP, and Software Collections on RHEL7

The relatively short lifespan of PHP versions does not bode well with Extended Release Operating Systems like Red Hat Enterprise Linux and CentOS. The longevity of the OS is, perhaps, one of the most attractive features for server owners and Administrators. However, as with most things in life, there's always a trade-off. Extended Release Operating Systems provide a long "shelf life" and ongoing support and development for the most important part of a server. It's not surprising then that "bleeding edge" software isn't readily available in the default software repositories.

This creates a dilemma in the days of DevOps and increasing Internet penetration. Software Collections have made this type of scenario less problematic. Software Collections provides a repository for more recent, development versions of software that are always separated from the system-wide software installations of a server. This allows us, for example, to run different versions of PHP on the same system.

yum install httpd24-httpd php55{,-devel}

scl enable php55 /bin/bash

systemctl enable httpd24-httpd

The commands above install a newer version of the apache web-server into the "/opt/rh/httpd/" subdirectories. Then, the newer version of PHP is set as the version used by the system. Lastly, the apache web-server is enabled to automatically start.
Please note, the default DocumentRoot is not "/var/www/html" anymore; rather, it's "/opt/rh/httpd/root/var/www/html".

Additional steps


CentOS and RHEL don't have the httpd_sys_content_rw_t SELinux file context. Therefore, make sure the following SELinux booleans are enabled, though there might be a more precise way to accomplish this.
setsebool -P httpd_unified=1
setsebool -P httpd_builtin_scripting=1
setsebool -P httpd_enable_cgi=1

The last two booleans might already be enabled. The httpd_unified boolean allows the apache user, under which the webserver is running, to write to "httpd_sys_content_t"-labeled files and directories.

Apache Config

In case you are faced with repeated 404 errors, a blanket approach that might resolve this issue is to change AllowOverride None to AllowOverride All within the httpd.conf file.

Popular posts from this blog

Password Policy in RHEL 7

Centos 7 pulseaudio

EFF Announces Voting Registration Service