Skip to content

Nginx + PHP-FPM Nginx + PHP-FPM

Description / nameInput element
Container Registry
Container Configuration Root Path
Timezone
User ID
Group ID
Nginx + PHP-FPM Host Port
Nginx + PHP-FPM /config Path

Build Status Last Commit OCI Pulls

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
Daemonless daemonless/nginx-php-fpm
Source php/php-src
Website www.php.net

Version Tags

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, including the security model for host vs. container privileges.

Deployment

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: always

Save as compose.yaml, then run podman-compose up -d.

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.

1
2
3
4
5
6
7
8
# .env

DIRECTOR_PROJECT=nginx-php-fpm
PUID=1000
PGID=1000
TZ=UTC
PHP_EXTENSIONS=
PHP_EXTENSIONS_EXTRA=
# 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}'
        - PHP_EXTENSIONS: !ENV '${PHP_EXTENSIONS}'
        - PHP_EXTENSIONS_EXTRA: !ENV '${PHP_EXTENSIONS_EXTRA}'
    volumes:
      - NGINX_PHP_FPM_CONFIG_PATH: /config
volumes:
  NGINX_PHP_FPM_CONFIG_PATH:
    device: '/containers/nginx-php-fpm'
1
2
3
4
5
6
7
# 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.

Experimental

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
      - PHP_EXTENSIONS=
      - PHP_EXTENSIONS_EXTRA=
    volumes:
      - "/containers/nginx-php-fpm:/config"

Save as bastille-compose.yml, then run bastille up.

Access at: http://localhost:80

Interactive Configuration

Parameters

Environment Variables

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

Volumes

Path Description
/config Web root (/config/www), nginx and PHP configuration

Ports

Port Protocol Description
80 TCP Web

Your site

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.

PHP settings

/config/php/php-local.ini is loaded after php.ini and holds the memory, upload and opcache settings. Edit it and restart the container.

Extensions

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

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

PHP versions

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.

Implementation Details

  • Architectures: amd64
  • User: bsd (UID/GID set via PUID/PGID). Defaults to 1000:1000.
  • Base: Built on ghcr.io/daemonless/base (FreeBSD 15.1).

Need help? Join our Discord community.