About
NGINX, PHP and Nginx RTMP Module Docker image based on Alpine Linux.
Features
- Run as non-root user
- Multi-platform image
- Latest NGINX with latest PHP 8.1 from
Alpine
repository - Latest Nginx Headers Module
- Latest Nginx RTMP Module for live streaming support
Supported platforms
- linux/amd64
- linux/arm64
- linux/arm/v7
Usage
Docker Compose
Docker compose is the recommended way to run this image. Edit the compose file with your preferences and run the following command:
git clone https://github.com/k44sh/nginx-php.git
mkdir {config,data}
docker-compose up -d
docker-compose logs -f
Upgrade
To upgrade, pull the newer image and launch the container:
docker-compose pull
docker-compose up -d
Command line
You can also use the following minimal command:
docker run -d --name nginx-php \
--ulimit nproc=65535 \
--ulimit nofile=32000:40000 \
-p 80:8080 \
-p 1935:1935 k44sh/nginx-php:latest && \
docker logs -f nginx-php
Configuration
Environment variables
TZ
: The timezone assigned to the container (defaultUTC
)PUID
: User id (default1000
)PGID
: User group id (default1000
)MEMORY_LIMIT
: PHP memory limit (default512M
)UPLOAD_MAX_SIZE
: Upload max size (default16M
)CLEAR_ENV
: Clear environment in FPM workers (defaultyes
)OPCACHE_MEM_SIZE
: PHP OpCache memory consumption (default256
)MAX_FILE_UPLOADS
: The maximum number of files allowed to be uploaded simultaneously (default50
)
RTMP (Streaming)
/var/www/default/stream/play.php
: Internal authentication to add an authentication when publishing a stream/var/www/default/stream/publish.php
: Internal authentication to add authentication to watch a stream
// Accounts
$accounts = array(
0 => array(
"name" => "user1",
"pass" => "xxxxxxxxxxxxxxxx"
),
[...]
You can configure OBS like this:
- Server Example:
rtmp://192.168.1.1/stream
- Key Example:
user1?name=user1&key=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
You can watch a stream like this:
- Network URL:
rtmp://192.168.1.1/stream/user1?name=user1&pass=xxxxxxxxxxxxxxxx
If you want remove authentication, just comment the following directives in nginx.conf
:
on_publish
http://127.0.0.1:8080/stream/publish.php;on_play
http://127.0.0.1:8080/stream/play.php;
Documentation: https://github.com/arut/nginx-rtmp-module/wiki/Directives