Docs

Introduction

LicenseDocker PullsDiscordSupport us

Run PHP in production without building the image yourself

A PHP container usually starts with the official image and an afternoon of setup. You add Composer and a few extensions. You wire up a web server, write a health check, and switch to a non-root user.

serversideup/php ships with that work done. It's built from the same source as the official PHP images. Your app runs the same way. You change settings with environment variables instead of editing config files.

The images are free and open source, maintained by Jay Rogers and Dan Pastori of Server Side Up.

The setup you'd otherwise do by hand

Unprivileged from the start.

Every image runs as www-data. Web servers listen on ports 8080 and 8443.

Settings live in your compose file.

Set PHP_MEMORY_LIMIT: "512M" or PHP_OPCACHE_ENABLE: "1" as an environment variable. There's no php.ini to mount.

The usual tools are already installed.

Composer, install-php-extensions, and common extensions like redis, pdo_pgsql, and zip come in every image.

Health checks and logs work anywhere.

Every image except cli has a built-in health check. All logs go to stdout and stderr.

Laravel prepares itself on startup.

Set AUTORUN_ENABLED: "true". The container runs storage:link, your migrations, and optimize before it starts serving.

Five ways to run PHP

The tag names the variation, as in serversideup/php:8.5-fpm-nginx.

VariationWhat runs in the container
cliPHP on the command line, for scripts, Composer, and CI.
fpmPHP-FPM on port 9000, behind a web server you run separately.
fpm-nginxPHP-FPM with NGINX, supervised by S6 Overlay.
fpm-apachePHP-FPM with Apache, supervised by S6 Overlay. Debian only.
frankenphpFrankenPHP, a PHP application server built on Caddy. PHP 8.3 and newer.

Each one is on Docker Hub and GitHub Packages, for amd64 and arm64. Every variation runs on Debian, and all but fpm-apache also run on Alpine. Choosing an image lists every PHP version and operating system.

Get running in three steps

  1. Add serversideup/php:8.5-fpm-nginx to your compose.yml.
  2. Set the PHP settings you need as environment variables.
  3. Run docker compose up.

The installation guide walks through each step with a working example.

Start the installation guide

New to containers? Read Container basics first. Coming from the official images? Follow Migrating from official PHP images.