Nginx with PHP-FPM, composer and the PHP extensions from ports, for running your own PHP sites.
| Port | 80 |
| Registry | ghcr.io/daemonless/nginx-php-fpm |
| Source | https://github.com/php/php-src |
| Website | https://www.php.net/ |
| Tag | Description | Best For |
|---|---|---|
85 / 85-pkg / latest / pkg |
FreeBSD Quarterly. Uses stable, tested packages. | Most users — recommended. |
85-pkg-latest / pkg-latest |
FreeBSD Latest. Rolling package updates. | Staying current. |
86 / 86-pkg |
FreeBSD Quarterly. Uses stable, tested packages. | Production stability. |
86-pkg-latest |
FreeBSD Latest. Rolling package updates. | Staying current. |
84 / 84-pkg |
FreeBSD Quarterly. Uses stable, tested packages. | Production stability. |
84-pkg-latest |
FreeBSD Latest. Rolling package updates. | Staying current. |
Before deploying, ensure your host environment is ready. See the Quick Start Guide for host setup instructions.
services:
nginx-php-fpm:
image: "ghcr.io/daemonless/nginx-php-fpm:latest"
container_name: nginx-php-fpm
environment:
- PUID=1000 # User ID for php-fpm workers and nginx workers
- PGID=1000 # Group ID for php-fpm workers and nginx workers
- TZ=UTC # Timezone, also used as PHP's date.timezone
# - PHP_EXTENSIONS= # Space-separated list of PHP extensions to enable; replaces the default set
# - PHP_EXTENSIONS_EXTRA= # Extensions to enable in addition to PHP_EXTENSIONS
volumes:
- "/containers/nginx-php-fpm:/config"
ports:
- "80:80"
# always (not unless-stopped) so FreeBSD's podman rc.d auto-starts it at boot
restart: alwaysSave as compose.yaml, then run podman-compose up -d.
.env:
# .env
DIRECTOR_PROJECT=nginx-php-fpm
PUID=1000
PGID=1000
TZ=UTC
appjail-director.yml:
# appjail-director.yml
options:
- virtualnet: ':<random> default'
- nat:
services:
nginx-php-fpm:
name: nginx_php_fpm
options:
- container: 'args:--pull'
- expose: '80:80 proto:tcp'
oci:
user: root
environment:
- PUID: !ENV '${PUID}'
- PGID: !ENV '${PGID}'
- TZ: !ENV '${TZ}'
volumes:
- nginx-php-fpm: /config
volumes:
nginx-php-fpm:
device: '/containers/nginx-php-fpm'Makejail:
# Makejail
ARG tag=latest
OPTION container=boot
OPTION overwrite=force
OPTION from=ghcr.io/daemonless/nginx-php-fpm:${tag}
Save the files above, then run appjail-director up.
Warning
Exposing ports in AppJail means that your service can be reached from remote hosts. If that is not your intention, do not expose the ports and communicate with the service using the jail's IPv4 address or hostname assigned by the virtual network.
To avoid exposing ports, just remove the expose option in your appjail-director.yml or from your command-line arguments.
Warning
Bastille's OCI support is experimental. It requires buildah and shares the host network stack (inherit). Mount volumes with --volume HOST JAIL; without it, image-declared volumes are stored under ${bastille_volumesdir}/${jail}.
services:
nginx-php-fpm:
name: nginx-php-fpm
image: "ghcr.io/daemonless/nginx-php-fpm:latest"
network:
- mode: host
environment:
- PUID=1000
- PGID=1000
- TZ=UTC
volumes:
- "/containers/nginx-php-fpm:/config"Save as bastille-compose.yml, then run bastille up.
Open http://<server>:80 from another machine (the server's own browser can't use a published port).
| Variable | Default | Description |
|---|---|---|
PUID |
1000 |
User ID for php-fpm workers and nginx workers |
PGID |
1000 |
Group ID for php-fpm workers and nginx workers |
TZ |
UTC |
Timezone, also used as PHP's date.timezone |
PHP_EXTENSIONS |
`` | Space-separated list of PHP extensions to enable; replaces the default set |
PHP_EXTENSIONS_EXTRA |
`` | Extensions to enable in addition to PHP_EXTENSIONS |
| Path | Description |
|---|---|
/config |
Web root (/config/www), nginx and PHP configuration |
| Port | Protocol | Description |
|---|---|---|
80 |
TCP | Web |
Put your PHP code in /config/www. On first start, when that directory is
empty, a welcome page is placed there showing the PHP version and the loaded
extensions. /config/nginx/site-confs/default.conf serves it; add more files
there for more sites. /config/nginx/nginx.conf and /config/php/www.conf
hold the nginx main config and the php-fpm pool. All of these are copied in
on first run and never overwritten afterwards.
/config/php/php-local.ini is loaded after php.ini and holds the memory,
upload and opcache settings. Edit it and restart the container.
The image ships every PHP extension in the FreeBSD ports tree except imagick, smbclient and enchant, whose dependencies would quadruple the image. By default these are enabled:
apcu bcmath bz2 ctype curl dom exif fileinfo filter gd iconv intl mbstring mysqli opcache pdo pdo_mysql pdo_pgsql pdo_sqlite pgsql phar posix session simplexml tokenizer xml xmlreader xmlwriter zip zlib
Set PHP_EXTENSIONS to replace that list, or PHP_EXTENSIONS_EXTRA to add to
it, for example PHP_EXTENSIONS_EXTRA=redis soap ldap. Extensions not in the
image are reported in the container log at start. json and openssl are built
into PHP and always available.
Composer is installed. Run it as the bsd user so the files it writes stay
owned by your PUID:
podman exec -u bsd nginx-php-fpm composer install -d /config/www
Tags 86, 85 and 84 pick the PHP version; latest is PHP 8.5. Each
has a -pkg-latest variant built from the FreeBSD latest package branch.
Newer PHP versions ship fewer extensions until the pecl ports catch up; the
welcome page lists what is loaded.
Architectures: amd64
User: bsd (UID/GID via PUID/PGID, defaults to 1000:1000)
Base: FreeBSD 15.1
Need help? Join our Discord community.