Sign inSign up

xplodwild/nginx-php-fpm

By xplodwild

Updated over 3 years ago

NGINX with PHP-FPM on Alpine

Image
0

928

xplodwild/nginx-php-fpm repository overview

hub.docker.com/r/tiredofit/nginx-php-fpm

Build Status Docker Pulls Docker Stars Docker
Layers

Introduction

Dockerfile to build a Nginx w/PHP-FPM container image.

  • This Container uses a customized Alpine Linux base which includes s6 overlay enabled for PID 1 Init capabilities, zabbix-agent based on 3.4 Packages for individual container monitoring, Cron also installed along with other tools (bash,curl, less, logrotate, mariadb-client, nano, vim) for easier management. It also supports sending to external SMTP servers..
  • Debug Mode to Enable XDebug
  • Caching is provided with w/ APC, OpCache
  • All available PHP Extensions included
  • Enabled by default extensions are: apcu, bcmath, ctype, curl, dom, gd, iconv, intl, json, ldap, mbstring, mcrypt, opcache, openssl, pdo, pdo_mysql, pdo_sqlite, pgsql, phar, redis, session, xml, xmlreader, zlib

Changelog

Authors

Table of Contents

Prerequisites

This image assumes that you are using a reverse proxy such as jwilder/nginx-proxy and optionally the Let's Encrypt Proxy Companion @ https://github.com/JrCs/docker-letsencrypt-nginx-proxy-companion in order to serve your pages. However, it will run just fine on it's own if you map appropriate ports.

Installation

Automated builds of the image are available on Registry and is the recommended method of installation.

docker pull hub.docker.com/tiredofit/nginx-php-fpm:(imagetag)

The following image tags are available:

  • 5.3-latest - PHP 5.3.29 w/Alpine 3.4
  • 5.5-latest - PHP 5.5..38 w/Alpine 3.4
  • 5.6-latest - PHP 5.6.x w/Alpine 3.5
  • 7.0-latest - PHP 7.0.x w/Alpine 3.6
  • 7.1-latest - PHP 7.1.x w/Alpine 3.7
  • 7.1-ldap-latest - PHP 7.1.x w/LDAP Authentication w/Alpine 3.7
  • 7.2-latest - PHP 7.2.x w/Alpine 3.8
  • edge-latest - Most recent release of PHP w/most recent Alpine Linux

Quick Start

Configuration

Data-Volumes

The container starts up and reads from /etc/nginx/nginx.conf for some basic configuration and to listen on port 73 internally for Nginx Status responses. /etc/nginx/conf.d contains a sample configuration file that can be used to customize a nginx server block.

The following directories are used for configuration and can be mapped for persistent storage.

DirectoryDescription
/www/htmlRoot Directory
/www/logsNginx and php-fpm logfiles
Database

No Database Required - MariaDB Client is located within the image.

Environment Variables

Along with the Environment Variables from the Base image, below is the complete list of available options that can be used to customize your installation.

ParameterDescription
MAINTENANCEDisplay an Under Maintenance Page - Default: FALSE
PHP_MEMORY_LIMITAmount of memory php-fpm process should use - Default: 128M)
STAGEWhat Stage this Image is running in DEVELOP or PRODUCTION - Passes ENV Var to PHP - Default DEVELOP
PHP_LOG_LEVELDefine verbosity: (e.g debug, info, notice, warning, error, critical, and alert - Default: info)
PHP_TIMEOUTSets Read and Write Timeouts for Nginx FastCGI - Default 300)
UPLOAD_MAX_SIZEMaximum Upload Size - Default 2G
APC_SHM_SIZEPHP7 APC SHM Cache Size - Default 128M)
OPCACHE_MEM_SIZEPHP7 OPCache Size - Select 0 to Disable - Default 128

Enabling / Disabling Specific Extensions

ParameterDescription
PHP_ENABLE_AMQPamqp extension - Default FALSE
PHP_ENABLE_APCUapcu extension - Default TRUE
PHP_ENABLE_BCMATHbcmath extension - Default TRUE
PHP_ENABLE_BZ2bzip2 extension - Default FALSE
PHP_ENABLE_CALENDARcalendar extension - Default FALSE
PHP_ENABLE_CTYPEctype extension - Default TRUE
PHP_ENABLE_CURLcurl extension - Default TRUE
PHP_ENABLE_DBAdba extension - Default FALSE
PHP_ENABLE_DOMdom extension - Default TRUE
PHP_ENABLE_EMBEDembed extension - Default FALSE
PHP_ENABLE_ENCHANTenchant extension - Default FALSE
PHP_ENABLE_EXIFEXIF extension - Default FALSE
PHP_ENABLE_FILEINFOfileinfo extension - Default FALSE
PHP_ENABLE_FTPFTP extension - Default FALSE
PHP_ENABLE_GDGD extension - Default TRUE
PHP_ENABLE_GETTEXTgettext extension - Default FALSE
PHP_ENABLE_GMPgmp extension - Default FALSE
PHP_ENABLE_ICONViconv extension - Default TRUE
PHP_ENABLE_IMAGICKImageMagick extension - Default FALSE
PHP_ENABLE_IMAPIMAP extension - Default TRUE
PHP_ENABLE_INTLINTL extension - Default TRUE
PHP_ENABLE_JSONJSON extension - Default TRUE
PHP_ENABLE_LDAPLDAP extension - Default TRUE
PHP_ENABLE_MAILPARSEMAILPARSE extension - Default FALSE
PHP_ENABLE_MBSTRINGmbstring extension - Default TRUE
PHP_ENABLE_MCRYPTmcrypt extension - Default TRUE
PHP_ENABLE_MEMCACHEDMemCached extension - Default FALSE
PHP_ENABLE_MYSQLNDMySQLND extension - Default TRUE
PHP_ENABLE_ODBCODBC extension - Default FALSE
PHP_ENABLE_OPCACHEOPCACHE extension - Default TRUE
PHP_ENABLE_OPENSSLOpenSSL extension - Default TRUE
PHP_ENABLE_PCNTLPCNTL extension - Default FALSE
PHP_ENABLE_PDOPDO extension - Default TRUE
PHP_ENABLE_PDO_MYSQLPDO_MySQL extension - Default TRUE
PHP_ENABLE_PDO_PGSQLPDO_PGSQL extension - Default FALSE
PHP_ENABLE_PDO_SQLITEPDO_SQLITE3 extension - Default TRUE
PHP_ENABLE_PGSQLPGSQL extension - Default TRUE
PHP_ENABLE_PHARPHAR extension - Default TRUE
PHP_ENABLE_POSIXPOSIX extension - Default FALSE
PHP_ENABLE_PSPELLpspell extension - Default FALSE
PHP_ENABLE_RECODERecode extension - Default FALSE
PHP_ENABLE_REDISRedis extension - Default TRUE
PHP_ENABLE_SESSIONSession extension - Default TRUE
PHP_ENABLE_SHMOPSHMOP extension - Default FALSE
PHP_ENABLE_SIMPLEXMLSimpleXML extension - Default FALSE
PHP_ENABLE_SNMPSNMP extension - Default FALSE
PHP_ENABLE_SOAPSOAP extension - Default FALSE
PHP_ENABLE_TIDYTIDY extension - Default FALSE
PHP_ENABLE_TOKENIZERTokenizer extension - Default FALSE
PHP_ENABLE_WDDXWDDX extension - Default FALSE
PHP_ENABLE_XMLXML extension - Default TRUE
PHP_ENABLE_XMLREADERXMLReader extension - Default TRUE
PHP_ENABLE_XMLRPCXMLRPC extension - Default FALSE
PHP_ENABLE_XMLWRITERXMLWriter extension - Default FALSE
PHP_ENABLE_ZIPZIP extension - Default FALSE
PHP_ENABLE_ZLIBZlib extension - Default TRUE
PHP_ENABLE_ZMQZeroMQ extension - Default FALSE

If you enable DEBUG_MODE=TRUE all extensions above will be enabled, and you will also have the ability to use XDebug. The following are the environment variables to configure XDebug. Visit the PHP XDebug Documentation to understand what these options mean.

ParameterDescription
PHP_XDEBUG_PROFILER_DIRWhere to store Profiler Logs - Default /www/logs/xdebug/
PHP_XDEBUG_PROFILER_ENABLEEnable Profiler - Default 0
PHP_XDEBUG_PROFILER_ENABLE_TRIGGEREnable Profiler Trigger - Default 0
PHP_XDEBUG_REMOTE_AUTOSTARTEnable Autostarting as opposed to GET/POST - Default 1
PHP_XDEBUG_REMOTE_CONNECT_BACKEnbable Connection Back - Default 0
PHP_XDEBUG_REMOTE_ENABLEEnable Remote Debugging - Default 1
PHP_XDEBUG_REMOTE_HANDLERXDebug Remote Handler - Default dbgp
PHP_XDEBUG_REMOTE_HOSTSet this to your IP Address - Default 127.0.0.1
PHP_XDEBUG_REMOTE_PORTXDebug Remote Port - Default 9090
Networking

The following ports are exposed.

PortDescription
80HTTP

Maintenance

Shell Access

If you wish to turn the web server into maintenance mode showing a single page screen outlining that the service is being worked on, you can also enter into the container and type maintenance ARG, where ARG is either ON,OFF, or SLEEP (seconds) which will temporarily place the site in maintenance mode and then restore it back to normal after time has passed.

For debugging and maintenance purposes you may want access the containers shell.

docker exec -it (whatever your container name is e.g. nginx-php-fpm) bash

References

Tag summary

Content type

Image

Digest

sha256:8a84a02c7

Size

82.4 MB

Last updated

over 3 years ago

docker pull xplodwild/nginx-php-fpm