Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

docker/httpd: Configuration error: No MPM loaded

Tags:

docker

apache

I have a docker container based in the httpd official image. From nowhere (after a new build), it started failing with the error:

AH00534: httpd: Configuration error: No MPM loaded.

Nothing else.

I'm using the official httpd image (FROM httpd:2.4) and everything was working fine until now.
The error appeared only after pruning all images in my system with a docker system prune -af

like image 926
Tiago Carreira Avatar asked Jan 30 '18 15:01

Tiago Carreira


4 Answers

(edit, thanks delboy1978uk) The error could be avoided if applied a simple best practice: pin your docker images to a specific version instead of latest.


After digging the commits of the official httpd image, I found the solution. (maybe this question/answer may help others)

For those who stumble onto this note while looking for a solution, just add LoadModule mpm_event_module modules/mod_mpm_event.so into httpd.conf above the other LoadModule directives.

(from the comments on the commit #17166574)

So, because I was overriding the file /usr/local/apache2/conf/httpd.conf without explicitly declare an MPM module, after this commit, my image started to fail.
With this quick fix, everything is fine now.

For the complete correction, add this to your httpd.conf file (thanks svinther):

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

or, for a more future-proof solution, you could modify the original http.conf file using sed.

like image 113
Tiago Carreira Avatar answered Nov 11 '22 03:11

Tiago Carreira


After comparing my configuration with latest httpd:2.4 configuration, I found that these new lines needed to be merged into conf/httpd.conf

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

Note to self: When building the derivative httpd docker image, it would probably be better to mod the conf files with sed, than to just COPY in a static file

like image 9
svinther Avatar answered Nov 11 '22 02:11

svinther


If you are using Docker for Windows, you might be running into a File conversion issue. Be sure to check the encoding of your httpd.conf, it should be Unix LF - UTF8.

like image 6
philippn Avatar answered Nov 11 '22 02:11

philippn


Much as the accepted solution works, it is less than ideal. The real reason you are getting this error is most likely the fact that your Dockerfile begins with the following line:

FROM httpd:latest

That latest part, is you asking for the latest and greatest version of Apache.

Don't do that. This is your infrastructure. Lock it down to a version number.

Something like

FROM apache:2.4.0

This is the real answer. Not doing that risks your own codebase failing when third party software vendors update their code.

Get the latest version of httpd.conf, and take a note of the version number, then tweak it with your changes, and get that :latest the hell out of your Dockerfile.

like image 4
delboy1978uk Avatar answered Nov 11 '22 04:11

delboy1978uk