Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Heroku - AH00534: apache2: Configuration error: More than one MPM loaded. #293

Closed
dahankzter opened this issue Mar 27, 2018 · 12 comments

Comments

@dahankzter
Copy link

@dahankzter dahankzter commented Mar 27, 2018

When I create a simple Dockerfile:

FROM wordpress:4.9.4-php7.2-apache
COPY --chown=www-data:www-data "plugins/" "/usr/src/wordpress/wp-content/plugins/"

It runs just fine locally and everything is nice and dandy but pushing it to Heroku fails when apache is starting.

The container dies to fast to go in and have a look at which modules are actually loaded.

Any ideas? Does anyone knows which modules are actually needed or what can fails in the scripts here.
Note that before the error the message Complete! WordPress has been successfully copied to /var/www/html is printed which seems to indicate the actual wp setup is successful.

@dahankzter

This comment has been minimized.

Copy link
Author

@dahankzter dahankzter commented Mar 28, 2018

We had to switch to the buildpack, no time to sort this.

@dahankzter dahankzter closed this Mar 28, 2018
@njam

This comment has been minimized.

Copy link

@njam njam commented Jun 7, 2018

I was investigating this issue today with @fresswolf
What we found is that Heroku is doing something very strange with docker images that contain apache. It seems that before the container is started Heroku is injecting some files into the folde /etc/apache2/.

The "php" docker image is enabling the module "mpm_prefork", and thus creates the file /etc/apache2/mods-enabled/mpm_prefork.load. Heroku later injects its own set of configuration files which includes the file /etc/apache2/mods-enabled/mpm_event.load. We end up with 2 mpm modules loaded, which makes apache fail.

We opened a support ticket with Heroku about it.


Steps to reproduce:

  1. Create a Dockerfile with apache installed, but the whole folder /etc/apache2/ removed. When the container is started it will list the contents of `/etc/apache2/
FROM debian:stretch-slim

RUN apt-get update && apt-get install -qy apache2
RUN rm -rf /etc/apache2

ENTRYPOINT []
CMD ["find", "/etc/apache2"]
  1. Build and run it locally. Obviously the folder is empty:
$ docker build -t test .
$ docker run --rm test
/etc/apache2/mods-enabled/:
total 0
  1. Create a Heroku app, then push the image to the registry:
$ docker tag test registry.heroku.com/<app-name>/web
$ docker push registry.heroku.com/<app-name>/web
$ heroku container:release -a <app-name> web
$ heroku logs -ta <app-name>
2018-06-07T18:05:20.749367+00:00 heroku[web.1]: Starting process with command `find /etc/apache2`
2018-06-07T18:05:22.413759+00:00 app[web.1]: /etc/apache2
2018-06-07T18:05:22.413777+00:00 app[web.1]: /etc/apache2/conf-enabled
2018-06-07T18:05:22.413779+00:00 app[web.1]: /etc/apache2/conf-enabled/serve-cgi-bin.conf
2018-06-07T18:05:22.413780+00:00 app[web.1]: /etc/apache2/conf-enabled/localized-error-pages.conf
2018-06-07T18:05:22.413782+00:00 app[web.1]: /etc/apache2/conf-enabled/other-vhosts-access-log.conf
2018-06-07T18:05:22.413783+00:00 app[web.1]: /etc/apache2/conf-enabled/security.conf
2018-06-07T18:05:22.413784+00:00 app[web.1]: /etc/apache2/conf-enabled/charset.conf
2018-06-07T18:05:22.413785+00:00 app[web.1]: /etc/apache2/magic
2018-06-07T18:05:22.413786+00:00 app[web.1]: /etc/apache2/ports.conf
2018-06-07T18:05:22.413788+00:00 app[web.1]: /etc/apache2/sites-available
2018-06-07T18:05:22.413789+00:00 app[web.1]: /etc/apache2/sites-available/000-default.conf
2018-06-07T18:05:22.413790+00:00 app[web.1]: /etc/apache2/sites-available/default-ssl.conf
2018-06-07T18:05:22.413792+00:00 app[web.1]: /etc/apache2/mods-available
2018-06-07T18:05:22.413793+00:00 app[web.1]: /etc/apache2/mods-available/session_dbd.load
2018-06-07T18:05:22.413794+00:00 app[web.1]: /etc/apache2/mods-available/mime_magic.conf
[...]

The files are magically there again.

@kfigiela

This comment has been minimized.

Copy link

@kfigiela kfigiela commented Jun 19, 2018

@njam, any response from Heroku on this issue?

@njam

This comment has been minimized.

Copy link

@njam njam commented Jun 19, 2018

Yes! Actually they developed a fix, but haven't rolled it out globally yet.
You can enable the fix for a specific application with:

heroku labs:enable --app=YOUR-APP runtime-new-layer-extract
@kfigiela

This comment has been minimized.

Copy link

@kfigiela kfigiela commented Jun 19, 2018

Thank you for quick response!

@rharish101

This comment has been minimized.

Copy link

@rharish101 rharish101 commented Nov 2, 2018

It doesn't work in my case. On applying the new fix, it gives me: (13)Permission denied: AH00072: make_sock: could not bind to address [::]:80.
This is my Dockerfile:

FROM php:7.2-apache
RUN apt-get update && apt-get install -y python3
RUN ln -s /etc/apache2/mods-available/rewrite.load /etc/apache2/mods-enabled/rewrite.load
COPY src/ /var/www/html/
@njam

This comment has been minimized.

Copy link

@njam njam commented Nov 2, 2018

@rharish101

The web process must listen for HTTP traffic on $PORT, which is set by Heroku.

https://devcenter.heroku.com/articles/container-registry-and-runtime#dockerfile-commands-and-runtime

@ovifrisch

This comment has been minimized.

Copy link

@ovifrisch ovifrisch commented Jul 13, 2019

@rharish101 did you find a fix?

@rharish101

This comment has been minimized.

Copy link

@rharish101 rharish101 commented Jul 13, 2019

Yeah, I just had to listen to HTTP traffic on $PORT, as pointed out by njam.

@arniwesth

This comment has been minimized.

Copy link

@arniwesth arniwesth commented Oct 27, 2019

Yeah, I just had to listen to HTTP traffic on $PORT, as pointed out by njam.

How exactly did you do this? I tried something like:

RUN sed -i 's/Listen 80/Listen $PORT/g' /etc/apache2/ports.conf

but this does not work (it just changes 80 to $PORT in ports.conf).

@rharish101

This comment has been minimized.

Copy link

@rharish101 rharish101 commented Oct 27, 2019

@arniwesth It seems like the $PORT environment variable isn't being expanded here. Try replacing the single-quotes with double-quotes, as follows:

RUN sed -i "s/Listen 80/Listen $PORT/g" /etc/apache2/ports.conf
@arniwesth

This comment has been minimized.

Copy link

@arniwesth arniwesth commented Oct 27, 2019

@rharish101 Thx for your reply. Unfortunately, it does not make a difference.

I gave up and ditched Docker for this app.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
6 participants
You can’t perform that action at this time.