Skip to content

[RFC] enable thread safety (zts) for apache images; drop zts images #742

Open
@yosifkit

Description

@yosifkit

If we add --enable-maintainer-zts to the PHP_EXTRA_CONFIGURE_ARGS then all three Apache MPMs become available: prefork, worker, and event.

tests:

Apache will start with any of the three MPMs (used event as default).

diff --git a/apache-Dockerfile-block-1 b/apache-Dockerfile-block-1
index a8e0078..630d13c 100644
--- a/apache-Dockerfile-block-1
+++ b/apache-Dockerfile-block-1
@@ -29,9 +29,6 @@ RUN set -ex \
                && chown -R "$APACHE_RUN_USER:$APACHE_RUN_GROUP" "$dir"; \
        done
 
-# Apache + PHP requires preforking Apache for best results
-RUN a2dismod mpm_event && a2enmod mpm_prefork
-
 # logs should go to stdout / stderr
 RUN set -ex \
        && . "$APACHE_ENVVARS" \
@@ -56,4 +53,4 @@ RUN { \
        && a2enconf docker-php
 
 ENV PHP_EXTRA_BUILD_DEPS apache2-dev
-ENV PHP_EXTRA_CONFIGURE_ARGS --with-apxs2 --disable-cgi
+ENV PHP_EXTRA_CONFIGURE_ARGS --disable-cgi --enable-maintainer-zts --with-apxs2
$ docker run -it --rm df3a4c6a986d
AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 172.17.0.4. Set the 'ServerName' directive globally to suppress this message
AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 172.17.0.4. Set the 'ServerName' directive globally to suppress this message
[Sat Nov 10 00:37:02.664991 2018] [mpm_event:notice] [pid 1:tid 139860600038592] AH00489: Apache/2.4.25 (Debian) PHP/7.2.12 configured -- resuming normal operations
[Sat Nov 10 00:37:02.665019 2018] [core:notice] [pid 1:tid 139860600038592] AH00094: Command line: 'apache2 -D FOREGROUND'
^C[Sat Nov 10 00:37:03.766817 2018] [mpm_event:notice] [pid 1:tid 139860600038592] AH00491: caught SIGTERM, shutting down
$ docker run -it --rm df3a4c6a986d bash -c 'a2dismod mpm_event && a2enmod mpm_worker && exec docker-php-entrypoint apache2-foreground'
Module mpm_event disabled.
To activate the new configuration, you need to run:
  service apache2 restart
Considering conflict mpm_event for mpm_worker:
Considering conflict mpm_prefork for mpm_worker:
Enabling module mpm_worker.
To activate the new configuration, you need to run:
  service apache2 restart
AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 172.17.0.4. Set the 'ServerName' directive globally to suppress this message
AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 172.17.0.4. Set the 'ServerName' directive globally to suppress this message
[Sat Nov 10 00:37:13.585052 2018] [mpm_worker:notice] [pid 1:tid 140705571566784] AH00292: Apache/2.4.25 (Debian) PHP/7.2.12 configured -- resuming normal operations
[Sat Nov 10 00:37:13.585089 2018] [core:notice] [pid 1:tid 140705571566784] AH00094: Command line: 'apache2 -D FOREGROUND'
^C[Sat Nov 10 00:37:14.935140 2018] [mpm_worker:notice] [pid 1:tid 140705571566784] AH00295: caught SIGTERM, shutting down
$ docker run -it --rm df3a4c6a986d bash -c 'a2dismod mpm_event && a2enmod mpm_prefork && exec docker-php-entrypoint apache2-foreground'
Module mpm_event disabled.
To activate the new configuration, you need to run:
  service apache2 restart
Considering conflict mpm_event for mpm_prefork:
Considering conflict mpm_worker for mpm_prefork:
Enabling module mpm_prefork.
To activate the new configuration, you need to run:
  service apache2 restart
AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 172.17.0.4. Set the 'ServerName' directive globally to suppress this message
AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 172.17.0.4. Set the 'ServerName' directive globally to suppress this message
[Sat Nov 10 00:37:29.323216 2018] [mpm_prefork:notice] [pid 1] AH00163: Apache/2.4.25 (Debian) PHP/7.2.12 configured -- resuming normal operations
[Sat Nov 10 00:37:29.323244 2018] [core:notice] [pid 1] AH00094: Command line: 'apache2 -D FOREGROUND'
^C[Sat Nov 10 00:37:30.249286 2018] [mpm_prefork:notice] [pid 1] AH00169: caught SIGTERM, shutting down

We'll leave the default on the current mpm_prefork and note how to swap:

FROM php:7.2-apache
RUN a2dismod mpm_prefork && a2enmod mpm_event
# also a simple one line docker run:
# docker run ... php:7.2-apache bash -c 'a2dismod mpm_prefork && a2enmod mpm_event && exec docker-php-entrypoint apache2-foreground'

We should also be able to do away with the plain -zts variants, since the cli can still be found in the apache image.


What effect will this have on Apache mpm_prefork?

Should we later migrate to mpm_event?

Other questions, concerns?


notes:

  • this is unrelated to pthreads
  • maker of pthreads with some misconceptions: reddit

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions