CentOS 7 with mpm event and php56u

While trying to reduce memory consumption by Apache on a low resource virtual private server, I stumbled on the Apache MPM Event module. Exciting discovery follows.

Back many years ago I successfully deployed multi-threaded Apache servers on Solaris using the HTTP server’s MPM worker module. In those days worker was implemented in its own discrete binary, httpd.worker, at compile time.

For many years subsequent to that Red Hat shipped both the standard prefork MPM as /usr/sbin/httpd and a worker MPM as /usr/sbin/httpd.worker.

As php grew in popularity its legendary instability on a threaded web server made many of us move back to MPM prefork. This especially on Linux where the php modules that shipped with various distributions, including Red Hat’s, were demonstrably not thread safe.

But times change, and software sometimes improves. Nowadays php can run on a threaded web server safely, and at least Red Hat’s implementation of Apache 2.4’s MPMs doesn’t require discrete binaries. On RHEL/CentOS 7, in fact, all you have to do is comment out the line that loads prefork and uncomment the line for one of the two optional threaded implementations.


# LoadModule mpm_prefork_module modules/mod_mpm_prefork.so
LoadModule mpm_event_module modules/mod_mpm_event.so

While MPM worker does a fine job as a threaded implementation, my reading of the Apache 2.4 documentation on the new event MPM led me to choose it for my low-power VPS project.

One wrinkle with using either threaded MPM is that they don’t play well with “older” versions of php. Specifically php 5.4.16 on RHEL/CentOS 7 was the cause of a nasty error message when I tried starting Apache back up:

AH00526: Syntax error on line 38 of /etc/httpd/conf.d/php.conf:
Invalid command 'php_value'...

Unsurprisingly, none of the “advice” I read on the Internet about how to resolve this issue was helpful.

Instead, after finding the switch worked just fine on Fedora 22, which ships with php 5.6, I decided to replace the system php to IUS Community’s php56u.

That done, Apache was able to start successfully and showed a remarkable reduction in the amount of RAM used.

Sometimes things work out in the end. Thankfully.

This entry was posted in System Administration, Systems Analysis, Web on by .

About phil

My name is Phil Lembo. In my day job I’m an enterprise IT architect for a leading distribution and services company. The rest of my time I try to maintain a semi-normal family life in the suburbs of Raleigh, NC. E-mail me at philipATlembobrothersDOTcom. The opinions expressed here are entirely my own and not those of my employers, past, present or future (except where I quote others, who will need to accept responsibility for their own rants).