Image Variations

FPM-Apache

The fpm-apache variation runs Apache and PHP-FPM in one container, supervised by S6 Overlay. Choose it when your app depends on .htaccess files or Apache modules, as WordPress and many older PHP apps do. Compare every variation →

At a glance

fpm-apache
ProcessesApache (event MPM) and PHP-FPM, supervised by S6 Overlay
Ports8080 (HTTP), 8443 (HTTPS)
Stop signalSIGQUIT
Default health checkcurl to http://localhost:${APACHE_HTTP_PORT}${HEALTHCHECK_PATH} (/healthcheck by default)
Webroot variableAPACHE_DOCUMENT_ROOT (default /var/www/html/public)
PHP versions8.1 to 8.6
Operating systemsDebian only. There is no Alpine build.

Requests flow the same way as in fpm-nginx, with Apache in place of NGINX. One difference: Apache has no built-in rule that sends unknown paths to index.php. Your app's .htaccess does that, such as the one Laravel ships in public/.htaccess. Without it, routes other than real files return 404.

Quick start

Put your app's public files in public/, which is the default document root:

compose.yml
services:
  php:
    image: serversideup/php:8.5-fpm-apache
    ports:
      - "80:8080"
    volumes:
      - ./:/var/www/html

Run docker compose up and open http://localhost. Mounting your code like this is for development. In production, copy the code into your own image instead; see packaging your app for deployment. For a WordPress setup with a database, see using WordPress with Docker.

Configuration

These variables are specific to this variation. Defaults and the full list, including every PHP_* and PHP_FPM_* option, are in the environment variable specification.

To changeSet
Document rootAPACHE_DOCUMENT_ROOT
Listening portsAPACHE_HTTP_PORT, APACHE_HTTPS_PORT
Apache worker threadsAPACHE_START_SERVERS, APACHE_MIN_SPARE_THREADS, APACHE_MAX_SPARE_THREADS, APACHE_THREAD_LIMIT, APACHE_THREADS_PER_CHILD, APACHE_MAX_REQUEST_WORKERS, APACHE_MAX_CONNECTIONS_PER_CHILD
Maximum upload sizePHP_UPLOAD_MAX_FILE_SIZE and PHP_POST_MAX_SIZE

Customize Apache

The default configuration adds security headers, hides the Apache version, turns off TRACE, blocks dotfiles (except /.well-known/), PHP files under /storage/, and WordPress's xmlrpc.php. You can add rules in two places.

.htaccess for per-directory rules

AllowOverride All is set on the document root. Your .htaccess files work as they would on any Apache host and apply without a restart.

conf-enabled for server-wide rules

Files in /etc/apache2/conf-enabled/ ending in .conf load before the virtual hosts and apply to every site and port. This example redirects an old URL and limits /admin to a private network:

custom.conf
Redirect permanent /old-pricing /pricing

<Location "/admin">
    Require ip 10.0.0.0/8
</Location>
services:
  php:
    image: serversideup/php:8.5-fpm-apache
    ports:
      - "80:8080"
    volumes:
      - ./:/var/www/html
      - ./custom.conf:/etc/apache2/conf-enabled/custom.conf:ro

The image's own rules are in conf-enabled/performance.conf, remoteip.conf, security.conf, and serversideup.conf. A file with the same name replaces the image's file.

Replace a site

Each SSL_MODE has its own virtual host file in /etc/apache2/sites-available/: ssl-off.conf, ssl-mixed.conf, and ssl-full.conf. Mount your own file over the one for your mode to replace it. You then own the health check route and the PHP handler. Start from a copy of the image's files.

Health checks

PHP-FPM answers the /healthcheck route. The default health check fails if either Apache or PHP-FPM is down. Set HEALTHCHECK_PATH=/up to check Laravel's health route instead. Health checks covers timing and orchestrators. Laravel health checks covers /up and worker containers.

SSL

SSL_MODE=mixed serves HTTP on 8080 and HTTPS on 8443. SSL_MODE=full serves HTTPS on 8443 and redirects HTTP on 8080 to it. The image generates a self-signed certificate unless you provide one. See configuring SSL.