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 | |
|---|---|
| Processes | Apache (event MPM) and PHP-FPM, supervised by S6 Overlay |
| Ports | 8080 (HTTP), 8443 (HTTPS) |
| Stop signal | SIGQUIT |
| Default health check | curl to http://localhost:${APACHE_HTTP_PORT}${HEALTHCHECK_PATH} (/healthcheck by default) |
| Webroot variable | APACHE_DOCUMENT_ROOT (default /var/www/html/public) |
| PHP versions | 8.1 to 8.6 |
| Operating systems | Debian 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:
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 change | Set |
|---|---|
| Document root | APACHE_DOCUMENT_ROOT |
| Listening ports | APACHE_HTTP_PORT, APACHE_HTTPS_PORT |
| Apache worker threads | APACHE_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 size | PHP_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:
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
FROM serversideup/php:8.5-fpm-apache
COPY custom.conf /etc/apache2/conf-enabled/
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.