├── Dockerfile ├── README.md └── files ├── nginx.conf ├── php-fpm.conf └── run.sh /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM alpine:edge 2 | MAINTAINER Christoph Wiechert 3 | 4 | RUN apk update \ 5 | && apk add bash nginx ca-certificates \ 6 | php-fpm php-json php-zlib php-xml php-pdo php-phar php-openssl \ 7 | php-pdo_mysql php-mysqli \ 8 | php-gd php-iconv php-mcrypt 9 | 10 | # fix php-fpm "Error relocating /usr/bin/php-fpm: __flt_rounds: symbol not found" bug 11 | RUN apk add -u musl 12 | RUN rm -rf /var/cache/apk/* 13 | 14 | ADD files/nginx.conf /etc/nginx/ 15 | ADD files/php-fpm.conf /etc/php/ 16 | ADD files/run.sh / 17 | RUN chmod +x /run.sh 18 | 19 | 20 | EXPOSE 80 21 | VOLUME ["/DATA"] 22 | 23 | CMD ["/run.sh"] -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # PHP-FPM & Nginx Docker Image 2 | 3 | Lightwight Docker image for the (latest) PHP-FPM and Nginx based on [AlpineLinux](http://alpinelinux.org) 4 | 5 | * Image size only ~100MB ! 6 | * Very new packages (alpine:edge) 2015-04-03: 7 | * [PHP](http://pkgs.alpinelinux.org/package/main/x86/php) 5.6.7 8 | * [Nginx](http://pkgs.alpinelinux.org/package/main/x86/nginx) 1.6.2 9 | 10 | 11 | ### Usage 12 | ```bash 13 | sudo docker run -v /data:/DATA -p 80:80 psitrax/php-nginx 14 | ``` 15 | 16 | ### Volume structure 17 | 18 | * `htdocs`: Webroot 19 | * `logs`: Nginx/PHP error logs 20 | -------------------------------------------------------------------------------- /files/nginx.conf: -------------------------------------------------------------------------------- 1 | # run nginx in foreground 2 | daemon off; 3 | 4 | error_log /DATA/logs/nginx/nginx-error.log warn; 5 | pid /var/run/nginx.pid; 6 | worker_processes 5; 7 | events { 8 | worker_connections 4096; 9 | } 10 | 11 | http { 12 | sendfile on; 13 | include /etc/nginx/mime.types; 14 | include /etc/nginx/fastcgi.conf; 15 | default_type application/octet-stream; 16 | tcp_nopush on; 17 | client_body_temp_path /tmp/nginx/body 1 2; 18 | fastcgi_temp_path /tmp/nginx/fastcgi_temp 1 2; 19 | 20 | client_max_body_size 2G; 21 | 22 | server { 23 | 24 | #listen [::]:80; #uncomment for IPv6 support 25 | listen 80; 26 | 27 | root /DATA/htdocs; 28 | index index.php index.html index.htm; 29 | 30 | disable_symlinks off; 31 | 32 | location = /robots.txt { 33 | allow all; 34 | log_not_found off; 35 | access_log off; 36 | } 37 | 38 | # deny dot-files 39 | location ~ /\. { 40 | deny all; 41 | access_log off; 42 | log_not_found off; 43 | } 44 | 45 | location / { 46 | try_files $uri $uri/ /index.html; 47 | } 48 | 49 | # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 50 | location ~ [^/]\.php(/|$) { 51 | fastcgi_split_path_info ^(.+?\.php)(/.*)$; 52 | if (!-f $document_root$fastcgi_script_name) { 53 | return 404; 54 | } 55 | fastcgi_pass 127.0.0.1:9000; 56 | fastcgi_index index.php; 57 | fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; 58 | include fastcgi_params; 59 | } 60 | } 61 | 62 | } 63 | -------------------------------------------------------------------------------- /files/php-fpm.conf: -------------------------------------------------------------------------------- 1 | error_log = /DATA/logs/php-fpm/php-fpm.log 2 | log_level = warning 3 | 4 | [www] 5 | user = nginx 6 | group = www-data 7 | listen = 127.0.0.1:9000 8 | listen.owner = nginx 9 | listen.group = www-data 10 | pm = ondemand 11 | pm.max_children = 75 12 | pm.process_idle_timeout = 10s 13 | pm.max_requests = 500 14 | chdir = /DATA/htdocs 15 | php_flag[display_errors] = on 16 | php_admin_value[memory_limit] = 128M 17 | php_admin_value[upload_max_filesize] = 2G 18 | php_admin_value[post_max_size] = 2G 19 | php_admin_value[always_populate_raw_post_data] = -1 20 | php_admin_value[output_buffering] = 0 21 | php_admin_value[php_value max_input_time] = 3600 22 | php_admin_value[php_value max_execution_time] = 3600 23 | php_admin_value[openssl.cafile] = /etc/ssl/certs/ca-certificates.crt 24 | php_admin_value[openssl.capath] = /etc/ssl/certs -------------------------------------------------------------------------------- /files/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | [ -f /run-pre.sh ] && /run-pre.sh 4 | 5 | if [ ! -d /DATA/htdocs ] ; then 6 | mkdir -p /DATA/htdocs 7 | chown nginx:www-data /DATA/htdocs 8 | fi 9 | 10 | # start php-fpm 11 | mkdir -p /DATA/logs/php-fpm 12 | php-fpm 13 | 14 | # start nginx 15 | mkdir -p /DATA/logs/nginx 16 | mkdir -p /tmp/nginx 17 | chown nginx /tmp/nginx 18 | nginx --------------------------------------------------------------------------------