mirror of
https://github.com/coralhl/alpine-nginx-php8.git
synced 2026-10-27 08:43:09 +03:00
Lightweight Docker image for Nginx and PHP8
- Dockerfile 61%
- Shell 25.2%
- HTML 13.7%
| Filename | Latest commit message | Latest commit date |
|---|---|---|
| .github/workflows | ||
| config | ||
| web | ||
| .dockerignore | ||
| .gitattributes | ||
| .gitignore | ||
| 82.Dockerfile | ||
| 83.Dockerfile | ||
| 84.Dockerfile | ||
| 85.Dockerfile | ||
| LICENSE | ||
| README.md | ||
| start.sh | ||
Docker PHP-FPM 8 & Nginx on 🏔️ Alpine Linux
- Built on the lightweight and secure Alpine Linux distribution
- Small Docker image size (+/-60MB)
- Uses PHP 8 for better performance, lower CPU usage & memory footprint
- Optimized for ~20 concurrent users
- Optimized to use low amount of resources when there's no traffic (by using PHP-FPM's dynamic PM)
- The servers Nginx, PHP-FPM and supervisord run under a non-privileged user to make it more secure
- Follows the KISS principle (Keep It Simple, Stupid) to make it easy to understand and adjust the image to your needs
Tags: alpine-nginx-php8: latest, 8.5, 8.4, 8.3, 8.2
NOTE If you are upgrading from PHP 8.1 to 8.2 or from 8.2 to 8.3 or from 8.3 to 8.4 or from 8.4 to 8.5, you may need to run composer update to upgrade php packages, because some packages under 8.1/8.2 are not supported in 8.2/8.3 or 8.3/8.4 or 8.4/8.4
Includes
- bash
- dcron
- Composer
- GD2
- Various other extensions (like SimpleXML, see below)
- MySQL CLI
- PostgreSQL CLI
This image is built on GitHub actions and available on Docker Hub.
Usage
docker pull coralhl/alpine-nginx-php8/alpine-nginx-php8:latest
or
docker pull coralhl/alpine-nginx-php8/alpine-nginx-php8:php8.3
COMPOSE
services:
php82:
image: coralhl/alpine-nginx-php8:8.2
container_name: php82
environment:
TZ: Europe/Moscow
restart: always
DEFAULT SETTINGS
| Parameter | Value | Description |
|---|---|---|
user |
abc | user inside docker |
user's home |
/home/user | home directory of user abc |
www |
/var/www/html | webroot content directory (see WEBROOT) |
conf |
/var/www/html/conf | you can put your files nginx.conf and nginx-site.conf in this directory or your own config file |
scripts |
/var/www/html/scripts | this directory can contain your scripts that will be run when the container starts up |
supervisor logs |
/var/log/supervisor | supervisor logs is saved here by default |
nginx logs |
/var/log/nginx | nginx logs is saved here by default |
php logs |
/var/log/php | php logs is saved here by default |
ENVIRONMENT
| Parameter | Value | Default |
|---|---|---|
TZ |
Time Zone | Europe/Moscow |
PUID |
non-privileged user id | 1000 |
PGID |
non-privileged group id | 1000 |
WEBROOT |
for example /home/user/www |
/var/www/html |
CHOWN_WEBROOT |
1 (on) / - (off) | 0 (not chown WEBROOT) |
ERRORS |
1 (on) / - (off) | 0 (php_flag[display_errors] = off) |
PHP_ERRORS_STDERR |
1 (on) / - (off) | 0 (/var/log/php/error.log) |
PHP_MEM_LIMIT |
1024M | memory_limit = 128M |
PHP_POST_MAX_SIZE |
2048M | post_max_size = 100M |
PHP_UPLOAD_MAX_FILESIZE |
3072M | upload_max_filesize = 100M |
PHP_REDIS_SESSION_HOST |
192.168.1.10 | session.save_handler = files |
REAL_IP_HEADER |
1 (on) / - (off) | 0 (#real_ip_header X-Forwarded-For; #set_real_ip_from ) |
REAL_IP_FROM |
192.168.1.0/24 | - |
RUN_SCRIPTS |
1 (on) / - (off) | 0 (not launch scripts from /var/www/html/scripts/*) |
Configuration
In config/ you'll find the default configuration files for Nginx, PHP and PHP-FPM. If you want to extend or customize that you can do so by mounting a configuration file in the correct folder.
You may check start.sh for more information about what it can do.
PHP Modules
In this image it contains following PHP modules:
# php -m
[PHP Modules]
bcmath
Core
ctype
curl
date
dom
exif
fileinfo
filter
ftp
gd
hash
iconv
igbinary
imagick
imap
intl
json
libxml
mbstring
memcache
memcached
msgpack
mysqli
mysqlnd
openssl
pcntl
pcre
PDO
pdo_mysql
pdo_pgsql
pdo_sqlite
pgsql
Phar
posix
random
readline
redis
Reflection
session
SimpleXML
soap
sockets
sodium
SPL
sqlite3
standard
tokenizer
xml
xmlreader
xmlwriter
Zend OPcache
zip
zlib
[Zend Modules]
Zend OPcache