├── .gitignore ├── 5.6 ├── Dockerfile ├── README.md ├── example.env └── scripts │ ├── crontab.sh │ ├── docker-boot │ ├── docker-php-entrypoint │ ├── newrelic.sh │ ├── sendgrid.sh │ └── session.sh ├── 7.0 ├── .env-example ├── .gitignore ├── Dockerfile ├── configs │ ├── cron │ ├── job.sh │ ├── php.ini │ ├── pools │ │ ├── test1.conf │ │ ├── test2.conf │ │ ├── test3-pool.conf │ │ └── test4-pool.conf │ ├── start.sh │ └── www.conf ├── docker-compose.yml └── scripts │ ├── crontab.sh │ ├── docker-boot │ ├── docker-php-entrypoint │ ├── emailtest.php │ ├── newrelic.sh │ ├── phpsendmail │ ├── sendgrid.sh │ └── session.sh ├── 7.1 ├── .gitignore ├── Dockerfile ├── docker-compose.yml └── scripts │ ├── aliases.sh │ ├── crontab.sh │ ├── docker-boot │ ├── docker-php-entrypoint │ ├── newrelic.sh │ ├── phpsendmail │ ├── sendgrid.sh │ └── session.sh ├── 7.2 ├── .gitignore ├── Dockerfile ├── configs │ ├── php.ini │ └── www.conf ├── docker-compose.yml └── scripts │ ├── crontab.sh │ ├── docker-boot │ ├── docker-php-entrypoint │ ├── newrelic.sh │ ├── phpsendmail │ ├── sendgrid.sh │ ├── session.sh │ └── www-pool.sh ├── 7.3 ├── .env-example ├── .gitignore ├── Dockerfile ├── configs │ ├── cron │ ├── job.sh │ ├── php.ini │ ├── pools │ │ ├── test1.conf │ │ ├── test2.conf │ │ ├── test3-pool.conf │ │ └── test4-pool.conf │ ├── start.sh │ └── www.conf ├── docker-compose.yml └── scripts │ ├── crontab.sh │ ├── docker-boot │ ├── docker-php-entrypoint │ ├── emailtest.php │ ├── newrelic.sh │ ├── phpsendmail │ ├── sendgrid.sh │ └── session.sh ├── 7.4 ├── .env-example ├── .gitignore ├── Dockerfile ├── configs │ ├── cron │ ├── job.sh │ ├── php.ini │ ├── pools │ │ ├── test1.conf │ │ ├── test2.conf │ │ ├── test3-pool.conf │ │ └── test4-pool.conf │ ├── start.sh │ └── www.conf ├── docker-compose.yml └── scripts │ ├── crontab.sh │ ├── docker-boot │ ├── docker-php-entrypoint │ ├── emailtest.php │ ├── newrelic.sh │ ├── phpsendmail │ ├── sendgrid.sh │ └── session.sh ├── 8.0 ├── .env-example ├── .gitignore ├── Dockerfile ├── configs │ ├── cron │ ├── job.sh │ ├── php.ini │ ├── pools │ │ ├── test1.conf │ │ ├── test2.conf │ │ ├── test3-pool.conf │ │ └── test4-pool.conf │ ├── start.sh │ └── www.conf ├── docker-compose.yml └── scripts │ ├── crontab.sh │ ├── docker-boot │ ├── docker-php-entrypoint │ ├── emailtest.php │ ├── newrelic.sh │ ├── phpsendmail │ ├── sendgrid.sh │ └── session.sh ├── 8.1 ├── .env-example ├── .gitignore ├── Dockerfile ├── configs │ ├── cron │ ├── job.sh │ ├── php.ini │ ├── pools │ │ ├── test1.conf │ │ ├── test2.conf │ │ ├── test3-pool.conf │ │ └── test4-pool.conf │ ├── start.sh │ └── www.conf ├── docker-compose.yml └── scripts │ ├── crontab.sh │ ├── docker-boot │ ├── docker-php-entrypoint │ ├── emailtest.php │ ├── newrelic.sh │ ├── phpsendmail │ ├── sendgrid.sh │ └── session.sh ├── 8.2 ├── .env-example ├── .gitignore ├── Dockerfile ├── configs │ ├── cron │ ├── job.sh │ ├── php.ini │ ├── pools │ │ ├── test1.conf │ │ ├── test2.conf │ │ ├── test3-pool.conf │ │ └── test4-pool.conf │ ├── start.sh │ └── www.conf ├── docker-compose.yml └── scripts │ ├── crontab.sh │ ├── docker-boot │ ├── docker-php-entrypoint │ ├── emailtest.php │ ├── newrelic.sh │ ├── phpsendmail │ ├── sendgrid.sh │ └── session.sh ├── LICENSE ├── README.md └── cloudbuild.yaml /.gitignore: -------------------------------------------------------------------------------- 1 | _OLD/ 2 | .vscode 3 | HELP.md 4 | -------------------------------------------------------------------------------- /5.6/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM php:5.6-fpm 2 | 3 | MAINTAINER Mark Hilton 4 | 5 | # Install PHP extensions 6 | RUN DEBIAN_FRONTEND=noninteractive apt-get update -q && \ 7 | DEBIAN_FRONTEND=noninteractive apt-get install -y \ 8 | nano openssl libldb-dev libtidy-dev libgmp-dev unixODBC-dev \ 9 | libicu-dev \ 10 | libmcrypt-dev \ 11 | libcurl4-openssl-dev \ 12 | librabbitmq-dev \ 13 | libsodium-dev \ 14 | libpq-dev \ 15 | libxslt1-dev \ 16 | libfreetype6-dev \ 17 | libjpeg62-turbo-dev \ 18 | libpng12-dev \ 19 | zlib1g-dev \ 20 | libgmp3-dev \ 21 | libbz2-dev \ 22 | libgmp-dev \ 23 | libgmp3-dev 24 | 25 | # imagic 26 | RUN apt-get install -y libmagickwand-6.q16-dev --no-install-recommends \ 27 | && ln -s /usr/lib/x86_64-linux-gnu/ImageMagick-6.8.9/bin-Q16/MagickWand-config /usr/bin \ 28 | && pecl install imagick \ 29 | && echo "extension=imagick.so" > /usr/local/etc/php/conf.d/ext-imagick.ini 30 | 31 | RUN docker-php-ext-configure xsl \ 32 | && docker-php-ext-configure soap --enable-soap \ 33 | && docker-php-ext-configure intl --enable-intl \ 34 | && docker-php-ext-configure pcntl --enable-pcntl \ 35 | && docker-php-ext-configure bcmath --enable-bcmath \ 36 | && docker-php-ext-configure pdo_mysql --with-pdo-mysql \ 37 | && docker-php-ext-configure mbstring --enable-mbstring \ 38 | && docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ \ 39 | && docker-php-ext-install gd \ 40 | && docker-php-ext-install dba ftp calendar ctype dom tokenizer fileinfo gettext posix tidy wddx \ 41 | && docker-php-ext-install exif sockets bz2 zip iconv mcrypt json session \ 42 | && docker-php-ext-install opcache xsl xml xmlreader xmlwriter xmlrpc simplexml \ 43 | && docker-php-ext-install curl bcmath intl pcntl mbstring soap mysqli pdo pdo_mysql \ 44 | && ln -s /usr/include/x86_64-linux-gnu/gmp.h /usr/include/gmp.h \ 45 | && docker-php-ext-install gmp sysvmsg sysvsem sysvshm \ 46 | && docker-php-ext-enable soap 47 | 48 | # && docker-php-ext-configure odbc --with-unixODBC=unixODBC,/usr/ \ 49 | # && docker-php-ext-configure pdo_odbc --with-pdo-odbc=unixODBC,/usr/ \ 50 | # && docker-php-ext-install odbc pdo_odbc \ 51 | # && docker-php-ext-enable odbc \ 52 | 53 | # mhash 54 | RUN apt-get install -y libmhash2 libmhash-dev php5-mhash && \ 55 | cd /usr/src/ && \ 56 | curl -O -L https://downloads.sourceforge.net/project/mhash/mhash/0.9.9.9/mhash-0.9.9.9.tar.gz && \ 57 | tar xzf mhash-0.9.9.9.tar.gz && \ 58 | cd mhash-0.9.9.9 && \ 59 | ./configure && make && make install && \ 60 | ln -s /usr/local/lib/libmhash.so.2 /usr/lib/libmhash.so.2 61 | 62 | RUN docker-php-ext-configure hash --with-mhash=/usr/src/mhash-0.9.9.9/include/ && \ 63 | docker-php-ext-install hash 64 | 65 | # Igbinary module 66 | RUN pecl install igbinary \ 67 | && docker-php-ext-enable igbinary 68 | 69 | RUN pecl install -o -f redis && \ 70 | docker-php-ext-enable redis 71 | 72 | RUN pecl install apcu-4.0.10 && \ 73 | docker-php-ext-enable apcu 74 | 75 | RUN apt-get install -y libmemcached-dev \ 76 | && pecl install memcache \ 77 | && pecl install memcached-2.2.0 \ 78 | && docker-php-ext-enable memcache memcached 79 | 80 | RUN curl -fsSL 'https://xcache.lighttpd.net/pub/Releases/3.2.0/xcache-3.2.0.tar.gz' -o xcache.tar.gz \ 81 | && mkdir -p xcache \ 82 | && tar -xf xcache.tar.gz -C xcache --strip-components=1 \ 83 | && rm xcache.tar.gz \ 84 | && ( \ 85 | cd xcache \ 86 | && phpize \ 87 | && ./configure --enable-xcache \ 88 | && make -j$(nproc) \ 89 | && make install \ 90 | ) \ 91 | && rm -r xcache \ 92 | && docker-php-ext-enable xcache 93 | 94 | # composer 95 | RUN RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/bin/ --filename=composer 96 | 97 | # install NewRelic agent 98 | RUN echo 'deb http://apt.newrelic.com/debian/ newrelic non-free' | tee /etc/apt/sources.list.d/newrelic.list && \ 99 | curl https://download.newrelic.com/548C16BF.gpg | apt-key add - && \ 100 | apt-get -y update && \ 101 | DEBIAN_FRONTEND=noninteractive apt-get -y install newrelic-php5 newrelic-sysmond && \ 102 | export NR_INSTALL_SILENT=1 && newrelic-install install 103 | 104 | # Install required libraries 105 | RUN apt-get -y install libfcgi0ldbl git mysql-client cron redis-tools 106 | 107 | # install sendgrid mail routing 108 | RUN echo "postfix postfix/mailname string localhost" | debconf-set-selections && \ 109 | echo "postfix postfix/main_mailer_type string 'Internet Site'" | debconf-set-selections && \ 110 | DEBIAN_FRONTEND=noninteractive apt-get install postfix libsasl2-modules -y 111 | 112 | # install modman 113 | RUN curl -s -L https://raw.github.com/colinmollenhour/modman/master/modman-installer | bash && \ 114 | mv ~/bin/modman /usr/sbin/ 115 | 116 | # install composer 117 | ENV COMPOSER_HOME /tmp 118 | ENV COMPOSER_VERSION 1.5.2 119 | ENV COMPOSER_ALLOW_SUPERUSER 1 120 | 121 | RUN curl -s -f -L -o /tmp/installer.php https://raw.githubusercontent.com/composer/getcomposer.org/da290238de6d63faace0343efbdd5aa9354332c5/web/installer \ 122 | && php -r " \ 123 | \$signature = '669656bab3166a7aff8a7506b8cb2d1c292f042046c5a994c43155c0be6190fa0355160742ab2e1c88d40d5be660b410'; \ 124 | \$hash = hash('SHA384', file_get_contents('/tmp/installer.php')); \ 125 | if (!hash_equals(\$signature, \$hash)) { \ 126 | unlink('/tmp/installer.php'); \ 127 | echo 'Integrity check failed, installer is either corrupt or worse.' . PHP_EOL; \ 128 | exit(1); \ 129 | }" \ 130 | && php /tmp/installer.php --no-ansi --install-dir=/usr/bin --filename=composer --version=${COMPOSER_VERSION} \ 131 | && composer --ansi --version --no-interaction \ 132 | && rm -rf /tmp/* /tmp/.htaccess 133 | 134 | # install recommended redis extension 135 | RUN cd /usr/src && \ 136 | git clone https://github.com/phpredis/phpredis.git && \ 137 | cd /usr/src/phpredis && phpize && \ 138 | ./configure --enable-redis-igbinary && \ 139 | make && make install 140 | 141 | # install blackfire.io profiler 142 | RUN version=$(php -r "echo PHP_MAJOR_VERSION.PHP_MINOR_VERSION;") \ 143 | && curl -A "Docker" -o /tmp/blackfire-probe.tar.gz -D - -L -s https://blackfire.io/api/v1/releases/probe/php/linux/amd64/$version \ 144 | && tar zxpf /tmp/blackfire-probe.tar.gz -C /tmp \ 145 | && mv /tmp/blackfire-*.so $(php -r "echo ini_get('extension_dir');")/blackfire.so \ 146 | && printf "extension=blackfire.so\nblackfire.agent_socket=tcp://blackfire:8707\n" > $PHP_INI_DIR/conf.d/blackfire.ini 147 | 148 | # cache 149 | RUN echo 5 150 | 151 | # Install shared PHP code 152 | RUN git clone https://github.com/nrk/predis.git /usr/local/lib/php/predis && \ 153 | git clone -b magento https://github.com/markhilton/redis-http-cache.git /usr/local/lib/php/redis-http-cache 154 | 155 | # clean up 156 | RUN apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* 157 | 158 | COPY scripts/* /usr/local/bin/ 159 | 160 | RUN chmod +x /usr/local/bin/* 161 | 162 | # Health check 163 | RUN sed -i '/pm.status_path/c\pm.status_path = /status' /usr/local/etc/php-fpm.d/www.conf && \ 164 | sed -i '/ping.path/c\ping.path = /health' /usr/local/etc/php-fpm.d/www.conf && \ 165 | sed -i '/ping.response/c\;ping.response = OK' /usr/local/etc/php-fpm.d/www.conf 166 | 167 | HEALTHCHECK --interval=10s --timeout=5s \ 168 | CMD SCRIPT_NAME=/health SCRIPT_FILENAME=/health REQUEST_METHOD=GET cgi-fcgi -bind -connect 127.0.0.1:9000 || exit 1 169 | -------------------------------------------------------------------------------- /5.6/README.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/markhilton/docker-php-fpm/4c4c07d77ac886627885ab82d5ca1e1ceeb7119f/5.6/README.md -------------------------------------------------------------------------------- /5.6/example.env: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/markhilton/docker-php-fpm/4c4c07d77ac886627885ab82d5ca1e1ceeb7119f/5.6/example.env -------------------------------------------------------------------------------- /5.6/scripts/crontab.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | if [ ! "$PHP_CRONTABS_PATH" == "" ]; then 4 | printf "env CRONTABS_PATH: setting up crontabs: "; 5 | for f in ${PHP_CRONTABS_PATH}; do 6 | printf "$f, "; 7 | rm -f /etc/cron.d/${f##*/} 8 | cp $f /etc/cron.d/ 9 | chmod 0644 /etc/cron.d/${f##*/} 10 | done 11 | echo 12 | touch /var/log/cron.log 13 | printenv | grep -v "no_proxy" >> /etc/environment 14 | /etc/init.d/cron start > /dev/null 15 | fi 16 | -------------------------------------------------------------------------------- /5.6/scripts/docker-boot: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | /usr/local/bin/php -v 4 | 5 | ### create system user for php pool 6 | if [ ! "$PHP_USER" == "" ] && [ ! "$PHP_UID" == "" ] && [ ! "$PHP_GID" == "" ] && [ ! "$PHP_HOME" == "" ]; then 7 | echo "env PHP_USER: creating new system user: ${PHP_USER} ${PHP_UID}:${PHP_GID} ${PHP_HOME}" 8 | groupadd -f $PHP_USER -g $PHP_GID && \ 9 | useradd -d $PHP_HOME -u $PHP_UID -g $PHP_GID -s /bin/false $PHP_USER 10 | fi 11 | 12 | ### load PHP ini configurations 13 | if [ ! "$PHP_INI_PATH" == "" ]; then 14 | printf "env PHP_INI_PATH: " 15 | for f in ${PHP_INI_PATH}; do 16 | printf "$f, "; 17 | rm -f /usr/local/etc/php/conf.d/${f##*/} 18 | cp $f /usr/local/etc/php/conf.d/ 19 | done 20 | echo 21 | fi 22 | 23 | ### make sure to create clean php-fpm.conf 24 | ### to avoid adding multiple times the same lines next 25 | ### in case container is restarting 26 | echo "[global]" > /usr/local/etc/php-fpm.conf 27 | echo "include=etc/php-fpm.d/*.conf" >> /usr/local/etc/php-fpm.conf 28 | 29 | ### load PHP-FPM pool configurations 30 | if [ ! "$PHP_POOL_PATH" == "" ]; then 31 | printf "env PHP_POOL_PATH: " 32 | for f in ${PHP_POOL_PATH}; do 33 | printf "$f, "; 34 | rm -f /usr/local/etc/php-fpm.d/${f##*/} 35 | cp $f /usr/local/etc/php-fpm.d/ 36 | done 37 | echo 38 | echo "include=$PHP_POOL_PATH" >> /usr/local/etc/php-fpm.conf 39 | fi 40 | 41 | ### load boot bash scripts 42 | for f in /usr/local/bin/*.sh; do 43 | /bin/bash -c $f 44 | done 45 | 46 | ### load bash scripts 47 | if [ ! "$PHP_BOOT_SCRIPTS" == "" ]; then 48 | printf "env PHP_BOOT_SCRIPTS: " 49 | for f in $PHP_BOOT_SCRIPTS; do 50 | printf "${f##*/}, "; 51 | done 52 | echo 53 | for f in $PHP_BOOT_SCRIPTS; do 54 | /bin/bash -c $f 55 | done 56 | fi 57 | -------------------------------------------------------------------------------- /5.6/scripts/docker-php-entrypoint: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -e 3 | 4 | /usr/local/bin/docker-boot 5 | 6 | # first arg is `-f` or `--some-option` 7 | if [ "${1#-}" != "$1" ]; then 8 | set -- php-fpm "$@" 9 | fi 10 | 11 | exec "$@" 12 | -------------------------------------------------------------------------------- /5.6/scripts/newrelic.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | if [ ! "$NEWRELIC_LICENSE" == "" ] ; then 4 | echo "env NEWRELIC_LICENSE: setting up newrelic license" 5 | sed -i "s/REPLACE_WITH_REAL_KEY/$NEWRELIC_LICENSE/g" /usr/local/etc/php/conf.d/newrelic.ini 6 | nrsysmond-config --set license_key=$NEWRELIC_LICENSE 7 | service newrelic-sysmond start > /dev/null 8 | fi -------------------------------------------------------------------------------- /5.6/scripts/sendgrid.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | if [ -z ${SMTP_LOGIN+x} ] && [ -z ${SMTP_PASSWORD+x} ] && [ ! "$SMTP_LOGIN" == "" ] && [ ! "$SMTP_PASSWORD" == "" ]; then 4 | echo "env SMTP_LOGIN: sendgrid credentials for email routing"; 5 | echo "[smtp.sendgrid.net]:2525 ${SMTP_LOGIN}:${SMTP_PASSWORD}" >> /etc/postfix/sasl_passwd 6 | 7 | postmap /etc/postfix/sasl_passwd 8 | chmod 600 /etc/postfix/sasl_passwd.db 9 | rm /etc/postfix/sasl_passwd 10 | 11 | ### update email relay configuration for SendGrid 12 | sed -i 's/default_transport = error//g' /etc/postfix/main.cf && \ 13 | sed -i 's/relay_transport = error//g' /etc/postfix/main.cf && \ 14 | sed -i 's/relayhost = //g' /etc/postfix/main.cf && \ 15 | 16 | echo "relayhost = [smtp.sendgrid.net]:2525" >> /etc/postfix/main.cf && \ 17 | echo "smtp_tls_security_level = encrypt" >> /etc/postfix/main.cf && \ 18 | echo "smtp_sasl_auth_enable = yes" >> /etc/postfix/main.cf && \ 19 | echo "smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd" >> /etc/postfix/main.cf && \ 20 | echo "header_size_limit = 4096000" >> /etc/postfix/main.cf && \ 21 | echo "smtp_sasl_security_options = noanonymous" >> /etc/postfix/main.cf 22 | 23 | /etc/init.d/postfix start > /dev/null 24 | fi 25 | -------------------------------------------------------------------------------- /5.6/scripts/session.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | ### update PHP session handler 4 | if [ ! "$PHP_SESSION_HANDLER" == "" ] && [ ! "$PHP_SESSION_PATH" == "" ]; then 5 | echo "env PHP_SESSION_HANDLER: updating php session handler [ $PHP_SESSION_PATH ]" 6 | echo "session.save_handler = $PHP_SESSION_HANDLER" > /usr/local/etc/php/conf.d/zz-session.ini 7 | echo "session.save_path = \"$PHP_SESSION_PATH\"" >> /usr/local/etc/php/conf.d/zz-session.ini 8 | fi 9 | -------------------------------------------------------------------------------- /7.0/.env-example: -------------------------------------------------------------------------------- 1 | PHP_UID=1000 2 | PHP_GID=1000 3 | PHP_HOME=/app 4 | PHP_USER=php-fpm 5 | # PHP_INI_SCAN_DIR=/cfgs:/usr/local/etc/php/conf.d 6 | PHP_INI_PATH=/cfgs/php.ini 7 | PHP_POOL_PATH=/cfgs/*/*-pool.conf 8 | PHP_BOOT_SCRIPTS=/cfgs/start.sh 9 | PHP_CRONTABS_PATH=/cfgs/cron 10 | PHP_SESSION_HANDLER=redis 11 | PHP_SESSION_PATH=tcp://redis.host:6379 12 | 13 | # private 14 | TEST_EMAIL=name@domain.com 15 | NEWRELIC_LICENSE=newrelic_license 16 | SENDGRID_API_KEY=sendgrid_api_key 17 | -------------------------------------------------------------------------------- /7.0/.gitignore: -------------------------------------------------------------------------------- 1 | .env -------------------------------------------------------------------------------- /7.0/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM php:7.0-fpm 2 | 3 | RUN apt-get update && apt-get upgrade -y && \ 4 | apt-get install -y --no-install-recommends \ 5 | git \ 6 | libmemcached-dev \ 7 | libz-dev \ 8 | libpq-dev \ 9 | libjpeg-dev \ 10 | libfreetype6-dev \ 11 | libssl-dev \ 12 | libmcrypt-dev 13 | 14 | RUN docker-php-ext-install mcrypt 15 | RUN docker-php-ext-install mysqli pdo_mysql 16 | 17 | # install the PHP gd library 18 | RUN docker-php-ext-configure gd \ 19 | --enable-gd-native-ttf \ 20 | --with-jpeg-dir=/usr/lib \ 21 | --with-freetype-dir=/usr/include/freetype2 && \ 22 | docker-php-ext-install gd 23 | 24 | # install the soap extension 25 | RUN apt-get update -yqq && \ 26 | apt-get -y install libxml2-dev && \ 27 | docker-php-ext-install soap 28 | 29 | # install Php Redis Extension 30 | RUN pecl install -o -f redis \ 31 | && rm -rf /tmp/pear \ 32 | && docker-php-ext-enable redis 33 | 34 | # install the mongodb extension 35 | RUN pecl install mongodb && docker-php-ext-enable mongodb 36 | 37 | # install bcmath, mbstring and zip extensions 38 | RUN docker-php-ext-install bcmath && \ 39 | docker-php-ext-install mbstring && \ 40 | docker-php-ext-install zip 41 | 42 | # enable Exif PHP extentions requirements 43 | RUN docker-php-ext-install exif 44 | 45 | # tokenizer Modifications: 46 | RUN docker-php-ext-install tokenizer 47 | 48 | # install intl and requirements 49 | RUN apt-get update -yqq && \ 50 | apt-get install -y zlib1g-dev libicu-dev g++ && \ 51 | docker-php-ext-configure intl && \ 52 | docker-php-ext-install intl 53 | 54 | # install the ghostscript extension for PDF editing 55 | RUN apt-get update -yqq \ 56 | && apt-get install -y \ 57 | poppler-utils \ 58 | ghostscript 59 | 60 | # LDAP: 61 | RUN apt-get update -yqq && \ 62 | apt-get install -y libldap2-dev && \ 63 | docker-php-ext-configure ldap --with-libdir=lib/x86_64-linux-gnu/ && \ 64 | docker-php-ext-install ldap 65 | 66 | RUN yes "" | pecl install msgpack-beta \ 67 | && echo "extension=msgpack.so" > /usr/local/etc/php/conf.d/ext-msgpack.ini 68 | 69 | # compile igbinary extension 70 | RUN cd /tmp/ && git clone https://github.com/igbinary/igbinary "php-igbinary" && \ 71 | cd php-igbinary && \ 72 | phpize && \ 73 | ./configure && \ 74 | make && \ 75 | make install && \ 76 | make clean && \ 77 | docker-php-ext-enable igbinary 78 | 79 | # curl extension 80 | RUN apt-get install -y curl libcurl4-openssl-dev --no-install-recommends && \ 81 | docker-php-ext-install curl 82 | 83 | # data structures extension 84 | RUN pecl install ds && \ 85 | docker-php-ext-enable ds 86 | 87 | # imagick 88 | RUN apt-get update && apt-get install -y libmagickwand-6.q16-dev --no-install-recommends && \ 89 | ln -s /usr/lib/x86_64-linux-gnu/ImageMagick-6.8.9/bin-Q16/MagickWand-config /usr/bin && \ 90 | pecl install imagick && \ 91 | echo "extension=imagick.so" > /usr/local/etc/php/conf.d/ext-imagick.ini 92 | 93 | # ssh2 module 94 | RUN apt-get install -y libssh2-1-dev && \ 95 | pecl install ssh2-1.0 && \ 96 | docker-php-ext-enable ssh2 97 | 98 | # php-module: curl dom bz2 gd json mysqli pcntl pdo pdo_mysql phar posix 99 | RUN apt-get install -y libxml2-dev libbz2-dev re2c libpng++-dev \ 100 | libjpeg-dev libvpx-dev zlib1g-dev libgd-dev \ 101 | libtidy-dev libxslt1-dev libmagic-dev libexif-dev file \ 102 | sqlite3 libsqlite3-dev libxslt-dev 103 | 104 | RUN export CFLAGS="-I/usr/src/php" && \ 105 | docker-php-ext-install xmlreader xmlwriter 106 | 107 | RUN docker-php-ext-configure json && \ 108 | docker-php-ext-configure session && \ 109 | docker-php-ext-configure ctype && \ 110 | docker-php-ext-configure tokenizer && \ 111 | docker-php-ext-configure simplexml && \ 112 | docker-php-ext-configure dom && \ 113 | docker-php-ext-configure mbstring && \ 114 | docker-php-ext-configure zip && \ 115 | docker-php-ext-configure pdo && \ 116 | docker-php-ext-configure pdo_sqlite && \ 117 | docker-php-ext-configure pdo_mysql && \ 118 | docker-php-ext-configure mysqli && \ 119 | docker-php-ext-configure iconv && \ 120 | docker-php-ext-configure xml && \ 121 | docker-php-ext-configure phar 122 | 123 | RUN docker-php-ext-install \ 124 | dom \ 125 | bz2 \ 126 | json \ 127 | pcntl \ 128 | phar \ 129 | posix \ 130 | simplexml \ 131 | soap \ 132 | tidy \ 133 | xml \ 134 | xmlrpc \ 135 | xsl \ 136 | calendar \ 137 | ctype \ 138 | fileinfo \ 139 | ftp \ 140 | sysvmsg \ 141 | sysvsem \ 142 | sysvshm 143 | 144 | # install the php memcache & memcached extension 145 | RUN set -x \ 146 | && apt-get update && apt-get install -y --no-install-recommends unzip libssl-dev libpcre3 libpcre3-dev \ 147 | && cd /tmp \ 148 | && curl -sSL -o php7.zip https://github.com/websupport-sk/pecl-memcache/archive/php7.zip \ 149 | && unzip php7 \ 150 | && cd pecl-memcache-php7 \ 151 | && /usr/local/bin/phpize \ 152 | && ./configure --with-php-config=/usr/local/bin/php-config \ 153 | && make \ 154 | && make install \ 155 | && echo "extension=memcache.so" > /usr/local/etc/php/conf.d/ext-memcache.ini \ 156 | && rm -rf /tmp/pecl-memcache-php7 php7.zip 157 | 158 | RUN curl -L -o /tmp/memcached.tar.gz "https://github.com/php-memcached-dev/php-memcached/archive/php7.tar.gz" \ 159 | && mkdir -p memcached \ 160 | && tar -C memcached -zxvf /tmp/memcached.tar.gz --strip 1 \ 161 | && ( \ 162 | cd memcached \ 163 | && phpize \ 164 | && ./configure \ 165 | && make -j$(nproc) \ 166 | && make install \ 167 | ) \ 168 | && rm -r memcached \ 169 | && rm /tmp/memcached.tar.gz \ 170 | && docker-php-ext-enable memcached 171 | 172 | # mhash 173 | RUN apt-get install -y libmhash2 libmhash-dev libc-client-dev libkrb5-dev 174 | 175 | RUN docker-php-ext-configure imap --with-kerberos --with-imap-ssl \ 176 | && docker-php-ext-install imap 177 | 178 | RUN docker-php-ext-configure hash --with-mhash && \ 179 | docker-php-ext-install hash 180 | 181 | # Opcache 182 | RUN docker-php-ext-install opcache 183 | 184 | # install APCu 185 | RUN pecl install apcu-5.1.8 && \ 186 | pecl install apcu_bc-1.0.3 && \ 187 | docker-php-ext-enable apcu --ini-name 10-docker-php-ext-apcu.ini && \ 188 | docker-php-ext-enable apc --ini-name 20-docker-php-ext-apc.ini 189 | 190 | RUN apt-get update -y && apt-get install -y gnupg apt-transport-https locales 191 | 192 | # install MSSQL support 193 | # install ODBC driver 194 | #RUN curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add - && \ 195 | # curl https://packages.microsoft.com/config/debian/8/prod.list > /etc/apt/sources.list.d/mssql-release.list && \ 196 | # export DEBIAN_FRONTEND=noninteractive && apt-get update -y && \ 197 | # ACCEPT_EULA=Y apt-get install -y msodbcsql unixodbc-dev 198 | #RUN set -xe \ 199 | # && pecl install pdo_sqlsrv \ 200 | # && docker-php-ext-enable pdo_sqlsrv \ 201 | # && apt-get purge -y unixodbc-dev && apt-get autoremove -y && apt-get clean 202 | 203 | # set locale to utf-8 204 | RUN echo "en_US.UTF-8 UTF-8" > /etc/locale.gen && \ 205 | locale-gen 206 | ENV LANG='en_US.UTF-8' LANGUAGE='en_US:en' LC_ALL='en_US.UTF-8' 207 | 208 | #-------------------------------------------------------------------------- 209 | # Final Touches 210 | #-------------------------------------------------------------------------- 211 | 212 | # install required libs for health check 213 | RUN apt-get -y install libfcgi0ldbl nano htop iotop lsof cron mariadb-client redis-tools 214 | 215 | # install NewRelic agent 216 | RUN echo 'deb http://apt.newrelic.com/debian/ newrelic non-free' | tee /etc/apt/sources.list.d/newrelic.list && \ 217 | curl https://download.newrelic.com/548C16BF.gpg | apt-key add - && \ 218 | apt-get -y update && \ 219 | DEBIAN_FRONTEND=noninteractive apt-get -y install newrelic-php5 newrelic-sysmond && \ 220 | export NR_INSTALL_SILENT=1 && newrelic-install install 221 | 222 | # install SendGrid 223 | RUN echo "postfix postfix/mailname string localhost" | debconf-set-selections && \ 224 | echo "postfix postfix/main_mailer_type string 'Internet Site'" | debconf-set-selections && \ 225 | DEBIAN_FRONTEND=noninteractive apt-get install postfix libsasl2-modules -y 226 | 227 | # Set default work directory 228 | ADD scripts/* /usr/local/bin/ 229 | RUN chmod +x /usr/local/bin/* 230 | 231 | # Health check 232 | RUN echo '#!/bin/bash' > /healthcheck && \ 233 | echo 'SCRIPT_NAME=/health SCRIPT_FILENAME=/health REQUEST_METHOD=GET cgi-fcgi -bind -connect 127.0.0.1:9000 || exit 1' >> /healthcheck && \ 234 | chmod +x /healthcheck 235 | 236 | # Clean up 237 | RUN apt-get remove -y git && apt-get autoremove -y && apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* 238 | 239 | WORKDIR / 240 | -------------------------------------------------------------------------------- /7.0/configs/cron: -------------------------------------------------------------------------------- 1 | * * * * * root /cfgs/job.sh 2 | -------------------------------------------------------------------------------- /7.0/configs/job.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | echo "[ cronjob task ] executed at `date`" > /proc/1/fd/2 3 | -------------------------------------------------------------------------------- /7.0/configs/pools/test1.conf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/markhilton/docker-php-fpm/4c4c07d77ac886627885ab82d5ca1e1ceeb7119f/7.0/configs/pools/test1.conf -------------------------------------------------------------------------------- /7.0/configs/pools/test2.conf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/markhilton/docker-php-fpm/4c4c07d77ac886627885ab82d5ca1e1ceeb7119f/7.0/configs/pools/test2.conf -------------------------------------------------------------------------------- /7.0/configs/pools/test3-pool.conf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/markhilton/docker-php-fpm/4c4c07d77ac886627885ab82d5ca1e1ceeb7119f/7.0/configs/pools/test3-pool.conf -------------------------------------------------------------------------------- /7.0/configs/pools/test4-pool.conf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/markhilton/docker-php-fpm/4c4c07d77ac886627885ab82d5ca1e1ceeb7119f/7.0/configs/pools/test4-pool.conf -------------------------------------------------------------------------------- /7.0/configs/start.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | echo "[ start.sh ] Boot script test..." > /proc/1/fd/2 3 | -------------------------------------------------------------------------------- /7.0/configs/www.conf: -------------------------------------------------------------------------------- 1 | ; Start a new pool named 'www'. 2 | ; the variable $pool can be used in any directive and will be replaced by the 3 | ; pool name ('www' here) 4 | [www] 5 | 6 | ; Per pool prefix 7 | ; It only applies on the following directives: 8 | ; - 'access.log' 9 | ; - 'slowlog' 10 | ; - 'listen' (unixsocket) 11 | ; - 'chroot' 12 | ; - 'chdir' 13 | ; - 'php_values' 14 | ; - 'php_admin_values' 15 | ; When not set, the global prefix (or NONE) applies instead. 16 | ; Note: This directive can also be relative to the global prefix. 17 | ; Default Value: none 18 | ;prefix = /path/to/pools/$pool 19 | 20 | ; Unix user/group of processes 21 | ; Note: The user is mandatory. If the group is not set, the default user's group 22 | ; will be used. 23 | user = www-data 24 | group = www-data 25 | 26 | ; The address on which to accept FastCGI requests. 27 | ; Valid syntaxes are: 28 | ; 'ip.add.re.ss:port' - to listen on a TCP socket to a specific IPv4 address on 29 | ; a specific port; 30 | ; '[ip:6:addr:ess]:port' - to listen on a TCP socket to a specific IPv6 address on 31 | ; a specific port; 32 | ; 'port' - to listen on a TCP socket to all addresses 33 | ; (IPv6 and IPv4-mapped) on a specific port; 34 | ; '/path/to/unix/socket' - to listen on a unix socket. 35 | ; Note: This value is mandatory. 36 | listen = 9000 37 | 38 | ; Set listen(2) backlog. 39 | ; Default Value: 511 (-1 on FreeBSD and OpenBSD) 40 | ;listen.backlog = 511 41 | 42 | ; Set permissions for unix socket, if one is used. In Linux, read/write 43 | ; permissions must be set in order to allow connections from a web server. Many 44 | ; BSD-derived systems allow connections regardless of permissions. 45 | ; Default Values: user and group are set as the running user 46 | ; mode is set to 0660 47 | ;listen.owner = www-data 48 | ;listen.group = www-data 49 | ;listen.mode = 0660 50 | ; When POSIX Access Control Lists are supported you can set them using 51 | ; these options, value is a comma separated list of user/group names. 52 | ; When set, listen.owner and listen.group are ignored 53 | ;listen.acl_users = 54 | ;listen.acl_groups = 55 | 56 | ; List of addresses (IPv4/IPv6) of FastCGI clients which are allowed to connect. 57 | ; Equivalent to the FCGI_WEB_SERVER_ADDRS environment variable in the original 58 | ; PHP FCGI (5.2.2+). Makes sense only with a tcp listening socket. Each address 59 | ; must be separated by a comma. If this value is left blank, connections will be 60 | ; accepted from any ip address. 61 | ; Default Value: any 62 | ;listen.allowed_clients = 127.0.0.1 63 | 64 | ; Specify the nice(2) priority to apply to the pool processes (only if set) 65 | ; The value can vary from -19 (highest priority) to 20 (lower priority) 66 | ; Note: - It will only work if the FPM master process is launched as root 67 | ; - The pool processes will inherit the master process priority 68 | ; unless it specified otherwise 69 | ; Default Value: no set 70 | ; process.priority = -19 71 | 72 | ; Set the process dumpable flag (PR_SET_DUMPABLE prctl) even if the process user 73 | ; or group is differrent than the master process user. It allows to create process 74 | ; core dump and ptrace the process for the pool user. 75 | ; Default Value: no 76 | ; process.dumpable = yes 77 | 78 | ; Choose how the process manager will control the number of child processes. 79 | ; Possible Values: 80 | ; static - a fixed number (pm.max_children) of child processes; 81 | ; dynamic - the number of child processes are set dynamically based on the 82 | ; following directives. With this process management, there will be 83 | ; always at least 1 children. 84 | ; pm.max_children - the maximum number of children that can 85 | ; be alive at the same time. 86 | ; pm.start_servers - the number of children created on startup. 87 | ; pm.min_spare_servers - the minimum number of children in 'idle' 88 | ; state (waiting to process). If the number 89 | ; of 'idle' processes is less than this 90 | ; number then some children will be created. 91 | ; pm.max_spare_servers - the maximum number of children in 'idle' 92 | ; state (waiting to process). If the number 93 | ; of 'idle' processes is greater than this 94 | ; number then some children will be killed. 95 | ; ondemand - no children are created at startup. Children will be forked when 96 | ; new requests will connect. The following parameter are used: 97 | ; pm.max_children - the maximum number of children that 98 | ; can be alive at the same time. 99 | ; pm.process_idle_timeout - The number of seconds after which 100 | ; an idle process will be killed. 101 | ; Note: This value is mandatory. 102 | pm = dynamic 103 | 104 | ; The number of child processes to be created when pm is set to 'static' and the 105 | ; maximum number of child processes when pm is set to 'dynamic' or 'ondemand'. 106 | ; This value sets the limit on the number of simultaneous requests that will be 107 | ; served. Equivalent to the ApacheMaxClients directive with mpm_prefork. 108 | ; Equivalent to the PHP_FCGI_CHILDREN environment variable in the original PHP 109 | ; CGI. The below defaults are based on a server without much resources. Don't 110 | ; forget to tweak pm.* to fit your needs. 111 | ; Note: Used when pm is set to 'static', 'dynamic' or 'ondemand' 112 | ; Note: This value is mandatory. 113 | pm.max_children = 5 114 | 115 | ; The number of child processes created on startup. 116 | ; Note: Used only when pm is set to 'dynamic' 117 | ; Default Value: min_spare_servers + (max_spare_servers - min_spare_servers) / 2 118 | pm.start_servers = 2 119 | 120 | ; The desired minimum number of idle server processes. 121 | ; Note: Used only when pm is set to 'dynamic' 122 | ; Note: Mandatory when pm is set to 'dynamic' 123 | pm.min_spare_servers = 1 124 | 125 | ; The desired maximum number of idle server processes. 126 | ; Note: Used only when pm is set to 'dynamic' 127 | ; Note: Mandatory when pm is set to 'dynamic' 128 | pm.max_spare_servers = 3 129 | 130 | ; The number of seconds after which an idle process will be killed. 131 | ; Note: Used only when pm is set to 'ondemand' 132 | ; Default Value: 10s 133 | ;pm.process_idle_timeout = 10s; 134 | 135 | ; The number of requests each child process should execute before respawning. 136 | ; This can be useful to work around memory leaks in 3rd party libraries. For 137 | ; endless request processing specify '0'. Equivalent to PHP_FCGI_MAX_REQUESTS. 138 | ; Default Value: 0 139 | ;pm.max_requests = 500 140 | 141 | ; The URI to view the FPM status page. If this value is not set, no URI will be 142 | ; recognized as a status page. It shows the following informations: 143 | ; pool - the name of the pool; 144 | ; process manager - static, dynamic or ondemand; 145 | ; start time - the date and time FPM has started; 146 | ; start since - number of seconds since FPM has started; 147 | ; accepted conn - the number of request accepted by the pool; 148 | ; listen queue - the number of request in the queue of pending 149 | ; connections (see backlog in listen(2)); 150 | ; max listen queue - the maximum number of requests in the queue 151 | ; of pending connections since FPM has started; 152 | ; listen queue len - the size of the socket queue of pending connections; 153 | ; idle processes - the number of idle processes; 154 | ; active processes - the number of active processes; 155 | ; total processes - the number of idle + active processes; 156 | ; max active processes - the maximum number of active processes since FPM 157 | ; has started; 158 | ; max children reached - number of times, the process limit has been reached, 159 | ; when pm tries to start more children (works only for 160 | ; pm 'dynamic' and 'ondemand'); 161 | ; Value are updated in real time. 162 | ; Example output: 163 | ; pool: www 164 | ; process manager: static 165 | ; start time: 01/Jul/2011:17:53:49 +0200 166 | ; start since: 62636 167 | ; accepted conn: 190460 168 | ; listen queue: 0 169 | ; max listen queue: 1 170 | ; listen queue len: 42 171 | ; idle processes: 4 172 | ; active processes: 11 173 | ; total processes: 15 174 | ; max active processes: 12 175 | ; max children reached: 0 176 | ; 177 | ; By default the status page output is formatted as text/plain. Passing either 178 | ; 'html', 'xml' or 'json' in the query string will return the corresponding 179 | ; output syntax. Example: 180 | ; http://www.foo.bar/status 181 | ; http://www.foo.bar/status?json 182 | ; http://www.foo.bar/status?html 183 | ; http://www.foo.bar/status?xml 184 | ; 185 | ; By default the status page only outputs short status. Passing 'full' in the 186 | ; query string will also return status for each pool process. 187 | ; Example: 188 | ; http://www.foo.bar/status?full 189 | ; http://www.foo.bar/status?json&full 190 | ; http://www.foo.bar/status?html&full 191 | ; http://www.foo.bar/status?xml&full 192 | ; The Full status returns for each process: 193 | ; pid - the PID of the process; 194 | ; state - the state of the process (Idle, Running, ...); 195 | ; start time - the date and time the process has started; 196 | ; start since - the number of seconds since the process has started; 197 | ; requests - the number of requests the process has served; 198 | ; request duration - the duration in µs of the requests; 199 | ; request method - the request method (GET, POST, ...); 200 | ; request URI - the request URI with the query string; 201 | ; content length - the content length of the request (only with POST); 202 | ; user - the user (PHP_AUTH_USER) (or '-' if not set); 203 | ; script - the main script called (or '-' if not set); 204 | ; last request cpu - the %cpu the last request consumed 205 | ; it's always 0 if the process is not in Idle state 206 | ; because CPU calculation is done when the request 207 | ; processing has terminated; 208 | ; last request memory - the max amount of memory the last request consumed 209 | ; it's always 0 if the process is not in Idle state 210 | ; because memory calculation is done when the request 211 | ; processing has terminated; 212 | ; If the process is in Idle state, then informations are related to the 213 | ; last request the process has served. Otherwise informations are related to 214 | ; the current request being served. 215 | ; Example output: 216 | ; ************************ 217 | ; pid: 31330 218 | ; state: Running 219 | ; start time: 01/Jul/2011:17:53:49 +0200 220 | ; start since: 63087 221 | ; requests: 12808 222 | ; request duration: 1250261 223 | ; request method: GET 224 | ; request URI: /test_mem.php?N=10000 225 | ; content length: 0 226 | ; user: - 227 | ; script: /home/fat/web/docs/php/test_mem.php 228 | ; last request cpu: 0.00 229 | ; last request memory: 0 230 | ; 231 | ; Note: There is a real-time FPM status monitoring sample web page available 232 | ; It's available in: /usr/local/share/php/fpm/status.html 233 | ; 234 | ; Note: The value must start with a leading slash (/). The value can be 235 | ; anything, but it may not be a good idea to use the .php extension or it 236 | ; may conflict with a real PHP file. 237 | ; Default Value: not set 238 | pm.status_path = /status 239 | 240 | ; The ping URI to call the monitoring page of FPM. If this value is not set, no 241 | ; URI will be recognized as a ping page. This could be used to test from outside 242 | ; that FPM is alive and responding, or to 243 | ; - create a graph of FPM availability (rrd or such); 244 | ; - remove a server from a group if it is not responding (load balancing); 245 | ; - trigger alerts for the operating team (24/7). 246 | ; Note: The value must start with a leading slash (/). The value can be 247 | ; anything, but it may not be a good idea to use the .php extension or it 248 | ; may conflict with a real PHP file. 249 | ; Default Value: not set 250 | ping.path = /health 251 | 252 | ; This directive may be used to customize the response of a ping request. The 253 | ; response is formatted as text/plain with a 200 response code. 254 | ; Default Value: pong 255 | ping.response = OK 256 | 257 | ; The access log file 258 | ; Default: not set 259 | ;access.log = log/$pool.access.log 260 | 261 | ; The access log format. 262 | ; The following syntax is allowed 263 | ; %%: the '%' character 264 | ; %C: %CPU used by the request 265 | ; it can accept the following format: 266 | ; - %{user}C for user CPU only 267 | ; - %{system}C for system CPU only 268 | ; - %{total}C for user + system CPU (default) 269 | ; %d: time taken to serve the request 270 | ; it can accept the following format: 271 | ; - %{seconds}d (default) 272 | ; - %{miliseconds}d 273 | ; - %{mili}d 274 | ; - %{microseconds}d 275 | ; - %{micro}d 276 | ; %e: an environment variable (same as $_ENV or $_SERVER) 277 | ; it must be associated with embraces to specify the name of the env 278 | ; variable. Some exemples: 279 | ; - server specifics like: %{REQUEST_METHOD}e or %{SERVER_PROTOCOL}e 280 | ; - HTTP headers like: %{HTTP_HOST}e or %{HTTP_USER_AGENT}e 281 | ; %f: script filename 282 | ; %l: content-length of the request (for POST request only) 283 | ; %m: request method 284 | ; %M: peak of memory allocated by PHP 285 | ; it can accept the following format: 286 | ; - %{bytes}M (default) 287 | ; - %{kilobytes}M 288 | ; - %{kilo}M 289 | ; - %{megabytes}M 290 | ; - %{mega}M 291 | ; %n: pool name 292 | ; %o: output header 293 | ; it must be associated with embraces to specify the name of the header: 294 | ; - %{Content-Type}o 295 | ; - %{X-Powered-By}o 296 | ; - %{Transfert-Encoding}o 297 | ; - .... 298 | ; %p: PID of the child that serviced the request 299 | ; %P: PID of the parent of the child that serviced the request 300 | ; %q: the query string 301 | ; %Q: the '?' character if query string exists 302 | ; %r: the request URI (without the query string, see %q and %Q) 303 | ; %R: remote IP address 304 | ; %s: status (response code) 305 | ; %t: server time the request was received 306 | ; it can accept a strftime(3) format: 307 | ; %d/%b/%Y:%H:%M:%S %z (default) 308 | ; The strftime(3) format must be encapsuled in a %{}t tag 309 | ; e.g. for a ISO8601 formatted timestring, use: %{%Y-%m-%dT%H:%M:%S%z}t 310 | ; %T: time the log has been written (the request has finished) 311 | ; it can accept a strftime(3) format: 312 | ; %d/%b/%Y:%H:%M:%S %z (default) 313 | ; The strftime(3) format must be encapsuled in a %{}t tag 314 | ; e.g. for a ISO8601 formatted timestring, use: %{%Y-%m-%dT%H:%M:%S%z}t 315 | ; %u: remote user 316 | ; 317 | ; Default: "%R - %u %t \"%m %r\" %s" 318 | ;access.format = "%R - %u %t \"%m %r%Q%q\" %s %f %{mili}d %{kilo}M %C%%" 319 | 320 | ; The log file for slow requests 321 | ; Default Value: not set 322 | ; Note: slowlog is mandatory if request_slowlog_timeout is set 323 | ;slowlog = log/$pool.log.slow 324 | 325 | ; The timeout for serving a single request after which a PHP backtrace will be 326 | ; dumped to the 'slowlog' file. A value of '0s' means 'off'. 327 | ; Available units: s(econds)(default), m(inutes), h(ours), or d(ays) 328 | ; Default Value: 0 329 | ;request_slowlog_timeout = 0 330 | 331 | ; Depth of slow log stack trace. 332 | ; Default Value: 20 333 | ;request_slowlog_trace_depth = 20 334 | 335 | ; The timeout for serving a single request after which the worker process will 336 | ; be killed. This option should be used when the 'max_execution_time' ini option 337 | ; does not stop script execution for some reason. A value of '0' means 'off'. 338 | ; Available units: s(econds)(default), m(inutes), h(ours), or d(ays) 339 | ; Default Value: 0 340 | request_terminate_timeout = 360 341 | 342 | ; Set open file descriptor rlimit. 343 | ; Default Value: system defined value 344 | rlimit_files = 131072 345 | 346 | ; Set max core size rlimit. 347 | ; Possible Values: 'unlimited' or an integer greater or equal to 0 348 | ; Default Value: system defined value 349 | rlimit_core = unlimited 350 | 351 | ; Chroot to this directory at the start. This value must be defined as an 352 | ; absolute path. When this value is not set, chroot is not used. 353 | ; Note: you can prefix with '$prefix' to chroot to the pool prefix or one 354 | ; of its subdirectories. If the pool prefix is not set, the global prefix 355 | ; will be used instead. 356 | ; Note: chrooting is a great security feature and should be used whenever 357 | ; possible. However, all PHP paths will be relative to the chroot 358 | ; (error_log, sessions.save_path, ...). 359 | ; Default Value: not set 360 | ;chroot = 361 | 362 | ; Chdir to this directory at the start. 363 | ; Note: relative path can be used. 364 | ; Default Value: current directory or / when chroot 365 | ;chdir = /var/www 366 | 367 | ; Redirect worker stdout and stderr into main error log. If not set, stdout and 368 | ; stderr will be redirected to /dev/null according to FastCGI specs. 369 | ; Note: on highloaded environement, this can cause some delay in the page 370 | ; process time (several ms). 371 | ; Default Value: no 372 | catch_workers_output = yes 373 | 374 | ; Clear environment in FPM workers 375 | ; Prevents arbitrary environment variables from reaching FPM worker processes 376 | ; by clearing the environment in workers before env vars specified in this 377 | ; pool configuration are added. 378 | ; Setting to "no" will make all environment variables available to PHP code 379 | ; via getenv(), $_ENV and $_SERVER. 380 | ; Default Value: yes 381 | ;clear_env = no 382 | 383 | ; Limits the extensions of the main script FPM will allow to parse. This can 384 | ; prevent configuration mistakes on the web server side. You should only limit 385 | ; FPM to .php extensions to prevent malicious users to use other extensions to 386 | ; execute php code. 387 | ; Note: set an empty value to allow all extensions. 388 | ; Default Value: .php 389 | ;security.limit_extensions = .php .php3 .php4 .php5 .php7 390 | 391 | ; Pass environment variables like LD_LIBRARY_PATH. All $VARIABLEs are taken from 392 | ; the current environment. 393 | ; Default Value: clean env 394 | ;env[HOSTNAME] = $HOSTNAME 395 | ;env[PATH] = /usr/local/bin:/usr/bin:/bin 396 | ;env[TMP] = /tmp 397 | ;env[TMPDIR] = /tmp 398 | ;env[TEMP] = /tmp 399 | 400 | ; Additional php.ini defines, specific to this pool of workers. These settings 401 | ; overwrite the values previously defined in the php.ini. The directives are the 402 | ; same as the PHP SAPI: 403 | ; php_value/php_flag - you can set classic ini defines which can 404 | ; be overwritten from PHP call 'ini_set'. 405 | ; php_admin_value/php_admin_flag - these directives won't be overwritten by 406 | ; PHP call 'ini_set' 407 | ; For php_*flag, valid values are on, off, 1, 0, true, false, yes or no. 408 | 409 | ; Defining 'extension' will load the corresponding shared extension from 410 | ; extension_dir. Defining 'disable_functions' or 'disable_classes' will not 411 | ; overwrite previously defined php.ini values, but will append the new value 412 | ; instead. 413 | 414 | ; Note: path INI options can be relative and will be expanded with the prefix 415 | ; (pool, global or /usr/local) 416 | 417 | ; Default Value: nothing is defined by default except the values in php.ini and 418 | ; specified at startup with the -d argument 419 | ;php_admin_value[sendmail_path] = /usr/sbin/sendmail -t -i -f www@my.domain.com 420 | ;php_flag[display_errors] = off 421 | ;php_admin_value[error_log] = /var/log/fpm-php.www.log 422 | ;php_admin_flag[log_errors] = on 423 | ;php_admin_value[memory_limit] = 32M 424 | -------------------------------------------------------------------------------- /7.0/docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: "3" 2 | 3 | services: 4 | php70: 5 | build: 6 | context: ./ 7 | dockerfile: Dockerfile 8 | depends_on: 9 | - redis 10 | hostname: php70 11 | container_name: php70 12 | volumes: 13 | - ./configs:/cfgs 14 | env_file: .env 15 | 16 | redis: 17 | image: redis:latest 18 | -------------------------------------------------------------------------------- /7.0/scripts/crontab.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | if [ ! "$PHP_CRONTABS_PATH" == "" ]; then 4 | echo "env CRONTABS_PATH: setting up crontabs [ $PHP_CRONTABS_PATH ]:"; 5 | 6 | for f in ${PHP_CRONTABS_PATH}; do 7 | echo " - $f"; 8 | rm -f /etc/cron.d/${f##*/} 9 | cp $f /etc/cron.d/ 10 | chmod 0644 /etc/cron.d/${f##*/} 11 | done 12 | 13 | touch /var/log/cron.log 14 | printenv | grep -v "no_proxy" >> /etc/default/locale 15 | /etc/init.d/cron start > /dev/null 16 | fi 17 | -------------------------------------------------------------------------------- /7.0/scripts/docker-boot: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | echo "[`date +"%d-%b-%Y %T"`] PHP-FPM Docker container boot" 4 | 5 | ### create system user for php pool 6 | if [ ! "$PHP_USER" == "" ] && [ ! "$PHP_UID" == "" ] && [ ! "$PHP_GID" == "" ] && [ ! "$PHP_HOME" == "" ]; then 7 | echo "env PHP_USER: creating new system user: ${PHP_USER} ${PHP_UID}:${PHP_GID} ${PHP_HOME}" 8 | mkdir -p $PHP_HOME && \ 9 | groupadd -f $PHP_USER -g $PHP_GID && \ 10 | useradd -d $PHP_HOME -u $PHP_UID -g $PHP_GID -s /usr/sbin/nologin $PHP_USER 11 | fi 12 | 13 | 14 | ### load PHP ini configurations 15 | if [ ! "$PHP_INI_PATH" == "" ]; then 16 | echo "env PHP_INI_PATH: copy from [ $PHP_INI_PATH ] into [ /usr/local/etc/php/conf.d/ ] folder" 17 | for f in ${PHP_INI_PATH}; do 18 | echo " - $f"; 19 | rm -f /usr/local/etc/php/conf.d/${f##*/} 20 | cp $f /usr/local/etc/php/conf.d/ 21 | done 22 | fi 23 | 24 | 25 | ### make sure to create clean php-fpm.conf 26 | ### to avoid adding multiple times the same lines next 27 | ### in case container is restarting 28 | echo "[global]" > /usr/local/etc/php-fpm.conf 29 | echo "include=etc/php-fpm.d/*.conf" >> /usr/local/etc/php-fpm.conf 30 | 31 | ### load PHP-FPM pool configurations 32 | if [ ! "$PHP_POOL_PATH" == "" ]; then 33 | echo "env PHP_POOL_PATH: copy from [ $PHP_POOL_PATH ] into [ /usr/local/etc/php-fpm.d/ ] folder" 34 | for f in ${PHP_POOL_PATH}; do 35 | echo " - $f"; 36 | rm -f /usr/local/etc/php-fpm.d/${f##*/} 37 | cp $f /usr/local/etc/php-fpm.d/ 38 | done 39 | fi 40 | 41 | 42 | ### scan for config files in folders from PHP_INI_SCAN_DIR 43 | if [ ! -z ${PHP_INI_SCAN_DIR+x} ] && [ "$PHP_INI_SCAN_DIR" != "" ] ; then 44 | echo "env PHP_INI_SCAN_DIR: copy from [ $PHP_INI_SCAN_DIR ] into [ /usr/local/etc/php-fpm.d/ ] folder" 45 | 46 | ### break down path by : separator 47 | IFS=':' read -ra DIRECTORIES <<< "$PHP_INI_SCAN_DIR" 48 | 49 | for DIR in "${DIRECTORIES[@]}"; do 50 | ### check if there are any php pool configuration files to copy 51 | COUNT=`ls -1 $DIR/*.conf 2>/dev/null | wc -l` 52 | 53 | if [ $COUNT != "0" ] ; then 54 | echo " - $DIR/*.conf"; 55 | cp -f $DIR/*.conf /usr/local/etc/php-fpm.d/ 56 | fi 57 | done 58 | fi 59 | 60 | 61 | ### load boot bash scripts 62 | for f in /usr/local/bin/*.sh; do 63 | /bin/bash -c $f 64 | done 65 | 66 | ### load additional on-demand scripts 67 | if [ ! -z ${PHP_BOOT_SCRIPTS+x} ] && [ "$PHP_BOOT_SCRIPTS" != "" ]; then 68 | echo "env PHP_BOOT_SCRIPTS: executing scripts in [ $PHP_BOOT_SCRIPTS ]" 69 | 70 | for f in ${PHP_BOOT_SCRIPTS}; do 71 | echo " - $f"; 72 | 73 | rm -f /usr/local/bin/${f##*/} 74 | cp $f /usr/local/bin/ 75 | 76 | chmod +x /usr/local/bin/${f##*/} 77 | done 78 | 79 | for f in ${PHP_BOOT_SCRIPTS}; do 80 | /bin/bash -c /usr/local/bin/${f##*/} 81 | done 82 | fi 83 | 84 | ### expose php version 85 | echo 86 | /usr/local/bin/php -v 87 | -------------------------------------------------------------------------------- /7.0/scripts/docker-php-entrypoint: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -e 3 | 4 | /usr/local/bin/docker-boot 5 | 6 | # first arg is `-f` or `--some-option` 7 | if [ "${1#-}" != "$1" ]; then 8 | set -- php-fpm "$@" 9 | fi 10 | 11 | exec "$@" 12 | -------------------------------------------------------------------------------- /7.0/scripts/emailtest.php: -------------------------------------------------------------------------------- 1 | /dev/null 9 | 10 | chmod u+rw,g+rw,o+rw /var/log/newrelic/newrelic-daemon.log 11 | else 12 | rm -f /usr/local/etc/php/conf.d/newrelic.ini 13 | fi 14 | -------------------------------------------------------------------------------- /7.0/scripts/phpsendmail: -------------------------------------------------------------------------------- 1 | #!/usr/local/bin/php 2 | 8 | * https://www.howtoforge.com/how-to-log-emails-sent-with-phps-mail-function-to-detect-form-spam 9 | */ 10 | 11 | $sendmail_bin = '/usr/sbin/sendmail'; 12 | 13 | // Get the email content 14 | $mail = ''; 15 | $logline = ''; 16 | $pointer = fopen('php://stdin', 'r'); 17 | 18 | while ($line = fgets($pointer)) { 19 | if (preg_match('/^to:/i', $line) || preg_match('/^from:/i', $line)) { 20 | $logline .= trim($line) . ' '; 21 | } 22 | $mail .= $line; 23 | } 24 | 25 | // Compose the sendmail command 26 | $command = 'echo ' . escapeshellarg($mail) . ' | ' . $sendmail_bin . ' -t -i'; 27 | 28 | if (isset($_SERVER['argc'])) { 29 | for ($i = 1; $i < $_SERVER['argc']; $i++) { 30 | $command .= escapeshellarg($_SERVER['argv'][$i]) . ' '; 31 | } 32 | } 33 | 34 | // Write the log 35 | error_log("Email sent: " . $logline); 36 | 37 | // Execute the command 38 | return shell_exec($command); 39 | -------------------------------------------------------------------------------- /7.0/scripts/sendgrid.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | if [ ! -z ${SENDGRID_API_KEY+x} ] && [ "$SENDGRID_API_KEY" != "" ]; then 4 | echo "env SMTP_LOGIN: sendgrid credentials for email routing"; 5 | echo "[smtp.sendgrid.net]:2525 apikey:${SENDGRID_API_KEY}" > /etc/postfix/sasl_passwd 6 | 7 | postmap /etc/postfix/sasl_passwd 8 | chmod 600 /etc/postfix/sasl_passwd.db 9 | rm /etc/postfix/sasl_passwd 10 | 11 | ### update email relay configuration for SendGrid 12 | sed -i 's/default_transport = error//g' /etc/postfix/main.cf 13 | sed -i 's/relay_transport = error//g' /etc/postfix/main.cf 14 | 15 | ### delete following lines if already exist before adding 16 | sed -i '/relayhost/d' /etc/postfix/main.cf 17 | sed -i '/smtp_tls_security_level/d' /etc/postfix/main.cf 18 | sed -i '/smtp_sasl_auth_enable/d' /etc/postfix/main.cf 19 | sed -i '/smtp_sasl_password_maps/d' /etc/postfix/main.cf 20 | sed -i '/header_size_limit/d' /etc/postfix/main.cf 21 | sed -i '/smtp_sasl_security_options/d' /etc/postfix/main.cf 22 | 23 | ### add following lines 24 | echo "relayhost = [smtp.sendgrid.net]:2525" >> /etc/postfix/main.cf 25 | echo "smtp_tls_security_level = encrypt" >> /etc/postfix/main.cf 26 | echo "smtp_sasl_auth_enable = yes" >> /etc/postfix/main.cf 27 | echo "smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd" >> /etc/postfix/main.cf 28 | echo "header_size_limit = 4096000" >> /etc/postfix/main.cf 29 | echo "smtp_sasl_security_options = noanonymous" >> /etc/postfix/main.cf 30 | 31 | /etc/init.d/postfix start > /dev/null 32 | 33 | ### send test email if TEST_EMAIL env variable is set 34 | if [ ! -z ${TEST_EMAIL+x} ] && [ "$TEST_EMAIL" != "" ]; then 35 | echo " - sending test email to: [ $TEST_EMAIL ]"; 36 | php /usr/local/bin/emailtest.php 37 | fi 38 | fi 39 | -------------------------------------------------------------------------------- /7.0/scripts/session.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | ### update PHP session handler 4 | if [ ! "$PHP_SESSION_HANDLER" == "" ] && [ ! "$PHP_SESSION_PATH" == "" ]; then 5 | echo "env PHP_SESSION_HANDLER: updating php session handler [ $PHP_SESSION_PATH ]" 6 | echo "session.save_handler = $PHP_SESSION_HANDLER" > /usr/local/etc/php/conf.d/zz-session.ini 7 | echo "session.save_path = \"$PHP_SESSION_PATH\"" >> /usr/local/etc/php/conf.d/zz-session.ini 8 | fi 9 | -------------------------------------------------------------------------------- /7.1/.gitignore: -------------------------------------------------------------------------------- 1 | .env 2 | -------------------------------------------------------------------------------- /7.1/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM php:7.1-fpm 2 | 3 | MAINTAINER Mark Hilton 4 | 5 | RUN apt-get update && \ 6 | apt-get install -y --no-install-recommends \ 7 | git \ 8 | libmemcached-dev \ 9 | libz-dev \ 10 | libpq-dev \ 11 | libjpeg-dev \ 12 | libfreetype6-dev \ 13 | libssl-dev \ 14 | libmcrypt-dev 15 | 16 | RUN docker-php-ext-install mcrypt 17 | RUN docker-php-ext-install mysqli pdo pdo_mysql 18 | 19 | # install the PHP gd library 20 | RUN docker-php-ext-configure gd \ 21 | --enable-gd-native-ttf \ 22 | --with-jpeg-dir=/usr/lib \ 23 | --with-freetype-dir=/usr/include/freetype2 && \ 24 | docker-php-ext-install gd 25 | 26 | # install the soap extension 27 | RUN apt-get update -yqq && \ 28 | apt-get -y install libxml2-dev && \ 29 | docker-php-ext-install soap 30 | 31 | # install Php Redis Extension 32 | RUN pecl install -o -f redis \ 33 | && rm -rf /tmp/pear \ 34 | && docker-php-ext-enable redis 35 | 36 | # install the mongodb extension 37 | RUN pecl install mongodb && \ 38 | docker-php-ext-enable mongodb 39 | 40 | # install bcmath, mbstring and zip extensions 41 | RUN docker-php-ext-install bcmath && \ 42 | docker-php-ext-install mbstring && \ 43 | docker-php-ext-install zip 44 | 45 | # enable Exif PHP extentions requirements 46 | RUN docker-php-ext-install exif 47 | 48 | # tokenizer Modifications: 49 | RUN docker-php-ext-install tokenizer 50 | 51 | # install intl and requirements 52 | RUN apt-get update -yqq && \ 53 | apt-get install -y zlib1g-dev libicu-dev g++ && \ 54 | docker-php-ext-configure intl && \ 55 | docker-php-ext-install intl 56 | 57 | # install the ghostscript extension for PDF editing 58 | RUN apt-get update -yqq \ 59 | && apt-get install -y \ 60 | poppler-utils \ 61 | ghostscript 62 | 63 | # LDAP: 64 | RUN apt-get update -yqq && \ 65 | apt-get install -y libldap2-dev && \ 66 | docker-php-ext-configure ldap --with-libdir=lib/x86_64-linux-gnu/ && \ 67 | docker-php-ext-install ldap 68 | 69 | RUN yes "" | pecl install msgpack-beta \ 70 | && echo "extension=msgpack.so" > /usr/local/etc/php/conf.d/ext-msgpack.ini 71 | 72 | # compile igbinary extension 73 | RUN cd /tmp/ && git clone https://github.com/igbinary/igbinary "php-igbinary" && \ 74 | cd php-igbinary && \ 75 | phpize && \ 76 | ./configure && \ 77 | make && \ 78 | make install && \ 79 | make clean && \ 80 | docker-php-ext-enable igbinary 81 | 82 | # curl extension 83 | RUN apt-get install -y curl libcurl4-openssl-dev --no-install-recommends && \ 84 | docker-php-ext-install curl 85 | 86 | # data structures extension 87 | RUN pecl install ds && \ 88 | docker-php-ext-enable ds 89 | 90 | # imagick 91 | RUN apt-get update && apt-get install -y libmagickwand-6.q16-dev --no-install-recommends && \ 92 | ln -s /usr/lib/x86_64-linux-gnu/ImageMagick-6.8.9/bin-Q16/MagickWand-config /usr/bin && \ 93 | pecl install imagick && \ 94 | echo "extension=imagick.so" > /usr/local/etc/php/conf.d/ext-imagick.ini 95 | 96 | # ssh2 module 97 | RUN apt-get install -y libssh2-1-dev && \ 98 | pecl install ssh2-1.0 && \ 99 | docker-php-ext-enable ssh2 100 | 101 | # php-module: curl dom bz2 gd json mysqli pcntl pdo pdo_mysql phar posix 102 | RUN apt-get install -y libxml2-dev libbz2-dev re2c libpng++-dev \ 103 | libjpeg-dev libvpx-dev zlib1g-dev libgd-dev \ 104 | libtidy-dev libxslt1-dev libmagic-dev libexif-dev file \ 105 | sqlite3 libsqlite3-dev libxslt-dev 106 | 107 | RUN export CFLAGS="-I/usr/src/php" && \ 108 | docker-php-ext-install xmlreader xmlwriter 109 | 110 | RUN docker-php-ext-configure json && \ 111 | docker-php-ext-configure session && \ 112 | docker-php-ext-configure ctype && \ 113 | docker-php-ext-configure tokenizer && \ 114 | docker-php-ext-configure simplexml && \ 115 | docker-php-ext-configure dom && \ 116 | docker-php-ext-configure mbstring && \ 117 | docker-php-ext-configure zip && \ 118 | docker-php-ext-configure pdo && \ 119 | docker-php-ext-configure pdo_sqlite && \ 120 | docker-php-ext-configure pdo_mysql && \ 121 | docker-php-ext-configure mysqli && \ 122 | docker-php-ext-configure iconv && \ 123 | docker-php-ext-configure xml && \ 124 | docker-php-ext-configure phar 125 | 126 | RUN docker-php-ext-install \ 127 | dom \ 128 | bz2 \ 129 | json \ 130 | pcntl \ 131 | phar \ 132 | posix \ 133 | simplexml \ 134 | soap \ 135 | tidy \ 136 | xml \ 137 | xmlrpc \ 138 | xsl \ 139 | calendar \ 140 | ctype \ 141 | fileinfo \ 142 | ftp \ 143 | sysvmsg \ 144 | sysvsem \ 145 | sysvshm 146 | 147 | # install the php memcache & memcached extension 148 | RUN set -x \ 149 | && apt-get update && apt-get install -y --no-install-recommends unzip libssl-dev libpcre3 libpcre3-dev \ 150 | && cd /tmp \ 151 | && curl -sSL -o php7.zip https://github.com/websupport-sk/pecl-memcache/archive/php7.zip \ 152 | && unzip php7 \ 153 | && cd pecl-memcache-php7 \ 154 | && /usr/local/bin/phpize \ 155 | && ./configure --with-php-config=/usr/local/bin/php-config \ 156 | && make \ 157 | && make install \ 158 | && echo "extension=memcache.so" > /usr/local/etc/php/conf.d/ext-memcache.ini \ 159 | && rm -rf /tmp/pecl-memcache-php7 php7.zip 160 | 161 | RUN curl -L -o /tmp/memcached.tar.gz "https://github.com/php-memcached-dev/php-memcached/archive/php7.tar.gz" \ 162 | && mkdir -p memcached \ 163 | && tar -C memcached -zxvf /tmp/memcached.tar.gz --strip 1 \ 164 | && ( \ 165 | cd memcached \ 166 | && phpize \ 167 | && ./configure \ 168 | && make -j$(nproc) \ 169 | && make install \ 170 | ) \ 171 | && rm -r memcached \ 172 | && rm /tmp/memcached.tar.gz \ 173 | && docker-php-ext-enable memcached 174 | 175 | # mhash 176 | RUN apt-get install -y libmhash2 libmhash-dev libc-client-dev libkrb5-dev 177 | 178 | RUN docker-php-ext-configure imap --with-kerberos --with-imap-ssl \ 179 | && docker-php-ext-install imap 180 | 181 | RUN docker-php-ext-configure hash --with-mhash && \ 182 | docker-php-ext-install hash 183 | 184 | # Opcache 185 | RUN docker-php-ext-install opcache 186 | 187 | # install APCu 188 | RUN pecl install apcu-5.1.8 && \ 189 | pecl install apcu_bc-1.0.3 && \ 190 | docker-php-ext-enable apcu --ini-name 10-docker-php-ext-apcu.ini && \ 191 | docker-php-ext-enable apc --ini-name 20-docker-php-ext-apc.ini 192 | 193 | # install MSSQL support 194 | # install ODBC driver 195 | RUN apt-get update -y && apt-get install -y apt-transport-https locales gnupg 196 | RUN curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add - && \ 197 | curl https://packages.microsoft.com/config/debian/8/prod.list > /etc/apt/sources.list.d/mssql-release.list && \ 198 | export DEBIAN_FRONTEND=noninteractive && apt-get update -y && \ 199 | ACCEPT_EULA=Y apt-get install -y msodbcsql unixodbc-dev 200 | RUN set -xe \ 201 | && pecl install pdo_sqlsrv \ 202 | && docker-php-ext-enable pdo_sqlsrv \ 203 | && apt-get purge -y unixodbc-dev && apt-get autoremove -y && apt-get clean 204 | 205 | # set locale to utf-8 206 | RUN echo "en_US.UTF-8 UTF-8" > /etc/locale.gen && \ 207 | locale-gen 208 | ENV LANG='en_US.UTF-8' LANGUAGE='en_US:en' LC_ALL='en_US.UTF-8' 209 | 210 | # geoip - DEPRECIATED: using provided by Nginx container 211 | # RUN runtimeRequirements="libgeoip-dev" \ 212 | # && apt-get update && apt-get install -y ${runtimeRequirements} \ 213 | # && pecl install geoip-1.1.1 \ 214 | # && printf "extension=geoip.so\n[geoip]\ngeoip.custom_directory = /usr/share/GeoIP/\n" > /usr/local/etc/php/conf.d/ext-geoip.ini 215 | 216 | # RUN mkdir -p /usr/share/GeoIP && cd /usr/share/GeoIP/ && \ 217 | # rm -f GeoIP.dat GeoIPv6.dat && \ 218 | # curl -L -O http://geolite.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz && \ 219 | # curl -L -O http://geolite.maxmind.com/download/geoip/database/GeoLiteCountry/GeoIP.dat.gz && \ 220 | # gzip -d * && \ 221 | # mv GeoLiteCity.dat GeoIPCity.dat 222 | 223 | # 224 | #-------------------------------------------------------------------------- 225 | # Final Touches 226 | #-------------------------------------------------------------------------- 227 | # 228 | 229 | # install helpful libs 230 | RUN apt-get -y install libfcgi0ldbl nano cron 231 | 232 | # crontab fix: https://stackoverflow.com/questions/43323754/cannot-make-remove-an-entry-for-the-specified-session-cron 233 | RUN sed -i '/session required pam_loginuid.so/c\#session required pam_loginuid.so' /etc/pam.d/cron 234 | 235 | # expose /status for health check & stop access log 236 | RUN echo "pm.status_path = /status" >> /usr/local/etc/php/conf.d/zz-docker.conf && \ 237 | echo "ping.path = /ping" >> /usr/local/etc/php/conf.d/zz-docker.conf && \ 238 | echo "ping.response = OK" >> /usr/local/etc/php/conf.d/zz-docker.conf && \ 239 | echo "access.log = /proc/self/fd/1" >> /usr/local/etc/php/conf.d/zz-docker.conf 240 | 241 | # composer 242 | # consider removing to a separate container 243 | # RUN curl -sS https://getcomposer.org/installer | php && mv composer.phar /usr/local/bin/composer && chmod +x /usr/local/bin/composer 244 | # ENV PATH="$PATH:/root/.composer/vendor/bin" 245 | 246 | # install modman 247 | # RUN curl -s -L https://raw.github.com/colinmollenhour/modman/master/modman-installer | bash && \ 248 | # mv ~/bin/modman /usr/sbin/ 249 | 250 | # install NewRelic agent 251 | RUN echo 'deb http://apt.newrelic.com/debian/ newrelic non-free' | tee /etc/apt/sources.list.d/newrelic.list && \ 252 | curl https://download.newrelic.com/548C16BF.gpg | apt-key add - && \ 253 | apt-get -y update && \ 254 | DEBIAN_FRONTEND=noninteractive apt-get -y install newrelic-php5 newrelic-sysmond && \ 255 | export NR_INSTALL_SILENT=1 && newrelic-install install 256 | 257 | # install blackfire.io profiler 258 | # RUN version=$(php -r "echo PHP_MAJOR_VERSION.PHP_MINOR_VERSION;") \ 259 | # && curl -A "Docker" -o /tmp/blackfire-probe.tar.gz -D - -L -s https://blackfire.io/api/v1/releases/probe/php/linux/amd64/$version \ 260 | # && tar zxpf /tmp/blackfire-probe.tar.gz -C /tmp \ 261 | # && mv /tmp/blackfire-*.so $(php -r "echo ini_get('extension_dir');")/blackfire.so \ 262 | # && printf "extension=blackfire.so\nblackfire.agent_socket=tcp://blackfire:8707\n" > $PHP_INI_DIR/conf.d/blackfire.ini 263 | 264 | # install SendGrid 265 | RUN echo "postfix postfix/mailname string localhost" | debconf-set-selections && \ 266 | echo "postfix postfix/main_mailer_type string 'Internet Site'" | debconf-set-selections && \ 267 | DEBIAN_FRONTEND=noninteractive apt-get install postfix libsasl2-modules -y 268 | 269 | # install shared PHP code 270 | RUN git clone https://github.com/nrk/predis.git /usr/local/lib/php/predis && \ 271 | git clone https://github.com/markhilton/redis-http-cache.git /usr/local/lib/php/redis-http-cache 272 | 273 | # Set default work directory 274 | ADD scripts/* /usr/local/bin/ 275 | RUN chmod +x /usr/local/bin/* 276 | 277 | # install aliases 278 | RUN echo "" >> ~/.bashrc && \ 279 | echo "# Load Custom Aliases" >> ~/.bashrc && \ 280 | echo "source /usr/local/bin/aliases.sh" >> ~/.bashrc && \ 281 | echo "" >> ~/.bashrc && \ 282 | sed -i 's/\r//' /usr/local/bin/aliases.sh && \ 283 | sed -i 's/^#! \/bin\/sh/#! \/bin\/bash/' /usr/local/bin/aliases.sh 284 | 285 | # Clean up 286 | RUN apt-get autoremove -y && apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* 287 | 288 | # Health check 289 | HEALTHCHECK --interval=5s --timeout=3s \ 290 | CMD SCRIPT_NAME=/status SCRIPT_FILENAME=/status REQUEST_METHOD=GET cgi-fcgi -bind -connect 127.0.0.1:9000 || exit 1 291 | 292 | EXPOSE 9000 293 | WORKDIR /app 294 | 295 | CMD ["php-fpm"] 296 | -------------------------------------------------------------------------------- /7.1/docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: '3' 2 | 3 | services: 4 | 5 | php70: 6 | image: crunchgeek/php-fpm:7.0.r1 7 | restart: always 8 | hostname: php70 9 | container_name: php70 10 | environment: 11 | - ENDPOINT=${ENDPOINT} 12 | - FILESYSTEM=${FILESYSTEM} 13 | - APPLICATIONS=${APPLICATIONS} 14 | - NEWRELIC_LICENSE=${NEWRELIC_LICENSE} 15 | - SMTP_LOGIN=${SMTP_LOGIN} 16 | - SMTP_PASSWORD=${SMTP_PASSWORD} 17 | volumes: 18 | - ${APPLICATIONS}:/applications 19 | - configurations:/usr/local/etc/sites/ 20 | 21 | volumes: 22 | configurations: 23 | -------------------------------------------------------------------------------- /7.1/scripts/aliases.sh: -------------------------------------------------------------------------------- 1 | #! /bin/bash 2 | 3 | # Colors used for status updates 4 | ESC_SEQ="\x1b[" 5 | COL_RESET=$ESC_SEQ"39;49;00m" 6 | COL_RED=$ESC_SEQ"31;01m" 7 | COL_GREEN=$ESC_SEQ"32;01m" 8 | COL_YELLOW=$ESC_SEQ"33;01m" 9 | COL_BLUE=$ESC_SEQ"34;01m" 10 | COL_MAGENTA=$ESC_SEQ"35;01m" 11 | COL_CYAN=$ESC_SEQ"36;01m" 12 | 13 | # Detect which `ls` flavor is in use 14 | if ls --color > /dev/null 2>&1; then # GNU `ls` 15 | colorflag="--color" 16 | export LS_COLORS='no=00:fi=00:di=01;31:ln=01;36:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arj=01;31:*.taz=01;31:*.lzh=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.gz=01;31:*.bz2=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.jpg=01;35:*.jpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.avi=01;35:*.fli=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.ogg=01;35:*.mp3=01;35:*.wav=01;35:' 17 | else # macOS `ls` 18 | colorflag="-G" 19 | export LSCOLORS='BxBxhxDxfxhxhxhxhxcxcx' 20 | fi 21 | 22 | # List all files colorized in long format 23 | #alias l="ls -lF ${colorflag}" 24 | ### MEGA: I want l and la ti return hisdden files 25 | alias l="ls -laF ${colorflag}" 26 | 27 | # List all files colorized in long format, including dot files 28 | alias la="ls -laF ${colorflag}" 29 | 30 | # List only directories 31 | alias lsd="ls -lF ${colorflag} | grep --color=never '^d'" 32 | 33 | # Always use color output for `ls` 34 | alias ls="command ls ${colorflag}" 35 | 36 | # Commonly Used Aliases 37 | alias ..="cd .." 38 | alias ...="cd ../.." 39 | alias ....="cd ../../.." 40 | alias .....="cd ../../../.." 41 | alias ~="cd ~" # `cd` is probably faster to type though 42 | alias -- -="cd -" 43 | alias home="cd ~" 44 | 45 | alias h="history" 46 | alias j="jobs" 47 | alias e='exit' 48 | alias c="clear" 49 | alias cla="clear && ls -l" 50 | alias cll="clear && ls -la" 51 | alias cls="clear && ls" 52 | alias code="cd /var/www" 53 | alias ea="vi ~/aliases" 54 | 55 | # Always enable colored `grep` output 56 | # Note: `GREP_OPTIONS="--color=auto"` is deprecated, hence the alias usage. 57 | alias grep='grep --color=auto' 58 | alias fgrep='fgrep --color=auto' 59 | alias egrep='egrep --color=auto' 60 | 61 | alias art="php artisan" 62 | alias artisan="php artisan" 63 | alias cdump="composer dump-autoload -o" 64 | alias composer:dump="composer dump-autoload -o" 65 | alias db:reset="php artisan migrate:reset && php artisan migrate --seed" 66 | alias dusk="php artisan dusk" 67 | alias fresh="php artisan migrate:fresh" 68 | alias migrate="php artisan migrate" 69 | alias refresh="php artisan migrate:refresh" 70 | alias rollback="php artisan migrate:rollback" 71 | alias seed="php artisan:seed" 72 | alias serve="php artisan serve --quiet &" 73 | 74 | alias phpunit="./vendor/bin/phpunit" 75 | alias pu="phpunit" 76 | alias puf="phpunit --filter" 77 | alias pud='phpunit --debug' 78 | 79 | alias cc='codecept' 80 | alias ccb='codecept build' 81 | alias ccr='codecept run' 82 | alias ccu='codecept run unit' 83 | alias ccf='codecept run functional' 84 | 85 | alias g="gulp" 86 | alias npm-global="npm list -g --depth 0" 87 | alias ra="reload" 88 | alias reload="source ~/.aliases && echo \"$COL_GREEN ==> Aliases Reloaded... $COL_RESET \n \"" 89 | alias run="npm run" 90 | alias tree="xtree" 91 | 92 | # Xvfb 93 | alias xvfb="Xvfb -ac :0 -screen 0 1024x768x16 &" 94 | 95 | # requires installation of 'https://www.npmjs.com/package/npms-cli' 96 | alias npms="npms search" 97 | # requires installation of 'https://www.npmjs.com/package/package-menu-cli' 98 | alias pm="package-menu" 99 | # requires installation of 'https://www.npmjs.com/package/pkg-version-cli' 100 | alias pv="package-version" 101 | # requires installation of 'https://github.com/sindresorhus/latest-version-cli' 102 | alias lv="latest-version" 103 | 104 | # git aliases 105 | alias gaa="git add ." 106 | alias gd="git --no-pager diff" 107 | alias git-revert="git reset --hard && git clean -df" 108 | alias gs="git status" 109 | alias whoops="git reset --hard && git clean -df" 110 | 111 | # Create a new directory and enter it 112 | function mkd() { 113 | mkdir -p "$@" && cd "$@" 114 | } 115 | 116 | function md() { 117 | mkdir -p "$@" && cd "$@" 118 | } 119 | 120 | function xtree { 121 | find ${1:-.} -print | sed -e 's;[^/]*/;|____;g;s;____|; |;g' 122 | } 123 | 124 | # `tre` is a shorthand for `tree` with hidden files and color enabled, ignoring 125 | # the `.git` directory, listing directories first. The output gets piped into 126 | # `less` with options to preserve color and line numbers, unless the output is 127 | # small enough for one screen. 128 | function tre() { 129 | tree -aC -I '.git|node_modules|bower_components' --dirsfirst "$@" | less -FRNX; 130 | } 131 | 132 | # Determine size of a file or total size of a directory 133 | function fs() { 134 | if du -b /dev/null > /dev/null 2>&1; then 135 | local arg=-sbh; 136 | else 137 | local arg=-sh; 138 | fi 139 | if [[ -n "$@" ]]; then 140 | du $arg -- "$@"; 141 | else 142 | du $arg .[^.]* ./*; 143 | fi; 144 | } 145 | -------------------------------------------------------------------------------- /7.1/scripts/crontab.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | if [ ! -z ${PHP_CRONTABS_PATH+x} ] && [ "$PHP_CRONTABS_PATH" != "" ]; then 4 | printf "env CRONTABS_PATH: setting up crontabs: "; 5 | 6 | for f in ${PHP_CRONTABS_PATH}; do 7 | printf "$f, "; 8 | rm -f /etc/cron.d/${f##*/} 9 | cp $f /etc/cron.d/ 10 | chmod 0644 /etc/cron.d/${f##*/} 11 | done 12 | 13 | echo 14 | printenv | grep -v "no_proxy" >> /etc/environment 15 | 16 | /etc/init.d/cron start > /dev/null 17 | fi 18 | -------------------------------------------------------------------------------- /7.1/scripts/docker-boot: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | /usr/local/bin/php -v 4 | 5 | ### create system user for php pool 6 | if [ ! -z ${PHP_USER+x} ] && [ ! -z ${PHP_UID+x} ] && [ ! -z ${PHP_GID+x} ] && [ ! -z ${PHP_HOME+x} ] && [ "$PHP_USER" != "" ] && [ "$PHP_UID" != "" ] && [ "$PHP_GID" != "" ] && [ "$PHP_HOME" != "" ]; then 7 | echo "env PHP_USER: creating new system user: ${PHP_USER} ${PHP_UID}:${PHP_GID} ${PHP_HOME}" 8 | groupadd -f $PHP_USER -g $PHP_GID && \ 9 | useradd -d $PHP_HOME -u $PHP_UID -g $PHP_GID -s /bin/false $PHP_USER 10 | fi 11 | 12 | ### load PHP ini configurations 13 | if [ ! -z ${PHP_INI_PATH+x} ] && [ "$PHP_INI_PATH" != "" ]; then 14 | printf "env PHP_INI_PATH: " 15 | for f in ${PHP_INI_PATH}; do 16 | printf "$f, "; 17 | rm -f /usr/local/etc/php/conf.d/${f##*/} 18 | cp $f /usr/local/etc/php/conf.d/ 19 | done 20 | echo 21 | fi 22 | 23 | ### make sure to create clean php-fpm.conf 24 | ### to avoid adding multiple times the same lines next 25 | ### in case container is restarting 26 | echo "[global]" > /usr/local/etc/php-fpm.conf 27 | echo "include=etc/php-fpm.d/*.conf" >> /usr/local/etc/php-fpm.conf 28 | 29 | ### remove default www.conf pool 30 | ### and load PHP-FPM pool configurations 31 | if [ ! -z ${PHP_POOL_PATH+x} ] && [ "$PHP_POOL_PATH" != "" ]; then 32 | 33 | printf "env PHP_POOL_PATH: " 34 | for f in ${PHP_POOL_PATH}; do 35 | printf "$f, "; 36 | rm -f /usr/local/etc/php-fpm.d/${f##*/} 37 | cp $f /usr/local/etc/php-fpm.d/ 38 | done 39 | echo 40 | fi 41 | 42 | 43 | ### load boot bash scripts 44 | for f in /usr/local/bin/*.sh; do 45 | /bin/bash -c $f 46 | done 47 | 48 | 49 | ### load bash scripts 50 | if [ ! -z ${PHP_BOOT_SCRIPTS+x} ] && [ "$PHP_BOOT_SCRIPTS" != "" ]; then 51 | printf "env PHP_BOOT_SCRIPTS: " 52 | for f in ${PHP_BOOT_SCRIPTS}; do 53 | printf "$f, "; 54 | 55 | rm -f /usr/local/bin/${f##*/} 56 | cp $f /usr/local/bin/ 57 | 58 | chmod +x /usr/local/bin/${f##*/} 59 | /bin/bash -c /usr/local/bin/${f##*/} 60 | done 61 | echo 62 | fi 63 | -------------------------------------------------------------------------------- /7.1/scripts/docker-php-entrypoint: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -e 3 | 4 | /usr/local/bin/docker-boot 5 | 6 | # first arg is `-f` or `--some-option` 7 | if [ "${1#-}" != "$1" ]; then 8 | set -- php-fpm "$@" 9 | fi 10 | 11 | exec "$@" 12 | -------------------------------------------------------------------------------- /7.1/scripts/newrelic.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | if [ ! -z ${NEWRELIC_LICENSE+x} ] && [ "$NEWRELIC_LICENSE" != "" ] ; then 4 | echo "env NEWRELIC_LICENSE: setting up newrelic license" 5 | sed -i "s/REPLACE_WITH_REAL_KEY/$NEWRELIC_LICENSE/g" /usr/local/etc/php/conf.d/newrelic.ini 6 | nrsysmond-config --set license_key=$NEWRELIC_LICENSE 7 | service newrelic-sysmond start > /dev/null 8 | fi 9 | -------------------------------------------------------------------------------- /7.1/scripts/phpsendmail: -------------------------------------------------------------------------------- 1 | #!/usr/local/bin/php 2 | 8 | * https://www.howtoforge.com/how-to-log-emails-sent-with-phps-mail-function-to-detect-form-spam 9 | */ 10 | 11 | $sendmail_bin = '/usr/sbin/sendmail'; 12 | 13 | // Get the email content 14 | $mail = ''; 15 | $logline = ''; 16 | $pointer = fopen('php://stdin', 'r'); 17 | 18 | while ($line = fgets($pointer)) { 19 | if (preg_match('/^to:/i', $line) || preg_match('/^from:/i', $line)) { 20 | $logline .= trim($line) . ' '; 21 | } 22 | $mail .= $line; 23 | } 24 | 25 | // Compose the sendmail command 26 | $command = 'echo ' . escapeshellarg($mail) . ' | ' . $sendmail_bin . ' -t -i'; 27 | 28 | if (isset($_SERVER['argc'])) { 29 | for ($i = 1; $i < $_SERVER['argc']; $i++) { 30 | $command .= escapeshellarg($_SERVER['argv'][$i]) . ' '; 31 | } 32 | } 33 | 34 | // Write the log 35 | $stdout = fopen('php://stdout', 'w'); 36 | fwrite($stdout, (isset($_ENV['USER']) ? $_ENV['USER'] . ' ' : '') . $logline . ' - ' . $command . "\n"); 37 | 38 | // Execute the command 39 | return shell_exec($command); 40 | -------------------------------------------------------------------------------- /7.1/scripts/sendgrid.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | if [ ! -z ${SMTP_LOGIN+x} ] && [ ! -z ${SMTP_PASSWORD+x} ] && [ "$SMTP_LOGIN" != "" ] && [ "$SMTP_PASSWORD" != "" ]; then 4 | echo "env SMTP_LOGIN: sendgrid credentials for email routing"; 5 | echo "[smtp.sendgrid.net]:2525 ${SMTP_LOGIN}:${SMTP_PASSWORD}" >> /etc/postfix/sasl_passwd 6 | 7 | postmap /etc/postfix/sasl_passwd 8 | chmod 600 /etc/postfix/sasl_passwd.db 9 | rm /etc/postfix/sasl_passwd 10 | 11 | ### update email relay configuration for SendGrid 12 | sed -i 's/default_transport = error//g' /etc/postfix/main.cf && \ 13 | sed -i 's/relay_transport = error//g' /etc/postfix/main.cf && \ 14 | sed -i 's/relayhost = //g' /etc/postfix/main.cf && \ 15 | 16 | echo "relayhost = [smtp.sendgrid.net]:2525" >> /etc/postfix/main.cf && \ 17 | echo "smtp_tls_security_level = encrypt" >> /etc/postfix/main.cf && \ 18 | echo "smtp_sasl_auth_enable = yes" >> /etc/postfix/main.cf && \ 19 | echo "smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd" >> /etc/postfix/main.cf && \ 20 | echo "header_size_limit = 4096000" >> /etc/postfix/main.cf && \ 21 | echo "smtp_sasl_security_options = noanonymous" >> /etc/postfix/main.cf 22 | 23 | /etc/init.d/postfix start > /dev/null 24 | fi 25 | -------------------------------------------------------------------------------- /7.1/scripts/session.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | ### update PHP session handler 4 | if [ ! -z ${PHP_SESSION_HANDLER+x} ] && [ ! -z ${PHP_SESSION_PATH+x} ] && [ "$PHP_SESSION_HANDLER" != "" ] && [ "$PHP_SESSION_PATH" != "" ]; then 5 | echo "env PHP_SESSION_HANDLER: updating php session handler [ $PHP_SESSION_PATH ]" 6 | echo "session.save_handler = $PHP_SESSION_HANDLER" > /usr/local/etc/php/conf.d/zz-session.ini 7 | echo "session.save_path = \"$PHP_SESSION_PATH\"" >> /usr/local/etc/php/conf.d/zz-session.ini 8 | fi 9 | -------------------------------------------------------------------------------- /7.2/.gitignore: -------------------------------------------------------------------------------- 1 | .env 2 | test/ 3 | -------------------------------------------------------------------------------- /7.2/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM php:7.2-fpm 2 | 3 | RUN apt-get update && \ 4 | apt-get install -y --no-install-recommends \ 5 | git \ 6 | libmemcached-dev \ 7 | libz-dev \ 8 | libpq-dev \ 9 | libssl-dev libssl-doc libsasl2-dev \ 10 | libmcrypt-dev \ 11 | libxml2-dev \ 12 | zlib1g-dev libicu-dev g++ \ 13 | libldap2-dev libbz2-dev \ 14 | curl libcurl4-openssl-dev \ 15 | libenchant-dev libgmp-dev firebird-dev libib-util \ 16 | re2c libpng++-dev \ 17 | libwebp-dev libjpeg-dev libjpeg62-turbo-dev libpng-dev libxpm-dev libvpx-dev libfreetype6-dev \ 18 | libmagick++-dev \ 19 | libmagickwand-dev \ 20 | zlib1g-dev libgd-dev \ 21 | libtidy-dev libxslt1-dev libmagic-dev libexif-dev file \ 22 | sqlite3 libsqlite3-dev libxslt-dev \ 23 | libmhash2 libmhash-dev libc-client-dev libkrb5-dev libssh2-1-dev \ 24 | unzip libpcre3 libpcre3-dev \ 25 | poppler-utils ghostscript libmagickwand-6.q16-dev libsnmp-dev libedit-dev libreadline6-dev libsodium-dev \ 26 | freetds-bin freetds-dev freetds-common libct4 libsybdb5 tdsodbc libreadline-dev librecode-dev libpspell-dev 27 | 28 | # fix for docker-php-ext-install pdo_dblib 29 | # https://stackoverflow.com/questions/43617752/docker-php-and-freetds-cannot-find-freetds-in-know-installation-directories 30 | RUN ln -s /usr/lib/x86_64-linux-gnu/libsybdb.so /usr/lib/ 31 | 32 | RUN docker-php-ext-configure hash --with-mhash && \ 33 | docker-php-ext-install hash 34 | RUN docker-php-ext-configure imap --with-kerberos --with-imap-ssl && \ 35 | docker-php-ext-install imap iconv 36 | 37 | RUN docker-php-ext-install bcmath bz2 calendar ctype curl dba dom enchant 38 | RUN docker-php-ext-install fileinfo exif ftp gd gettext gmp 39 | RUN docker-php-ext-install interbase intl json ldap mbstring mysqli 40 | RUN docker-php-ext-install opcache pcntl pspell 41 | RUN docker-php-ext-install pdo pdo_dblib pdo_mysql pdo_pgsql pdo_sqlite pgsql phar posix 42 | RUN docker-php-ext-install readline recode 43 | RUN docker-php-ext-install session shmop simplexml soap sockets sodium 44 | RUN docker-php-ext-install sysvmsg sysvsem sysvshm 45 | # RUN docker-php-ext-install snmp 46 | 47 | # fix for docker-php-ext-install xmlreader 48 | # https://github.com/docker-library/php/issues/373 49 | RUN export CFLAGS="-I/usr/src/php" && docker-php-ext-install xmlreader xmlwriter xml xmlrpc xsl 50 | 51 | RUN docker-php-ext-install tidy tokenizer wddx zend_test zip 52 | 53 | # already build in... what they say... 54 | # RUN docker-php-ext-install filter reflection spl standard 55 | # RUN docker-php-ext-install pdo_firebird pdo_oci 56 | 57 | # install pecl extension 58 | RUN pecl install ds && \ 59 | pecl install imagick && \ 60 | pecl install igbinary && \ 61 | pecl install ssh2-1.0 && \ 62 | pecl install redis-4.0.1 && \ 63 | pecl install memcached-3.0.4 && \ 64 | docker-php-ext-enable ds imagick igbinary ssh2 redis memcached 65 | 66 | # install pecl extension 67 | RUN pecl install mongodb && docker-php-ext-enable mongodb 68 | 69 | RUN yes "" | pecl install msgpack && \ 70 | docker-php-ext-enable msgpack 71 | 72 | # install the php memcache extension 73 | RUN set -x \ 74 | && cd /tmp \ 75 | && curl -sSL -o php7.zip https://github.com/websupport-sk/pecl-memcache/archive/php7.zip \ 76 | && unzip php7 \ 77 | && cd pecl-memcache-php7 \ 78 | && /usr/local/bin/phpize \ 79 | && ./configure --with-php-config=/usr/local/bin/php-config \ 80 | && make \ 81 | && make install \ 82 | && echo "extension=memcache.so" > /usr/local/etc/php/conf.d/docker-php-ext-memcache.ini \ 83 | && rm -rf /tmp/pecl-memcache-php7 php7.zip 84 | 85 | # install APCu 86 | RUN pecl install apcu-5.1.8 && \ 87 | pecl install apcu_bc-1.0.3 && \ 88 | docker-php-ext-enable apcu --ini-name docker-php-ext-10-apcu.ini && \ 89 | docker-php-ext-enable apc --ini-name docker-php-ext-20-apc.ini 90 | 91 | # oracle database 92 | # RUN curl -o /tmp/instantclient-sdk.zip -L https://github.com/bumpx/oracle-instantclient/raw/master/instantclient-sdk-linux.x64-12.1.0.2.0.zip && \ 93 | # curl -o /tmp/instantclient-basic.zip -L https://github.com/bumpx/oracle-instantclient/raw/master/instantclient-basic-linux.x64-12.1.0.2.0.zip 94 | # RUN unzip /tmp/instantclient-basic.zip -d /usr/local/ && \ 95 | # unzip /tmp/instantclient-sdk.zip -d /usr/local/ && \ 96 | # ln -s /usr/local/instantclient_12_1 /usr/local/instantclient && \ 97 | # ln -s /usr/local/instantclient/libclntsh.so.12.1 /usr/local/instantclient/libclntsh.so && \ 98 | # docker-php-ext-configure oci8 --with-oci8=instantclient,/usr/local/instantclient && \ 99 | # docker-php-ext-install oci8 100 | 101 | RUN apt-get update -y && apt-get install -y apt-transport-https locales gnupg 102 | 103 | # install MSSQL support and ODBC driver 104 | # RUN curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add - && \ 105 | # curl https://packages.microsoft.com/config/debian/8/prod.list > /etc/apt/sources.list.d/mssql-release.list && \ 106 | # export DEBIAN_FRONTEND=noninteractive && apt-get update -y && \ 107 | # ACCEPT_EULA=Y apt-get install -y msodbcsql unixodbc-dev 108 | # RUN set -xe \ 109 | # && pecl install pdo_sqlsrv \ 110 | # && docker-php-ext-enable pdo_sqlsrv \ 111 | # && apt-get purge -y unixodbc-dev && apt-get autoremove -y && apt-get clean 112 | 113 | # install GD 114 | RUN docker-php-ext-configure gd \ 115 | --with-gd \ 116 | --with-webp-dir \ 117 | --with-jpeg-dir \ 118 | --with-png-dir \ 119 | --with-zlib-dir \ 120 | --with-xpm-dir \ 121 | --with-freetype-dir && \ 122 | docker-php-ext-install gd 123 | 124 | # set locale to utf-8 125 | RUN echo "en_US.UTF-8 UTF-8" > /etc/locale.gen && locale-gen 126 | ENV LANG='en_US.UTF-8' LANGUAGE='en_US:en' LC_ALL='en_US.UTF-8' 127 | 128 | #RUN pecl install stackdriver_debugger-alpha \ 129 | # && echo "extension=stackdriver_debugger.so" > /usr/local/etc/php/conf.d/docker-php-ext-stackdriver_debugger.ini 130 | 131 | # install xdebug 132 | RUN pecl install xdebug && docker-php-ext-enable xdebug 133 | 134 | #-------------------------------------------------------------------------- 135 | # Final Touches 136 | #-------------------------------------------------------------------------- 137 | 138 | # install required libs for health check 139 | RUN apt-get -y install libfcgi0ldbl nano htop iotop lsof cron mariadb-client redis-tools 140 | 141 | # install composer 142 | RUN php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" \ 143 | && php -r "if (hash_file('sha384', 'composer-setup.php') === 'e0012edf3e80b6978849f5eff0d4b4e4c79ff1609dd1e613307e16318854d24ae64f26d17af3ef0bf7cfb710ca74755a') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;" \ 144 | && php composer-setup.php \ 145 | && php -r "unlink('composer-setup.php');" \ 146 | && mv composer.phar /usr/local/sbin/composer \ 147 | && chmod +x /usr/local/sbin/composer 148 | 149 | # install NewRelic agent 150 | RUN echo 'deb http://apt.newrelic.com/debian/ newrelic non-free' | tee /etc/apt/sources.list.d/newrelic.list && \ 151 | curl https://download.newrelic.com/548C16BF.gpg | apt-key add - && \ 152 | apt-get -y update && \ 153 | DEBIAN_FRONTEND=noninteractive apt-get -y install newrelic-php5 newrelic-sysmond && \ 154 | export NR_INSTALL_SILENT=1 && newrelic-install install 155 | 156 | # install SendGrid 157 | RUN echo "postfix postfix/mailname string localhost" | debconf-set-selections && \ 158 | echo "postfix postfix/main_mailer_type string 'Internet Site'" | debconf-set-selections && \ 159 | DEBIAN_FRONTEND=noninteractive apt-get install postfix libsasl2-modules -y 160 | 161 | # Set default work directory 162 | ADD scripts/* /usr/local/bin/ 163 | RUN chmod +x /usr/local/bin/* 164 | 165 | # Health check 166 | RUN echo '#!/bin/bash' > /healthcheck && \ 167 | echo 'SCRIPT_NAME=/health SCRIPT_FILENAME=/health REQUEST_METHOD=GET cgi-fcgi -bind -connect 127.0.0.1:9000 || exit 1' >> /healthcheck && \ 168 | chmod +x /healthcheck 169 | 170 | # Clean up 171 | RUN apt-get remove -y git && apt-get autoremove -y && apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* 172 | -------------------------------------------------------------------------------- /7.2/configs/www.conf: -------------------------------------------------------------------------------- 1 | ; Start a new pool named 'www'. 2 | ; the variable $pool can be used in any directive and will be replaced by the 3 | ; pool name ('www' here) 4 | [www] 5 | 6 | ; Per pool prefix 7 | ; It only applies on the following directives: 8 | ; - 'access.log' 9 | ; - 'slowlog' 10 | ; - 'listen' (unixsocket) 11 | ; - 'chroot' 12 | ; - 'chdir' 13 | ; - 'php_values' 14 | ; - 'php_admin_values' 15 | ; When not set, the global prefix (or NONE) applies instead. 16 | ; Note: This directive can also be relative to the global prefix. 17 | ; Default Value: none 18 | ;prefix = /path/to/pools/$pool 19 | 20 | ; Unix user/group of processes 21 | ; Note: The user is mandatory. If the group is not set, the default user's group 22 | ; will be used. 23 | user = www-data 24 | group = www-data 25 | 26 | ; The address on which to accept FastCGI requests. 27 | ; Valid syntaxes are: 28 | ; 'ip.add.re.ss:port' - to listen on a TCP socket to a specific IPv4 address on 29 | ; a specific port; 30 | ; '[ip:6:addr:ess]:port' - to listen on a TCP socket to a specific IPv6 address on 31 | ; a specific port; 32 | ; 'port' - to listen on a TCP socket to all addresses 33 | ; (IPv6 and IPv4-mapped) on a specific port; 34 | ; '/path/to/unix/socket' - to listen on a unix socket. 35 | ; Note: This value is mandatory. 36 | listen = 9000 37 | 38 | ; Set listen(2) backlog. 39 | ; Default Value: 511 (-1 on FreeBSD and OpenBSD) 40 | ;listen.backlog = 511 41 | 42 | ; Set permissions for unix socket, if one is used. In Linux, read/write 43 | ; permissions must be set in order to allow connections from a web server. Many 44 | ; BSD-derived systems allow connections regardless of permissions. 45 | ; Default Values: user and group are set as the running user 46 | ; mode is set to 0660 47 | ;listen.owner = www-data 48 | ;listen.group = www-data 49 | ;listen.mode = 0660 50 | ; When POSIX Access Control Lists are supported you can set them using 51 | ; these options, value is a comma separated list of user/group names. 52 | ; When set, listen.owner and listen.group are ignored 53 | ;listen.acl_users = 54 | ;listen.acl_groups = 55 | 56 | ; List of addresses (IPv4/IPv6) of FastCGI clients which are allowed to connect. 57 | ; Equivalent to the FCGI_WEB_SERVER_ADDRS environment variable in the original 58 | ; PHP FCGI (5.2.2+). Makes sense only with a tcp listening socket. Each address 59 | ; must be separated by a comma. If this value is left blank, connections will be 60 | ; accepted from any ip address. 61 | ; Default Value: any 62 | ;listen.allowed_clients = 127.0.0.1 63 | 64 | ; Specify the nice(2) priority to apply to the pool processes (only if set) 65 | ; The value can vary from -19 (highest priority) to 20 (lower priority) 66 | ; Note: - It will only work if the FPM master process is launched as root 67 | ; - The pool processes will inherit the master process priority 68 | ; unless it specified otherwise 69 | ; Default Value: no set 70 | ; process.priority = -19 71 | 72 | ; Set the process dumpable flag (PR_SET_DUMPABLE prctl) even if the process user 73 | ; or group is differrent than the master process user. It allows to create process 74 | ; core dump and ptrace the process for the pool user. 75 | ; Default Value: no 76 | ; process.dumpable = yes 77 | 78 | ; Choose how the process manager will control the number of child processes. 79 | ; Possible Values: 80 | ; static - a fixed number (pm.max_children) of child processes; 81 | ; dynamic - the number of child processes are set dynamically based on the 82 | ; following directives. With this process management, there will be 83 | ; always at least 1 children. 84 | ; pm.max_children - the maximum number of children that can 85 | ; be alive at the same time. 86 | ; pm.start_servers - the number of children created on startup. 87 | ; pm.min_spare_servers - the minimum number of children in 'idle' 88 | ; state (waiting to process). If the number 89 | ; of 'idle' processes is less than this 90 | ; number then some children will be created. 91 | ; pm.max_spare_servers - the maximum number of children in 'idle' 92 | ; state (waiting to process). If the number 93 | ; of 'idle' processes is greater than this 94 | ; number then some children will be killed. 95 | ; ondemand - no children are created at startup. Children will be forked when 96 | ; new requests will connect. The following parameter are used: 97 | ; pm.max_children - the maximum number of children that 98 | ; can be alive at the same time. 99 | ; pm.process_idle_timeout - The number of seconds after which 100 | ; an idle process will be killed. 101 | ; Note: This value is mandatory. 102 | pm = dynamic 103 | 104 | ; The number of child processes to be created when pm is set to 'static' and the 105 | ; maximum number of child processes when pm is set to 'dynamic' or 'ondemand'. 106 | ; This value sets the limit on the number of simultaneous requests that will be 107 | ; served. Equivalent to the ApacheMaxClients directive with mpm_prefork. 108 | ; Equivalent to the PHP_FCGI_CHILDREN environment variable in the original PHP 109 | ; CGI. The below defaults are based on a server without much resources. Don't 110 | ; forget to tweak pm.* to fit your needs. 111 | ; Note: Used when pm is set to 'static', 'dynamic' or 'ondemand' 112 | ; Note: This value is mandatory. 113 | pm.max_children = 5 114 | 115 | ; The number of child processes created on startup. 116 | ; Note: Used only when pm is set to 'dynamic' 117 | ; Default Value: min_spare_servers + (max_spare_servers - min_spare_servers) / 2 118 | pm.start_servers = 2 119 | 120 | ; The desired minimum number of idle server processes. 121 | ; Note: Used only when pm is set to 'dynamic' 122 | ; Note: Mandatory when pm is set to 'dynamic' 123 | pm.min_spare_servers = 1 124 | 125 | ; The desired maximum number of idle server processes. 126 | ; Note: Used only when pm is set to 'dynamic' 127 | ; Note: Mandatory when pm is set to 'dynamic' 128 | pm.max_spare_servers = 3 129 | 130 | ; The number of seconds after which an idle process will be killed. 131 | ; Note: Used only when pm is set to 'ondemand' 132 | ; Default Value: 10s 133 | ;pm.process_idle_timeout = 10s; 134 | 135 | ; The number of requests each child process should execute before respawning. 136 | ; This can be useful to work around memory leaks in 3rd party libraries. For 137 | ; endless request processing specify '0'. Equivalent to PHP_FCGI_MAX_REQUESTS. 138 | ; Default Value: 0 139 | ;pm.max_requests = 500 140 | 141 | ; The URI to view the FPM status page. If this value is not set, no URI will be 142 | ; recognized as a status page. It shows the following informations: 143 | ; pool - the name of the pool; 144 | ; process manager - static, dynamic or ondemand; 145 | ; start time - the date and time FPM has started; 146 | ; start since - number of seconds since FPM has started; 147 | ; accepted conn - the number of request accepted by the pool; 148 | ; listen queue - the number of request in the queue of pending 149 | ; connections (see backlog in listen(2)); 150 | ; max listen queue - the maximum number of requests in the queue 151 | ; of pending connections since FPM has started; 152 | ; listen queue len - the size of the socket queue of pending connections; 153 | ; idle processes - the number of idle processes; 154 | ; active processes - the number of active processes; 155 | ; total processes - the number of idle + active processes; 156 | ; max active processes - the maximum number of active processes since FPM 157 | ; has started; 158 | ; max children reached - number of times, the process limit has been reached, 159 | ; when pm tries to start more children (works only for 160 | ; pm 'dynamic' and 'ondemand'); 161 | ; Value are updated in real time. 162 | ; Example output: 163 | ; pool: www 164 | ; process manager: static 165 | ; start time: 01/Jul/2011:17:53:49 +0200 166 | ; start since: 62636 167 | ; accepted conn: 190460 168 | ; listen queue: 0 169 | ; max listen queue: 1 170 | ; listen queue len: 42 171 | ; idle processes: 4 172 | ; active processes: 11 173 | ; total processes: 15 174 | ; max active processes: 12 175 | ; max children reached: 0 176 | ; 177 | ; By default the status page output is formatted as text/plain. Passing either 178 | ; 'html', 'xml' or 'json' in the query string will return the corresponding 179 | ; output syntax. Example: 180 | ; http://www.foo.bar/status 181 | ; http://www.foo.bar/status?json 182 | ; http://www.foo.bar/status?html 183 | ; http://www.foo.bar/status?xml 184 | ; 185 | ; By default the status page only outputs short status. Passing 'full' in the 186 | ; query string will also return status for each pool process. 187 | ; Example: 188 | ; http://www.foo.bar/status?full 189 | ; http://www.foo.bar/status?json&full 190 | ; http://www.foo.bar/status?html&full 191 | ; http://www.foo.bar/status?xml&full 192 | ; The Full status returns for each process: 193 | ; pid - the PID of the process; 194 | ; state - the state of the process (Idle, Running, ...); 195 | ; start time - the date and time the process has started; 196 | ; start since - the number of seconds since the process has started; 197 | ; requests - the number of requests the process has served; 198 | ; request duration - the duration in µs of the requests; 199 | ; request method - the request method (GET, POST, ...); 200 | ; request URI - the request URI with the query string; 201 | ; content length - the content length of the request (only with POST); 202 | ; user - the user (PHP_AUTH_USER) (or '-' if not set); 203 | ; script - the main script called (or '-' if not set); 204 | ; last request cpu - the %cpu the last request consumed 205 | ; it's always 0 if the process is not in Idle state 206 | ; because CPU calculation is done when the request 207 | ; processing has terminated; 208 | ; last request memory - the max amount of memory the last request consumed 209 | ; it's always 0 if the process is not in Idle state 210 | ; because memory calculation is done when the request 211 | ; processing has terminated; 212 | ; If the process is in Idle state, then informations are related to the 213 | ; last request the process has served. Otherwise informations are related to 214 | ; the current request being served. 215 | ; Example output: 216 | ; ************************ 217 | ; pid: 31330 218 | ; state: Running 219 | ; start time: 01/Jul/2011:17:53:49 +0200 220 | ; start since: 63087 221 | ; requests: 12808 222 | ; request duration: 1250261 223 | ; request method: GET 224 | ; request URI: /test_mem.php?N=10000 225 | ; content length: 0 226 | ; user: - 227 | ; script: /home/fat/web/docs/php/test_mem.php 228 | ; last request cpu: 0.00 229 | ; last request memory: 0 230 | ; 231 | ; Note: There is a real-time FPM status monitoring sample web page available 232 | ; It's available in: /usr/local/share/php/fpm/status.html 233 | ; 234 | ; Note: The value must start with a leading slash (/). The value can be 235 | ; anything, but it may not be a good idea to use the .php extension or it 236 | ; may conflict with a real PHP file. 237 | ; Default Value: not set 238 | pm.status_path = /status 239 | 240 | ; The ping URI to call the monitoring page of FPM. If this value is not set, no 241 | ; URI will be recognized as a ping page. This could be used to test from outside 242 | ; that FPM is alive and responding, or to 243 | ; - create a graph of FPM availability (rrd or such); 244 | ; - remove a server from a group if it is not responding (load balancing); 245 | ; - trigger alerts for the operating team (24/7). 246 | ; Note: The value must start with a leading slash (/). The value can be 247 | ; anything, but it may not be a good idea to use the .php extension or it 248 | ; may conflict with a real PHP file. 249 | ; Default Value: not set 250 | ping.path = /health 251 | 252 | ; This directive may be used to customize the response of a ping request. The 253 | ; response is formatted as text/plain with a 200 response code. 254 | ; Default Value: pong 255 | ping.response = OK 256 | 257 | ; The access log file 258 | ; Default: not set 259 | ;access.log = log/$pool.access.log 260 | 261 | ; The access log format. 262 | ; The following syntax is allowed 263 | ; %%: the '%' character 264 | ; %C: %CPU used by the request 265 | ; it can accept the following format: 266 | ; - %{user}C for user CPU only 267 | ; - %{system}C for system CPU only 268 | ; - %{total}C for user + system CPU (default) 269 | ; %d: time taken to serve the request 270 | ; it can accept the following format: 271 | ; - %{seconds}d (default) 272 | ; - %{miliseconds}d 273 | ; - %{mili}d 274 | ; - %{microseconds}d 275 | ; - %{micro}d 276 | ; %e: an environment variable (same as $_ENV or $_SERVER) 277 | ; it must be associated with embraces to specify the name of the env 278 | ; variable. Some exemples: 279 | ; - server specifics like: %{REQUEST_METHOD}e or %{SERVER_PROTOCOL}e 280 | ; - HTTP headers like: %{HTTP_HOST}e or %{HTTP_USER_AGENT}e 281 | ; %f: script filename 282 | ; %l: content-length of the request (for POST request only) 283 | ; %m: request method 284 | ; %M: peak of memory allocated by PHP 285 | ; it can accept the following format: 286 | ; - %{bytes}M (default) 287 | ; - %{kilobytes}M 288 | ; - %{kilo}M 289 | ; - %{megabytes}M 290 | ; - %{mega}M 291 | ; %n: pool name 292 | ; %o: output header 293 | ; it must be associated with embraces to specify the name of the header: 294 | ; - %{Content-Type}o 295 | ; - %{X-Powered-By}o 296 | ; - %{Transfert-Encoding}o 297 | ; - .... 298 | ; %p: PID of the child that serviced the request 299 | ; %P: PID of the parent of the child that serviced the request 300 | ; %q: the query string 301 | ; %Q: the '?' character if query string exists 302 | ; %r: the request URI (without the query string, see %q and %Q) 303 | ; %R: remote IP address 304 | ; %s: status (response code) 305 | ; %t: server time the request was received 306 | ; it can accept a strftime(3) format: 307 | ; %d/%b/%Y:%H:%M:%S %z (default) 308 | ; The strftime(3) format must be encapsuled in a %{}t tag 309 | ; e.g. for a ISO8601 formatted timestring, use: %{%Y-%m-%dT%H:%M:%S%z}t 310 | ; %T: time the log has been written (the request has finished) 311 | ; it can accept a strftime(3) format: 312 | ; %d/%b/%Y:%H:%M:%S %z (default) 313 | ; The strftime(3) format must be encapsuled in a %{}t tag 314 | ; e.g. for a ISO8601 formatted timestring, use: %{%Y-%m-%dT%H:%M:%S%z}t 315 | ; %u: remote user 316 | ; 317 | ; Default: "%R - %u %t \"%m %r\" %s" 318 | ;access.format = "%R - %u %t \"%m %r%Q%q\" %s %f %{mili}d %{kilo}M %C%%" 319 | 320 | ; The log file for slow requests 321 | ; Default Value: not set 322 | ; Note: slowlog is mandatory if request_slowlog_timeout is set 323 | ;slowlog = log/$pool.log.slow 324 | 325 | ; The timeout for serving a single request after which a PHP backtrace will be 326 | ; dumped to the 'slowlog' file. A value of '0s' means 'off'. 327 | ; Available units: s(econds)(default), m(inutes), h(ours), or d(ays) 328 | ; Default Value: 0 329 | ;request_slowlog_timeout = 0 330 | 331 | ; Depth of slow log stack trace. 332 | ; Default Value: 20 333 | ;request_slowlog_trace_depth = 20 334 | 335 | ; The timeout for serving a single request after which the worker process will 336 | ; be killed. This option should be used when the 'max_execution_time' ini option 337 | ; does not stop script execution for some reason. A value of '0' means 'off'. 338 | ; Available units: s(econds)(default), m(inutes), h(ours), or d(ays) 339 | ; Default Value: 0 340 | request_terminate_timeout = 360 341 | 342 | ; Set open file descriptor rlimit. 343 | ; Default Value: system defined value 344 | rlimit_files = 131072 345 | 346 | ; Set max core size rlimit. 347 | ; Possible Values: 'unlimited' or an integer greater or equal to 0 348 | ; Default Value: system defined value 349 | rlimit_core = unlimited 350 | 351 | ; Chroot to this directory at the start. This value must be defined as an 352 | ; absolute path. When this value is not set, chroot is not used. 353 | ; Note: you can prefix with '$prefix' to chroot to the pool prefix or one 354 | ; of its subdirectories. If the pool prefix is not set, the global prefix 355 | ; will be used instead. 356 | ; Note: chrooting is a great security feature and should be used whenever 357 | ; possible. However, all PHP paths will be relative to the chroot 358 | ; (error_log, sessions.save_path, ...). 359 | ; Default Value: not set 360 | ;chroot = 361 | 362 | ; Chdir to this directory at the start. 363 | ; Note: relative path can be used. 364 | ; Default Value: current directory or / when chroot 365 | ;chdir = /var/www 366 | 367 | ; Redirect worker stdout and stderr into main error log. If not set, stdout and 368 | ; stderr will be redirected to /dev/null according to FastCGI specs. 369 | ; Note: on highloaded environement, this can cause some delay in the page 370 | ; process time (several ms). 371 | ; Default Value: no 372 | catch_workers_output = yes 373 | 374 | ; Clear environment in FPM workers 375 | ; Prevents arbitrary environment variables from reaching FPM worker processes 376 | ; by clearing the environment in workers before env vars specified in this 377 | ; pool configuration are added. 378 | ; Setting to "no" will make all environment variables available to PHP code 379 | ; via getenv(), $_ENV and $_SERVER. 380 | ; Default Value: yes 381 | ;clear_env = no 382 | 383 | ; Limits the extensions of the main script FPM will allow to parse. This can 384 | ; prevent configuration mistakes on the web server side. You should only limit 385 | ; FPM to .php extensions to prevent malicious users to use other extensions to 386 | ; execute php code. 387 | ; Note: set an empty value to allow all extensions. 388 | ; Default Value: .php 389 | ;security.limit_extensions = .php .php3 .php4 .php5 .php7 390 | 391 | ; Pass environment variables like LD_LIBRARY_PATH. All $VARIABLEs are taken from 392 | ; the current environment. 393 | ; Default Value: clean env 394 | ;env[HOSTNAME] = $HOSTNAME 395 | ;env[PATH] = /usr/local/bin:/usr/bin:/bin 396 | ;env[TMP] = /tmp 397 | ;env[TMPDIR] = /tmp 398 | ;env[TEMP] = /tmp 399 | 400 | ; Additional php.ini defines, specific to this pool of workers. These settings 401 | ; overwrite the values previously defined in the php.ini. The directives are the 402 | ; same as the PHP SAPI: 403 | ; php_value/php_flag - you can set classic ini defines which can 404 | ; be overwritten from PHP call 'ini_set'. 405 | ; php_admin_value/php_admin_flag - these directives won't be overwritten by 406 | ; PHP call 'ini_set' 407 | ; For php_*flag, valid values are on, off, 1, 0, true, false, yes or no. 408 | 409 | ; Defining 'extension' will load the corresponding shared extension from 410 | ; extension_dir. Defining 'disable_functions' or 'disable_classes' will not 411 | ; overwrite previously defined php.ini values, but will append the new value 412 | ; instead. 413 | 414 | ; Note: path INI options can be relative and will be expanded with the prefix 415 | ; (pool, global or /usr/local) 416 | 417 | ; Default Value: nothing is defined by default except the values in php.ini and 418 | ; specified at startup with the -d argument 419 | ;php_admin_value[sendmail_path] = /usr/sbin/sendmail -t -i -f www@my.domain.com 420 | ;php_flag[display_errors] = off 421 | ;php_admin_value[error_log] = /var/log/fpm-php.www.log 422 | ;php_admin_flag[log_errors] = on 423 | ;php_admin_value[memory_limit] = 32M 424 | -------------------------------------------------------------------------------- /7.2/docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: "3" 2 | 3 | services: 4 | php72: 5 | build: 6 | context: ./ 7 | dockerfile: Dockerfile 8 | hostname: php72 9 | container_name: php72 10 | volumes: 11 | - ./configs:/cfgs 12 | env_file: .env 13 | -------------------------------------------------------------------------------- /7.2/scripts/crontab.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | if [ ! "$PHP_CRONTABS_PATH" == "" ]; then 4 | printf "env CRONTABS_PATH: setting up crontabs: "; 5 | for f in ${PHP_CRONTABS_PATH}; do 6 | printf "$f, "; 7 | rm -f /etc/cron.d/${f##*/} 8 | cp $f /etc/cron.d/ 9 | chmod 0644 /etc/cron.d/${f##*/} 10 | done 11 | echo 12 | touch /var/log/cron.log 13 | printenv | grep -v "no_proxy" >> /etc/environment 14 | /etc/init.d/cron start > /dev/null 15 | fi 16 | -------------------------------------------------------------------------------- /7.2/scripts/docker-boot: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | echo "[`date +"%d-%b-%Y %T"`] PHP-FPM Docker container boot" 4 | 5 | ### create system user for php pool 6 | if [ ! "$PHP_USER" == "" ] && [ ! "$PHP_UID" == "" ] && [ ! "$PHP_GID" == "" ] && [ ! "$PHP_HOME" == "" ]; then 7 | echo "env PHP_USER: creating new system user: ${PHP_USER} ${PHP_UID}:${PHP_GID} ${PHP_HOME}" 8 | mkdir -p $PHP_HOME && \ 9 | groupadd -f $PHP_USER -g $PHP_GID && \ 10 | useradd -d $PHP_HOME -u $PHP_UID -g $PHP_GID -s /usr/sbin/nologin $PHP_USER 11 | fi 12 | 13 | ### load PHP ini configurations 14 | if [ ! "$PHP_INI_PATH" == "" ]; then 15 | printf "env PHP_INI_PATH: " 16 | for f in ${PHP_INI_PATH}; do 17 | printf "$f, "; 18 | rm -f /usr/local/etc/php/conf.d/${f##*/} 19 | cp $f /usr/local/etc/php/conf.d/ 20 | done 21 | echo "into [ /usr/local/etc/php/conf.d/ ] folder..." 22 | fi 23 | 24 | ### make sure to create clean php-fpm.conf 25 | ### to avoid adding multiple times the same lines next 26 | ### in case container is restarting 27 | echo "[global]" > /usr/local/etc/php-fpm.conf 28 | echo "include=etc/php-fpm.d/*.conf" >> /usr/local/etc/php-fpm.conf 29 | 30 | ### load PHP-FPM pool configurations 31 | if [ ! "$PHP_POOL_PATH" == "" ]; then 32 | printf "env PHP_POOL_PATH: " 33 | for f in ${PHP_POOL_PATH}; do 34 | printf "$f, "; 35 | rm -f /usr/local/etc/php-fpm.d/${f##*/} 36 | cp $f /usr/local/etc/php-fpm.d/ 37 | done 38 | echo "into [ /usr/local/etc/php-fpm.d/ ] folder..." 39 | fi 40 | 41 | ### load boot bash scripts 42 | for f in /usr/local/bin/*.sh; do 43 | /bin/bash -c $f 44 | done 45 | 46 | ### load additional on-demand scripts 47 | if [ ! -z ${PHP_BOOT_SCRIPTS+x} ] && [ "$PHP_BOOT_SCRIPTS" != "" ]; then 48 | printf "env PHP_BOOT_SCRIPTS: " 49 | 50 | for f in ${PHP_BOOT_SCRIPTS}; do 51 | printf "$f, "; 52 | 53 | rm -f /usr/local/bin/${f##*/} 54 | cp $f /usr/local/bin/ 55 | 56 | chmod +x /usr/local/bin/${f##*/} 57 | done 58 | 59 | echo 60 | 61 | for f in ${PHP_BOOT_SCRIPTS}; do 62 | /bin/bash -c /usr/local/bin/${f##*/} 63 | done 64 | fi 65 | 66 | ### expose php version 67 | echo 68 | /usr/local/bin/php -v 69 | -------------------------------------------------------------------------------- /7.2/scripts/docker-php-entrypoint: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -e 3 | 4 | /usr/local/bin/docker-boot 5 | 6 | # first arg is `-f` or `--some-option` 7 | if [ "${1#-}" != "$1" ]; then 8 | set -- php-fpm "$@" 9 | fi 10 | 11 | exec "$@" 12 | -------------------------------------------------------------------------------- /7.2/scripts/newrelic.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | if [ ! -z ${NEWRELIC_LICENSE+x} ] && [ "$NEWRELIC_LICENSE" != "" ] ; then 4 | echo "env NEWRELIC_LICENSE: setting up newrelic license" 5 | sed -i "s/REPLACE_WITH_REAL_KEY/$NEWRELIC_LICENSE/g" /usr/local/etc/php/conf.d/newrelic.ini 6 | nrsysmond-config --set license_key=$NEWRELIC_LICENSE 7 | 8 | service newrelic-sysmond start > /dev/null 9 | 10 | chmod u+rw,g+rw,o+rw /var/log/newrelic/newrelic-daemon.log 11 | else 12 | rm -f /usr/local/etc/php/conf.d/newrelic.ini 13 | fi 14 | -------------------------------------------------------------------------------- /7.2/scripts/phpsendmail: -------------------------------------------------------------------------------- 1 | #!/usr/local/bin/php 2 | 8 | * https://www.howtoforge.com/how-to-log-emails-sent-with-phps-mail-function-to-detect-form-spam 9 | */ 10 | 11 | $sendmail_bin = '/usr/sbin/sendmail'; 12 | 13 | // Get the email content 14 | $mail = ''; 15 | $logline = ''; 16 | $pointer = fopen('php://stdin', 'r'); 17 | 18 | while ($line = fgets($pointer)) { 19 | if (preg_match('/^to:/i', $line) || preg_match('/^from:/i', $line)) { 20 | $logline .= trim($line) . ' '; 21 | } 22 | $mail .= $line; 23 | } 24 | 25 | // Compose the sendmail command 26 | $command = 'echo ' . escapeshellarg($mail) . ' | ' . $sendmail_bin . ' -t -i'; 27 | 28 | if (isset($_SERVER['argc'])) { 29 | for ($i = 1; $i < $_SERVER['argc']; $i++) { 30 | $command .= escapeshellarg($_SERVER['argv'][$i]) . ' '; 31 | } 32 | } 33 | 34 | // Write the log 35 | $stdout = fopen('php://stdout', 'w'); 36 | fwrite($stdout, (isset($_ENV['USER']) ? $_ENV['USER'] . ' ' : '') . $logline . ' - ' . $command . "\n"); 37 | 38 | // Execute the command 39 | return shell_exec($command); 40 | -------------------------------------------------------------------------------- /7.2/scripts/sendgrid.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | if [ ! -z ${SMTP_LOGIN+x} ] && [ ! -z ${SMTP_PASSWORD+x} ] && [ "$SMTP_LOGIN" != "" ] && [ "$SMTP_PASSWORD" != "" ]; then 4 | echo "env SMTP_LOGIN: sendgrid credentials for email routing"; 5 | echo "[smtp.sendgrid.net]:2525 ${SMTP_LOGIN}:${SMTP_PASSWORD}" > /etc/postfix/sasl_passwd 6 | 7 | postmap /etc/postfix/sasl_passwd 8 | chmod 600 /etc/postfix/sasl_passwd.db 9 | rm /etc/postfix/sasl_passwd 10 | 11 | ### update email relay configuration for SendGrid 12 | sed -i 's/default_transport = error//g' /etc/postfix/main.cf 13 | sed -i 's/relay_transport = error//g' /etc/postfix/main.cf 14 | 15 | ### delete following lines if already exist before adding 16 | sed -i '/relayhost/d' /etc/postfix/main.cf 17 | sed -i '/smtp_tls_security_level/d' /etc/postfix/main.cf 18 | sed -i '/smtp_sasl_auth_enable/d' /etc/postfix/main.cf 19 | sed -i '/smtp_sasl_password_maps/d' /etc/postfix/main.cf 20 | sed -i '/header_size_limit/d' /etc/postfix/main.cf 21 | sed -i '/smtp_sasl_security_options/d' /etc/postfix/main.cf 22 | 23 | ### add following lines 24 | echo "relayhost = [smtp.sendgrid.net]:2525" >> /etc/postfix/main.cf 25 | echo "smtp_tls_security_level = encrypt" >> /etc/postfix/main.cf 26 | echo "smtp_sasl_auth_enable = yes" >> /etc/postfix/main.cf 27 | echo "smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd" >> /etc/postfix/main.cf 28 | echo "header_size_limit = 4096000" >> /etc/postfix/main.cf 29 | echo "smtp_sasl_security_options = noanonymous" >> /etc/postfix/main.cf 30 | 31 | /etc/init.d/postfix start > /dev/null 32 | fi 33 | -------------------------------------------------------------------------------- /7.2/scripts/session.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | ### update PHP session handler 4 | if [ ! "$PHP_SESSION_HANDLER" == "" ] && [ ! "$PHP_SESSION_PATH" == "" ]; then 5 | echo "env PHP_SESSION_HANDLER: updating php session handler [ $PHP_SESSION_PATH ]" 6 | echo "session.save_handler = $PHP_SESSION_HANDLER" > /usr/local/etc/php/conf.d/zz-session.ini 7 | echo "session.save_path = \"$PHP_SESSION_PATH\"" >> /usr/local/etc/php/conf.d/zz-session.ini 8 | fi 9 | -------------------------------------------------------------------------------- /7.2/scripts/www-pool.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | if [ ! -z ${PHP_INI_SCAN_DIR+x} ] && [ "$PHP_INI_SCAN_DIR" != "" ] ; then 4 | echo "env PHP_INI_SCAN_DIR: $PHP_INI_SCAN_DIR" 5 | 6 | ### break down path by : separator 7 | IFS=':' read -ra DIRECTORIES <<< "$PHP_INI_SCAN_DIR" 8 | 9 | for DIR in "${DIRECTORIES[@]}"; do 10 | ### check if there are any php pool configuration files to copy 11 | COUNT=`ls -1 $DIR/*.conf 2>/dev/null | wc -l` 12 | 13 | if [ $COUNT != "0" ] ; then 14 | cp -f $DIR/*.conf /usr/local/etc/php-fpm.d/ 15 | fi 16 | done 17 | fi 18 | -------------------------------------------------------------------------------- /7.3/.env-example: -------------------------------------------------------------------------------- 1 | PHP_UID=1000 2 | PHP_GID=1000 3 | PHP_HOME=/app 4 | PHP_USER=php-fpm 5 | # PHP_INI_SCAN_DIR=/cfgs:/usr/local/etc/php/conf.d 6 | PHP_INI_PATH=/cfgs/php.ini 7 | PHP_POOL_PATH=/cfgs/*/*-pool.conf 8 | PHP_BOOT_SCRIPTS=/cfgs/start.sh 9 | PHP_CRONTABS_PATH=/cfgs/cron 10 | PHP_SESSION_HANDLER=redis 11 | PHP_SESSION_PATH=tcp://redis.host:6379 12 | 13 | # private 14 | TEST_EMAIL=name@domain.com 15 | NEWRELIC_LICENSE=newrelic_license 16 | SENDGRID_API_KEY=sendgrid_api_key 17 | -------------------------------------------------------------------------------- /7.3/.gitignore: -------------------------------------------------------------------------------- 1 | .env 2 | -------------------------------------------------------------------------------- /7.3/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM php:7.3-fpm 2 | 3 | RUN apt-get update -y 4 | RUN apt-get -y install gcc make autoconf libc-dev pkg-config libzip-dev 5 | 6 | RUN apt-get install -y --no-install-recommends \ 7 | git \ 8 | libmemcached-dev \ 9 | libz-dev \ 10 | libpq-dev \ 11 | libssl-dev libssl-doc libsasl2-dev \ 12 | libmcrypt-dev \ 13 | libxml2-dev \ 14 | zlib1g-dev libicu-dev g++ \ 15 | libldap2-dev libbz2-dev \ 16 | curl libcurl4-openssl-dev \ 17 | libenchant-dev libgmp-dev firebird-dev libib-util \ 18 | re2c libpng++-dev \ 19 | libwebp-dev libjpeg-dev libjpeg62-turbo-dev libpng-dev libxpm-dev libvpx-dev libfreetype6-dev \ 20 | libmagick++-dev \ 21 | libmagickwand-dev \ 22 | zlib1g-dev libgd-dev \ 23 | libtidy-dev libxslt1-dev libmagic-dev libexif-dev file \ 24 | sqlite3 libsqlite3-dev libxslt-dev \ 25 | libmhash2 libmhash-dev libc-client-dev libkrb5-dev libssh2-1-dev \ 26 | unzip libpcre3 libpcre3-dev \ 27 | poppler-utils ghostscript libmagickwand-6.q16-dev libsnmp-dev libedit-dev libreadline6-dev libsodium-dev \ 28 | freetds-bin freetds-dev freetds-common libct4 libsybdb5 tdsodbc libreadline-dev librecode-dev libpspell-dev 29 | 30 | # fix for docker-php-ext-install pdo_dblib 31 | # https://stackoverflow.com/questions/43617752/docker-php-and-freetds-cannot-find-freetds-in-know-installation-directories 32 | RUN ln -s /usr/lib/x86_64-linux-gnu/libsybdb.so /usr/lib/ 33 | 34 | RUN docker-php-ext-configure hash --with-mhash && \ 35 | docker-php-ext-install hash 36 | RUN docker-php-ext-configure imap --with-kerberos --with-imap-ssl && \ 37 | docker-php-ext-install imap iconv 38 | 39 | RUN docker-php-ext-install bcmath bz2 calendar ctype curl dba dom enchant 40 | RUN docker-php-ext-install fileinfo exif ftp gettext gmp 41 | RUN docker-php-ext-install interbase intl json ldap mbstring mysqli 42 | RUN docker-php-ext-install opcache pcntl pspell 43 | RUN docker-php-ext-install pdo pdo_dblib pdo_mysql pdo_pgsql pdo_sqlite pgsql phar posix 44 | RUN docker-php-ext-install readline recode 45 | RUN docker-php-ext-install session shmop simplexml soap sockets sodium 46 | RUN docker-php-ext-install sysvmsg sysvsem sysvshm 47 | # RUN docker-php-ext-install snmp 48 | 49 | # fix for docker-php-ext-install xmlreader 50 | # https://github.com/docker-library/php/issues/373 51 | RUN export CFLAGS="-I/usr/src/php" && docker-php-ext-install xmlreader xmlwriter xml xmlrpc xsl 52 | 53 | RUN docker-php-ext-install tidy tokenizer wddx zend_test zip 54 | 55 | # already build in... what they say... 56 | # RUN docker-php-ext-install filter reflection spl standard 57 | # RUN docker-php-ext-install pdo_firebird pdo_oci 58 | 59 | # install pecl extension 60 | RUN pecl install ds && \ 61 | pecl install imagick && \ 62 | pecl install igbinary && \ 63 | pecl install redis && \ 64 | pecl install memcached && \ 65 | docker-php-ext-enable ds imagick igbinary redis memcached 66 | 67 | # https://serverpilot.io/docs/how-to-install-the-php-ssh2-extension 68 | # pecl install ssh2-1.1.2 && \ 69 | # docker-php-ext-enable ssh2 70 | 71 | # install pecl extension 72 | RUN pecl install mongodb && docker-php-ext-enable mongodb 73 | 74 | # install xdebug 75 | # RUN pecl install xdebug && docker-php-ext-enable xdebug 76 | 77 | RUN yes "" | pecl install msgpack && \ 78 | docker-php-ext-enable msgpack 79 | 80 | # install APCu 81 | RUN pecl install apcu && \ 82 | docker-php-ext-enable apcu --ini-name docker-php-ext-10-apcu.ini 83 | 84 | RUN apt-get update -y && apt-get install -y apt-transport-https locales gnupg 85 | 86 | # install MSSQL support and ODBC driver 87 | # RUN curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add - && \ 88 | # curl https://packages.microsoft.com/config/debian/8/prod.list > /etc/apt/sources.list.d/mssql-release.list && \ 89 | # export DEBIAN_FRONTEND=noninteractive && apt-get update -y && \ 90 | # ACCEPT_EULA=Y apt-get install -y msodbcsql unixodbc-dev 91 | # RUN set -xe \ 92 | # && pecl install pdo_sqlsrv \ 93 | # && docker-php-ext-enable pdo_sqlsrv \ 94 | # && apt-get purge -y unixodbc-dev && apt-get autoremove -y && apt-get clean 95 | 96 | # RUN docker-php-ext-configure spl && docker-php-ext-install spl 97 | 98 | # install GD 99 | RUN docker-php-ext-configure gd \ 100 | --with-png-dir \ 101 | --with-jpeg-dir \ 102 | --with-xpm-dir \ 103 | --with-webp-dir \ 104 | --with-freetype-dir \ 105 | && docker-php-ext-install -j$(nproc) gd 106 | 107 | # set locale to utf-8 108 | RUN echo "en_US.UTF-8 UTF-8" > /etc/locale.gen && locale-gen 109 | ENV LANG='en_US.UTF-8' LANGUAGE='en_US:en' LC_ALL='en_US.UTF-8' 110 | 111 | #-------------------------------------------------------------------------- 112 | # Final Touches 113 | #-------------------------------------------------------------------------- 114 | 115 | # install required libs for health check 116 | RUN apt-get -y install libfcgi0ldbl nano htop iotop lsof cron mariadb-client redis-tools wget 117 | 118 | # install composer 119 | RUN EXPECTED_CHECKSUM="$(wget -q -O - https://composer.github.io/installer.sig)" && \ 120 | php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" && \ 121 | ACTUAL_CHECKSUM="$(php -r "echo hash_file('sha384', 'composer-setup.php');")" && \ 122 | if [ "$EXPECTED_CHECKSUM" != "$ACTUAL_CHECKSUM" ]; then >&2 echo 'ERROR: Invalid installer checksum' && exit 1; fi 123 | 124 | RUN php composer-setup.php --quiet && rm composer-setup.php && \ 125 | mv composer.phar /usr/local/sbin/composer && \ 126 | chmod +x /usr/local/sbin/composer 127 | 128 | # install NewRelic agent 129 | RUN echo 'deb http://apt.newrelic.com/debian/ newrelic non-free' | tee /etc/apt/sources.list.d/newrelic.list && \ 130 | curl https://download.newrelic.com/548C16BF.gpg | apt-key add - && \ 131 | apt-get -y update && \ 132 | DEBIAN_FRONTEND=noninteractive apt-get -y install newrelic-php5 newrelic-sysmond && \ 133 | export NR_INSTALL_SILENT=1 && newrelic-install install 134 | 135 | # install SendGrid 136 | RUN echo "postfix postfix/mailname string localhost" | debconf-set-selections && \ 137 | echo "postfix postfix/main_mailer_type string 'Internet Site'" | debconf-set-selections && \ 138 | DEBIAN_FRONTEND=noninteractive apt-get install postfix libsasl2-modules -y 139 | 140 | # Set default work directory 141 | ADD scripts/* /usr/local/bin/ 142 | RUN chmod +x /usr/local/bin/* 143 | 144 | # Add default configuration files 145 | ADD configs/php.ini /usr/local/etc/php/ 146 | ADD configs/www.conf /usr/local/etc/php-fpm.d/ 147 | 148 | # Health check 149 | RUN echo '#!/bin/bash' > /healthcheck && \ 150 | echo 'env -i SCRIPT_NAME=/health SCRIPT_FILENAME=/health REQUEST_METHOD=GET cgi-fcgi -bind -connect 127.0.0.1:9000 || exit 1' >> /healthcheck && \ 151 | chmod +x /healthcheck 152 | 153 | # Clean up 154 | RUN apt-get remove -y git && apt-get autoremove -y && apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* 155 | 156 | WORKDIR / 157 | -------------------------------------------------------------------------------- /7.3/configs/cron: -------------------------------------------------------------------------------- 1 | * * * * * root /cfgs/job.sh 2 | -------------------------------------------------------------------------------- /7.3/configs/job.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | echo "[ cronjob task ] executed at `date`" > /proc/1/fd/2 3 | -------------------------------------------------------------------------------- /7.3/configs/pools/test1.conf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/markhilton/docker-php-fpm/4c4c07d77ac886627885ab82d5ca1e1ceeb7119f/7.3/configs/pools/test1.conf -------------------------------------------------------------------------------- /7.3/configs/pools/test2.conf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/markhilton/docker-php-fpm/4c4c07d77ac886627885ab82d5ca1e1ceeb7119f/7.3/configs/pools/test2.conf -------------------------------------------------------------------------------- /7.3/configs/pools/test3-pool.conf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/markhilton/docker-php-fpm/4c4c07d77ac886627885ab82d5ca1e1ceeb7119f/7.3/configs/pools/test3-pool.conf -------------------------------------------------------------------------------- /7.3/configs/pools/test4-pool.conf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/markhilton/docker-php-fpm/4c4c07d77ac886627885ab82d5ca1e1ceeb7119f/7.3/configs/pools/test4-pool.conf -------------------------------------------------------------------------------- /7.3/configs/start.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | echo "[ start.sh ] Boot script test..." > /proc/1/fd/2 3 | -------------------------------------------------------------------------------- /7.3/docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: "3" 2 | 3 | services: 4 | php73: 5 | build: 6 | context: ./ 7 | dockerfile: Dockerfile 8 | depends_on: 9 | - redis 10 | hostname: php73 11 | container_name: php73 12 | volumes: 13 | - ./configs:/cfgs 14 | env_file: .env 15 | 16 | redis: 17 | image: redis:latest 18 | -------------------------------------------------------------------------------- /7.3/scripts/crontab.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | if [ ! "$PHP_CRONTABS_PATH" == "" ]; then 4 | echo "env CRONTABS_PATH: setting up crontabs [ $PHP_CRONTABS_PATH ]:"; 5 | for f in ${PHP_CRONTABS_PATH}; do 6 | echo " - $f"; 7 | rm -f /etc/cron.d/${f##*/} 8 | cp $f /etc/cron.d/ 9 | chmod 0644 /etc/cron.d/${f##*/} 10 | done 11 | 12 | touch /var/log/cron.log 13 | printenv | grep -v "no_proxy" >> /etc/default/locale 14 | /etc/init.d/cron start > /dev/null 15 | fi 16 | -------------------------------------------------------------------------------- /7.3/scripts/docker-boot: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | echo "[`date +"%d-%b-%Y %T"`] PHP-FPM Docker container boot" 4 | 5 | ### create system user for php pool 6 | if [ ! "$PHP_USER" == "" ] && [ ! "$PHP_UID" == "" ] && [ ! "$PHP_GID" == "" ] && [ ! "$PHP_HOME" == "" ]; then 7 | echo "env PHP_USER: creating new system user: ${PHP_USER} ${PHP_UID}:${PHP_GID} ${PHP_HOME}" 8 | mkdir -p $PHP_HOME && \ 9 | groupadd -f $PHP_USER -g $PHP_GID && \ 10 | useradd -d $PHP_HOME -u $PHP_UID -g $PHP_GID -s /usr/sbin/nologin $PHP_USER 11 | fi 12 | 13 | 14 | ### load PHP ini configurations 15 | if [ ! "$PHP_INI_PATH" == "" ]; then 16 | echo "env PHP_INI_PATH: copy from [ $PHP_INI_PATH ] into [ /usr/local/etc/php/conf.d/ ] folder" 17 | for f in ${PHP_INI_PATH}; do 18 | echo " - $f"; 19 | rm -f /usr/local/etc/php/conf.d/${f##*/} 20 | cp $f /usr/local/etc/php/conf.d/ 21 | done 22 | fi 23 | 24 | 25 | ### make sure to create clean php-fpm.conf 26 | ### to avoid adding multiple times the same lines next 27 | ### in case container is restarting 28 | echo "[global]" > /usr/local/etc/php-fpm.conf 29 | echo "include=etc/php-fpm.d/*.conf" >> /usr/local/etc/php-fpm.conf 30 | 31 | ### load PHP-FPM pool configurations 32 | if [ ! "$PHP_POOL_PATH" == "" ]; then 33 | echo "env PHP_POOL_PATH: copy from [ $PHP_POOL_PATH ] into [ /usr/local/etc/php-fpm.d/ ] folder" 34 | for f in ${PHP_POOL_PATH}; do 35 | echo " - $f"; 36 | rm -f /usr/local/etc/php-fpm.d/${f##*/} 37 | cp $f /usr/local/etc/php-fpm.d/ 38 | done 39 | fi 40 | 41 | 42 | ### scan for config files in folders from PHP_INI_SCAN_DIR 43 | if [ ! -z ${PHP_INI_SCAN_DIR+x} ] && [ "$PHP_INI_SCAN_DIR" != "" ] ; then 44 | echo "env PHP_INI_SCAN_DIR: copy from [ $PHP_INI_SCAN_DIR ] into [ /usr/local/etc/php-fpm.d/ ] folder" 45 | 46 | ### break down path by : separator 47 | IFS=':' read -ra DIRECTORIES <<< "$PHP_INI_SCAN_DIR" 48 | 49 | for DIR in "${DIRECTORIES[@]}"; do 50 | ### check if there are any php pool configuration files to copy 51 | COUNT=`ls -1 $DIR/*.conf 2>/dev/null | wc -l` 52 | 53 | if [ $COUNT != "0" ] ; then 54 | echo " - $DIR/*.conf"; 55 | cp -f $DIR/*.conf /usr/local/etc/php-fpm.d/ 56 | fi 57 | done 58 | fi 59 | 60 | 61 | ### load boot bash scripts 62 | for f in /usr/local/bin/*.sh; do 63 | /bin/bash -c $f 64 | done 65 | 66 | ### load additional on-demand scripts 67 | if [ ! -z ${PHP_BOOT_SCRIPTS+x} ] && [ "$PHP_BOOT_SCRIPTS" != "" ]; then 68 | echo "env PHP_BOOT_SCRIPTS: executing scripts in [ $PHP_BOOT_SCRIPTS ]" 69 | 70 | for f in ${PHP_BOOT_SCRIPTS}; do 71 | echo " - $f"; 72 | 73 | rm -f /usr/local/bin/${f##*/} 74 | cp $f /usr/local/bin/ 75 | 76 | chmod +x /usr/local/bin/${f##*/} 77 | done 78 | 79 | for f in ${PHP_BOOT_SCRIPTS}; do 80 | /bin/bash -c /usr/local/bin/${f##*/} 81 | done 82 | fi 83 | 84 | ### expose php version 85 | echo 86 | /usr/local/bin/php -v 87 | -------------------------------------------------------------------------------- /7.3/scripts/docker-php-entrypoint: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -e 3 | 4 | /usr/local/bin/docker-boot 5 | 6 | # first arg is `-f` or `--some-option` 7 | if [ "${1#-}" != "$1" ]; then 8 | set -- php-fpm "$@" 9 | fi 10 | 11 | exec "$@" 12 | -------------------------------------------------------------------------------- /7.3/scripts/emailtest.php: -------------------------------------------------------------------------------- 1 | /dev/null 9 | 10 | chmod u+rw,g+rw,o+rw /var/log/newrelic/newrelic-daemon.log 11 | else 12 | rm -f /usr/local/etc/php/conf.d/newrelic.ini 13 | fi 14 | -------------------------------------------------------------------------------- /7.3/scripts/phpsendmail: -------------------------------------------------------------------------------- 1 | #!/usr/local/bin/php 2 | 8 | * https://www.howtoforge.com/how-to-log-emails-sent-with-phps-mail-function-to-detect-form-spam 9 | */ 10 | 11 | $sendmail_bin = '/usr/sbin/sendmail'; 12 | 13 | // Get the email content 14 | $mail = ''; 15 | $logline = ''; 16 | $pointer = fopen('php://stdin', 'r'); 17 | 18 | while ($line = fgets($pointer)) { 19 | if (preg_match('/^to:/i', $line) || preg_match('/^from:/i', $line)) { 20 | $logline .= trim($line) . ' '; 21 | } 22 | $mail .= $line; 23 | } 24 | 25 | // Compose the sendmail command 26 | $command = 'echo ' . escapeshellarg($mail) . ' | ' . $sendmail_bin . ' -t -i'; 27 | 28 | if (isset($_SERVER['argc'])) { 29 | for ($i = 1; $i < $_SERVER['argc']; $i++) { 30 | $command .= escapeshellarg($_SERVER['argv'][$i]) . ' '; 31 | } 32 | } 33 | 34 | // Write the log 35 | error_log("Email sent: " . $logline); 36 | 37 | // Execute the command 38 | return shell_exec($command); 39 | -------------------------------------------------------------------------------- /7.3/scripts/sendgrid.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | if [ ! -z ${SENDGRID_API_KEY+x} ] && [ "$SENDGRID_API_KEY" != "" ]; then 4 | echo "env SMTP_LOGIN: sendgrid credentials for email routing"; 5 | echo "[smtp.sendgrid.net]:2525 apikey:${SENDGRID_API_KEY}" > /etc/postfix/sasl_passwd 6 | 7 | postmap /etc/postfix/sasl_passwd 8 | chmod 600 /etc/postfix/sasl_passwd.db 9 | rm /etc/postfix/sasl_passwd 10 | 11 | ### update email relay configuration for SendGrid 12 | sed -i 's/default_transport = error//g' /etc/postfix/main.cf 13 | sed -i 's/relay_transport = error//g' /etc/postfix/main.cf 14 | 15 | ### delete following lines if already exist before adding 16 | sed -i '/relayhost/d' /etc/postfix/main.cf 17 | sed -i '/smtp_tls_security_level/d' /etc/postfix/main.cf 18 | sed -i '/smtp_sasl_auth_enable/d' /etc/postfix/main.cf 19 | sed -i '/smtp_sasl_password_maps/d' /etc/postfix/main.cf 20 | sed -i '/header_size_limit/d' /etc/postfix/main.cf 21 | sed -i '/smtp_sasl_security_options/d' /etc/postfix/main.cf 22 | 23 | ### add following lines 24 | echo "relayhost = [smtp.sendgrid.net]:2525" >> /etc/postfix/main.cf 25 | echo "smtp_tls_security_level = encrypt" >> /etc/postfix/main.cf 26 | echo "smtp_sasl_auth_enable = yes" >> /etc/postfix/main.cf 27 | echo "smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd" >> /etc/postfix/main.cf 28 | echo "header_size_limit = 4096000" >> /etc/postfix/main.cf 29 | echo "smtp_sasl_security_options = noanonymous" >> /etc/postfix/main.cf 30 | 31 | /etc/init.d/postfix start > /dev/null 32 | 33 | ### send test email if TEST_EMAIL env variable is set 34 | if [ ! -z ${TEST_EMAIL+x} ] && [ "$TEST_EMAIL" != "" ]; then 35 | echo " - sending test email to: [ $TEST_EMAIL ]"; 36 | php /usr/local/bin/emailtest.php 37 | fi 38 | fi 39 | -------------------------------------------------------------------------------- /7.3/scripts/session.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | ### update PHP session handler 4 | if [ ! "$PHP_SESSION_HANDLER" == "" ] && [ ! "$PHP_SESSION_PATH" == "" ]; then 5 | echo "env PHP_SESSION_HANDLER: updating php session handler [ $PHP_SESSION_PATH ]" 6 | echo "session.save_handler = $PHP_SESSION_HANDLER" > /usr/local/etc/php/conf.d/zz-session.ini 7 | echo "session.save_path = \"$PHP_SESSION_PATH\"" >> /usr/local/etc/php/conf.d/zz-session.ini 8 | fi 9 | -------------------------------------------------------------------------------- /7.4/.env-example: -------------------------------------------------------------------------------- 1 | PHP_UID=1000 2 | PHP_GID=1000 3 | PHP_HOME=/app 4 | PHP_USER=php-fpm 5 | # PHP_INI_SCAN_DIR=/cfgs:/usr/local/etc/php/conf.d 6 | PHP_INI_PATH=/cfgs/php.ini 7 | PHP_POOL_PATH=/cfgs/*/*-pool.conf 8 | PHP_BOOT_SCRIPTS=/cfgs/start.sh 9 | PHP_CRONTABS_PATH=/cfgs/cron 10 | PHP_SESSION_HANDLER=redis 11 | PHP_SESSION_PATH=tcp://redis.host:6379 12 | 13 | # private 14 | TEST_EMAIL=name@domain.com 15 | NEWRELIC_LICENSE=newrelic_license 16 | SENDGRID_API_KEY=sendgrid_api_key 17 | -------------------------------------------------------------------------------- /7.4/.gitignore: -------------------------------------------------------------------------------- 1 | .env 2 | -------------------------------------------------------------------------------- /7.4/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM php:7.4-fpm 2 | 3 | RUN apt-get update -y 4 | RUN apt-get -y install gcc make autoconf libc-dev pkg-config libzip-dev 5 | 6 | RUN apt-get install -y --no-install-recommends \ 7 | git \ 8 | libmemcached-dev \ 9 | libz-dev \ 10 | libpq-dev \ 11 | libssl-dev libssl-doc libsasl2-dev \ 12 | libmcrypt-dev \ 13 | libxml2-dev \ 14 | zlib1g-dev libicu-dev g++ \ 15 | libldap2-dev libbz2-dev \ 16 | curl libcurl4-openssl-dev \ 17 | libenchant-dev libgmp-dev firebird-dev libib-util \ 18 | re2c libpng++-dev \ 19 | libwebp-dev libjpeg-dev libjpeg62-turbo-dev libpng-dev libxpm-dev libvpx-dev libfreetype6-dev \ 20 | libmagick++-dev \ 21 | libmagickwand-dev \ 22 | zlib1g-dev libgd-dev \ 23 | libtidy-dev libxslt1-dev libmagic-dev libexif-dev file \ 24 | sqlite3 libsqlite3-dev libxslt-dev \ 25 | libmhash2 libmhash-dev libc-client-dev libkrb5-dev libssh2-1-dev \ 26 | unzip libpcre3 libpcre3-dev \ 27 | poppler-utils ghostscript libmagickwand-6.q16-dev libsnmp-dev libedit-dev libreadline6-dev libsodium-dev \ 28 | freetds-bin freetds-dev freetds-common libct4 libsybdb5 tdsodbc libreadline-dev librecode-dev libpspell-dev libonig-dev 29 | 30 | # fix for docker-php-ext-install pdo_dblib 31 | # https://stackoverflow.com/questions/43617752/docker-php-and-freetds-cannot-find-freetds-in-know-installation-directories 32 | RUN ln -s /usr/lib/x86_64-linux-gnu/libsybdb.so /usr/lib/ 33 | 34 | # RUN docker-php-ext-configure hash --with-mhash && \ 35 | # docker-php-ext-install hash 36 | RUN docker-php-ext-configure imap --with-kerberos --with-imap-ssl && \ 37 | docker-php-ext-install imap iconv 38 | 39 | RUN docker-php-ext-install bcmath bz2 calendar ctype curl dba dom enchant 40 | RUN docker-php-ext-install fileinfo exif ftp gettext gmp 41 | RUN docker-php-ext-install intl json ldap mbstring mysqli 42 | RUN docker-php-ext-install opcache pcntl pspell 43 | RUN docker-php-ext-install pdo pdo_dblib pdo_mysql pdo_pgsql pdo_sqlite pgsql phar posix 44 | RUN docker-php-ext-install readline 45 | RUN docker-php-ext-install session shmop simplexml soap sockets sodium 46 | RUN docker-php-ext-install sysvmsg sysvsem sysvshm 47 | # RUN docker-php-ext-install snmp 48 | 49 | # fix for docker-php-ext-install xmlreader 50 | # https://github.com/docker-library/php/issues/373 51 | RUN export CFLAGS="-I/usr/src/php" && docker-php-ext-install xmlreader xmlwriter xml xmlrpc xsl 52 | 53 | RUN docker-php-ext-install tidy tokenizer zend_test zip 54 | 55 | # already build in... what they say... 56 | # RUN docker-php-ext-install filter reflection spl standard 57 | # RUN docker-php-ext-install pdo_firebird pdo_oci 58 | 59 | # install pecl extension 60 | RUN pecl install ds && \ 61 | pecl install imagick && \ 62 | pecl install igbinary && \ 63 | pecl install memcached && \ 64 | pecl install redis-5.1.0 && \ 65 | pecl install mcrypt-1.0.3 && \ 66 | docker-php-ext-enable ds imagick igbinary redis memcached 67 | 68 | # https://serverpilot.io/docs/how-to-install-the-php-ssh2-extension 69 | # pecl install ssh2-1.1.2 && \ 70 | # docker-php-ext-enable ssh2 71 | 72 | # install pecl extension 73 | RUN pecl install mongodb && docker-php-ext-enable mongodb 74 | 75 | # install xdebug 76 | # RUN pecl install xdebug && docker-php-ext-enable xdebug 77 | 78 | RUN yes "" | pecl install msgpack && \ 79 | docker-php-ext-enable msgpack 80 | 81 | # install APCu 82 | RUN pecl install apcu && \ 83 | docker-php-ext-enable apcu --ini-name docker-php-ext-10-apcu.ini 84 | 85 | RUN apt-get update -y && apt-get install -y apt-transport-https locales gnupg 86 | 87 | # install MSSQL support and ODBC driver 88 | # RUN curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add - && \ 89 | # curl https://packages.microsoft.com/config/debian/8/prod.list > /etc/apt/sources.list.d/mssql-release.list && \ 90 | # export DEBIAN_FRONTEND=noninteractive && apt-get update -y && \ 91 | # ACCEPT_EULA=Y apt-get install -y msodbcsql unixodbc-dev 92 | # RUN set -xe \ 93 | # && pecl install pdo_sqlsrv \ 94 | # && docker-php-ext-enable pdo_sqlsrv \ 95 | # && apt-get purge -y unixodbc-dev && apt-get autoremove -y && apt-get clean 96 | 97 | # RUN docker-php-ext-configure spl && docker-php-ext-install spl 98 | 99 | # install GD 100 | RUN docker-php-ext-configure gd \ 101 | # --with-png \ 102 | --with-jpeg \ 103 | --with-xpm \ 104 | --with-webp \ 105 | --with-freetype \ 106 | && docker-php-ext-install -j$(nproc) gd 107 | 108 | # set locale to utf-8 109 | RUN echo "en_US.UTF-8 UTF-8" > /etc/locale.gen && locale-gen 110 | ENV LANG='en_US.UTF-8' LANGUAGE='en_US:en' LC_ALL='en_US.UTF-8' 111 | 112 | #-------------------------------------------------------------------------- 113 | # Final Touches 114 | #-------------------------------------------------------------------------- 115 | 116 | # install required libs for health check 117 | RUN apt-get -y install libfcgi0ldbl nano htop iotop lsof cron mariadb-client redis-tools wget 118 | 119 | # install composer 120 | RUN EXPECTED_CHECKSUM="$(wget -q -O - https://composer.github.io/installer.sig)" && \ 121 | php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" && \ 122 | ACTUAL_CHECKSUM="$(php -r "echo hash_file('sha384', 'composer-setup.php');")" && \ 123 | if [ "$EXPECTED_CHECKSUM" != "$ACTUAL_CHECKSUM" ]; then >&2 echo 'ERROR: Invalid installer checksum' && exit 1; fi 124 | 125 | RUN php composer-setup.php --quiet && rm composer-setup.php && \ 126 | mv composer.phar /usr/local/sbin/composer && \ 127 | chmod +x /usr/local/sbin/composer 128 | 129 | # install NewRelic agent 130 | RUN echo 'deb http://apt.newrelic.com/debian/ newrelic non-free' | tee /etc/apt/sources.list.d/newrelic.list && \ 131 | curl https://download.newrelic.com/548C16BF.gpg | apt-key add - && \ 132 | apt-get -y update && \ 133 | DEBIAN_FRONTEND=noninteractive apt-get -y install newrelic-php5 newrelic-sysmond && \ 134 | export NR_INSTALL_SILENT=1 && newrelic-install install 135 | 136 | # install SendGrid 137 | RUN echo "postfix postfix/mailname string localhost" | debconf-set-selections && \ 138 | echo "postfix postfix/main_mailer_type string 'Internet Site'" | debconf-set-selections && \ 139 | DEBIAN_FRONTEND=noninteractive apt-get install postfix libsasl2-modules -y 140 | 141 | # Set default work directory 142 | ADD scripts/* /usr/local/bin/ 143 | RUN chmod +x /usr/local/bin/* 144 | 145 | # Add default configuration files 146 | ADD configs/php.ini /usr/local/etc/php/ 147 | ADD configs/www.conf /usr/local/etc/php-fpm.d/ 148 | 149 | # Health check 150 | RUN echo '#!/bin/bash' > /healthcheck && \ 151 | echo 'env -i SCRIPT_NAME=/health SCRIPT_FILENAME=/health REQUEST_METHOD=GET cgi-fcgi -bind -connect 127.0.0.1:9000 || exit 1' >> /healthcheck && \ 152 | chmod +x /healthcheck 153 | 154 | # Clean up 155 | RUN apt-get remove -y git && apt-get autoremove -y && apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* 156 | 157 | WORKDIR / 158 | -------------------------------------------------------------------------------- /7.4/configs/cron: -------------------------------------------------------------------------------- 1 | * * * * * root /cfgs/job.sh 2 | -------------------------------------------------------------------------------- /7.4/configs/job.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | echo "[ cronjob task ] executed at `date`" > /proc/1/fd/2 3 | -------------------------------------------------------------------------------- /7.4/configs/pools/test1.conf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/markhilton/docker-php-fpm/4c4c07d77ac886627885ab82d5ca1e1ceeb7119f/7.4/configs/pools/test1.conf -------------------------------------------------------------------------------- /7.4/configs/pools/test2.conf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/markhilton/docker-php-fpm/4c4c07d77ac886627885ab82d5ca1e1ceeb7119f/7.4/configs/pools/test2.conf -------------------------------------------------------------------------------- /7.4/configs/pools/test3-pool.conf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/markhilton/docker-php-fpm/4c4c07d77ac886627885ab82d5ca1e1ceeb7119f/7.4/configs/pools/test3-pool.conf -------------------------------------------------------------------------------- /7.4/configs/pools/test4-pool.conf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/markhilton/docker-php-fpm/4c4c07d77ac886627885ab82d5ca1e1ceeb7119f/7.4/configs/pools/test4-pool.conf -------------------------------------------------------------------------------- /7.4/configs/start.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | echo "[ start.sh ] Boot script test..." > /proc/1/fd/2 3 | -------------------------------------------------------------------------------- /7.4/docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: "3" 2 | 3 | services: 4 | php74: 5 | build: 6 | context: ./ 7 | dockerfile: Dockerfile 8 | depends_on: 9 | - redis 10 | hostname: php74 11 | container_name: php74 12 | volumes: 13 | - ./configs:/cfgs 14 | env_file: .env 15 | 16 | redis: 17 | image: redis:latest 18 | -------------------------------------------------------------------------------- /7.4/scripts/crontab.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | if [ ! "$PHP_CRONTABS_PATH" == "" ]; then 4 | echo "env CRONTABS_PATH: setting up crontabs [ $PHP_CRONTABS_PATH ]:"; 5 | for f in ${PHP_CRONTABS_PATH}; do 6 | echo " - $f"; 7 | rm -f /etc/cron.d/${f##*/} 8 | cp $f /etc/cron.d/ 9 | chmod 0644 /etc/cron.d/${f##*/} 10 | done 11 | 12 | touch /var/log/cron.log 13 | printenv | grep -v "no_proxy" >> /etc/default/locale 14 | /etc/init.d/cron start > /dev/null 15 | fi 16 | -------------------------------------------------------------------------------- /7.4/scripts/docker-boot: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | echo "[`date +"%d-%b-%Y %T"`] PHP-FPM Docker container boot" 4 | 5 | ### create system user for php pool 6 | if [ ! "$PHP_USER" == "" ] && [ ! "$PHP_UID" == "" ] && [ ! "$PHP_GID" == "" ] && [ ! "$PHP_HOME" == "" ]; then 7 | echo "env PHP_USER: creating new system user: ${PHP_USER} ${PHP_UID}:${PHP_GID} ${PHP_HOME}" 8 | mkdir -p $PHP_HOME && \ 9 | groupadd -f $PHP_USER -g $PHP_GID && \ 10 | useradd -d $PHP_HOME -u $PHP_UID -g $PHP_GID -s /usr/sbin/nologin $PHP_USER 11 | fi 12 | 13 | 14 | ### load PHP ini configurations 15 | if [ ! "$PHP_INI_PATH" == "" ]; then 16 | echo "env PHP_INI_PATH: copy from [ $PHP_INI_PATH ] into [ /usr/local/etc/php/conf.d/ ] folder" 17 | for f in ${PHP_INI_PATH}; do 18 | echo " - $f"; 19 | rm -f /usr/local/etc/php/conf.d/${f##*/} 20 | cp $f /usr/local/etc/php/conf.d/ 21 | done 22 | fi 23 | 24 | 25 | ### make sure to create clean php-fpm.conf 26 | ### to avoid adding multiple times the same lines next 27 | ### in case container is restarting 28 | echo "[global]" > /usr/local/etc/php-fpm.conf 29 | echo "include=etc/php-fpm.d/*.conf" >> /usr/local/etc/php-fpm.conf 30 | 31 | ### load PHP-FPM pool configurations 32 | if [ ! "$PHP_POOL_PATH" == "" ]; then 33 | echo "env PHP_POOL_PATH: copy from [ $PHP_POOL_PATH ] into [ /usr/local/etc/php-fpm.d/ ] folder" 34 | for f in ${PHP_POOL_PATH}; do 35 | echo " - $f"; 36 | rm -f /usr/local/etc/php-fpm.d/${f##*/} 37 | cp $f /usr/local/etc/php-fpm.d/ 38 | done 39 | fi 40 | 41 | 42 | ### scan for config files in folders from PHP_INI_SCAN_DIR 43 | if [ ! -z ${PHP_INI_SCAN_DIR+x} ] && [ "$PHP_INI_SCAN_DIR" != "" ] ; then 44 | echo "env PHP_INI_SCAN_DIR: copy from [ $PHP_INI_SCAN_DIR ] into [ /usr/local/etc/php-fpm.d/ ] folder" 45 | 46 | ### break down path by : separator 47 | IFS=':' read -ra DIRECTORIES <<< "$PHP_INI_SCAN_DIR" 48 | 49 | for DIR in "${DIRECTORIES[@]}"; do 50 | ### check if there are any php pool configuration files to copy 51 | COUNT=`ls -1 $DIR/*.conf 2>/dev/null | wc -l` 52 | 53 | if [ $COUNT != "0" ] ; then 54 | echo " - $DIR/*.conf"; 55 | cp -f $DIR/*.conf /usr/local/etc/php-fpm.d/ 56 | fi 57 | done 58 | fi 59 | 60 | 61 | ### load boot bash scripts 62 | for f in /usr/local/bin/*.sh; do 63 | /bin/bash -c $f 64 | done 65 | 66 | ### load additional on-demand scripts 67 | if [ ! -z ${PHP_BOOT_SCRIPTS+x} ] && [ "$PHP_BOOT_SCRIPTS" != "" ]; then 68 | echo "env PHP_BOOT_SCRIPTS: executing scripts in [ $PHP_BOOT_SCRIPTS ]" 69 | 70 | for f in ${PHP_BOOT_SCRIPTS}; do 71 | echo " - $f"; 72 | 73 | rm -f /usr/local/bin/${f##*/} 74 | cp $f /usr/local/bin/ 75 | 76 | chmod +x /usr/local/bin/${f##*/} 77 | done 78 | 79 | for f in ${PHP_BOOT_SCRIPTS}; do 80 | /bin/bash -c /usr/local/bin/${f##*/} 81 | done 82 | fi 83 | 84 | ### expose php version 85 | echo 86 | /usr/local/bin/php -v 87 | -------------------------------------------------------------------------------- /7.4/scripts/docker-php-entrypoint: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -e 3 | 4 | /usr/local/bin/docker-boot 5 | 6 | # first arg is `-f` or `--some-option` 7 | if [ "${1#-}" != "$1" ]; then 8 | set -- php-fpm "$@" 9 | fi 10 | 11 | exec "$@" 12 | -------------------------------------------------------------------------------- /7.4/scripts/emailtest.php: -------------------------------------------------------------------------------- 1 | /dev/null 9 | 10 | chmod u+rw,g+rw,o+rw /var/log/newrelic/newrelic-daemon.log 11 | else 12 | rm -f /usr/local/etc/php/conf.d/newrelic.ini 13 | fi 14 | -------------------------------------------------------------------------------- /7.4/scripts/phpsendmail: -------------------------------------------------------------------------------- 1 | #!/usr/local/bin/php 2 | 8 | * https://www.howtoforge.com/how-to-log-emails-sent-with-phps-mail-function-to-detect-form-spam 9 | */ 10 | 11 | $sendmail_bin = '/usr/sbin/sendmail'; 12 | 13 | // Get the email content 14 | $mail = ''; 15 | $logline = ''; 16 | $pointer = fopen('php://stdin', 'r'); 17 | 18 | while ($line = fgets($pointer)) { 19 | if (preg_match('/^to:/i', $line) || preg_match('/^from:/i', $line)) { 20 | $logline .= trim($line) . ' '; 21 | } 22 | $mail .= $line; 23 | } 24 | 25 | // Compose the sendmail command 26 | $command = 'echo ' . escapeshellarg($mail) . ' | ' . $sendmail_bin . ' -t -i'; 27 | 28 | if (isset($_SERVER['argc'])) { 29 | for ($i = 1; $i < $_SERVER['argc']; $i++) { 30 | $command .= escapeshellarg($_SERVER['argv'][$i]) . ' '; 31 | } 32 | } 33 | 34 | // Write the log 35 | error_log("Email sent: " . $logline); 36 | 37 | // Execute the command 38 | return shell_exec($command); 39 | -------------------------------------------------------------------------------- /7.4/scripts/sendgrid.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | if [ ! -z ${SENDGRID_API_KEY+x} ] && [ "$SENDGRID_API_KEY" != "" ]; then 4 | echo "env SENDGRID_API_KEY: sendgrid credentials for email routing"; 5 | echo "[smtp.sendgrid.net]:2525 apikey:${SENDGRID_API_KEY}" > /etc/postfix/sasl_passwd 6 | 7 | postmap /etc/postfix/sasl_passwd 8 | chmod 600 /etc/postfix/sasl_passwd.db 9 | rm /etc/postfix/sasl_passwd 10 | 11 | ### update email relay configuration for SendGrid 12 | sed -i 's/default_transport = error//g' /etc/postfix/main.cf 13 | sed -i 's/relay_transport = error//g' /etc/postfix/main.cf 14 | 15 | ### delete following lines if already exist before adding 16 | sed -i '/relayhost/d' /etc/postfix/main.cf 17 | sed -i '/smtp_tls_security_level/d' /etc/postfix/main.cf 18 | sed -i '/smtp_sasl_auth_enable/d' /etc/postfix/main.cf 19 | sed -i '/smtp_sasl_password_maps/d' /etc/postfix/main.cf 20 | sed -i '/header_size_limit/d' /etc/postfix/main.cf 21 | sed -i '/smtp_sasl_security_options/d' /etc/postfix/main.cf 22 | 23 | ### add following lines 24 | echo "relayhost = [smtp.sendgrid.net]:2525" >> /etc/postfix/main.cf 25 | echo "smtp_tls_security_level = encrypt" >> /etc/postfix/main.cf 26 | echo "smtp_sasl_auth_enable = yes" >> /etc/postfix/main.cf 27 | echo "smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd" >> /etc/postfix/main.cf 28 | echo "header_size_limit = 4096000" >> /etc/postfix/main.cf 29 | echo "smtp_sasl_security_options = noanonymous" >> /etc/postfix/main.cf 30 | 31 | /etc/init.d/postfix start > /dev/null 32 | 33 | ### send test email if TEST_EMAIL env variable is set 34 | if [ ! -z ${TEST_EMAIL+x} ] && [ "$TEST_EMAIL" != "" ]; then 35 | echo " - sending test email to: [ $TEST_EMAIL ]"; 36 | php /usr/local/bin/emailtest.php 37 | fi 38 | fi 39 | -------------------------------------------------------------------------------- /7.4/scripts/session.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | ### update PHP session handler 4 | if [ ! "$PHP_SESSION_HANDLER" == "" ] && [ ! "$PHP_SESSION_PATH" == "" ]; then 5 | echo "env PHP_SESSION_HANDLER: updating php session handler [ $PHP_SESSION_PATH ]" 6 | echo "session.save_handler = $PHP_SESSION_HANDLER" > /usr/local/etc/php/conf.d/zz-session.ini 7 | echo "session.save_path = \"$PHP_SESSION_PATH\"" >> /usr/local/etc/php/conf.d/zz-session.ini 8 | fi 9 | -------------------------------------------------------------------------------- /8.0/.env-example: -------------------------------------------------------------------------------- 1 | PHP_UID=1000 2 | PHP_GID=1000 3 | PHP_HOME=/app 4 | PHP_USER=php-fpm 5 | # PHP_INI_SCAN_DIR=/cfgs:/usr/local/etc/php/conf.d 6 | PHP_INI_PATH=/cfgs/php.ini 7 | PHP_POOL_PATH=/cfgs/*/*-pool.conf 8 | PHP_BOOT_SCRIPTS=/cfgs/start.sh 9 | PHP_CRONTABS_PATH=/cfgs/cron 10 | PHP_SESSION_HANDLER=redis 11 | PHP_SESSION_PATH=tcp://redis.host:6379 12 | 13 | # private 14 | TEST_EMAIL=name@domain.com 15 | NEWRELIC_LICENSE=newrelic_license 16 | SENDGRID_API_KEY=sendgrid_api_key 17 | -------------------------------------------------------------------------------- /8.0/.gitignore: -------------------------------------------------------------------------------- 1 | .env 2 | -------------------------------------------------------------------------------- /8.0/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM php:8.0-fpm 2 | 3 | RUN apt-get update -y 4 | RUN apt-get -y install gcc make autoconf libc-dev pkg-config libzip-dev 5 | 6 | RUN apt-get install -y --no-install-recommends \ 7 | git \ 8 | libmemcached-dev \ 9 | libz-dev \ 10 | libpq-dev \ 11 | libssl-dev libssl-doc libsasl2-dev \ 12 | libmcrypt-dev \ 13 | libxml2-dev \ 14 | zlib1g-dev libicu-dev g++ \ 15 | libldap2-dev libbz2-dev \ 16 | curl libcurl4-openssl-dev \ 17 | libgmp-dev firebird-dev libib-util \ 18 | re2c libpng++-dev \ 19 | libwebp-dev libjpeg-dev libjpeg62-turbo-dev libpng-dev libxpm-dev libvpx-dev libfreetype6-dev \ 20 | libmagick++-dev \ 21 | libmagickwand-dev \ 22 | zlib1g-dev libgd-dev \ 23 | libtidy-dev libxslt1-dev libmagic-dev libexif-dev file \ 24 | sqlite3 libsqlite3-dev libxslt-dev \ 25 | libmhash2 libmhash-dev libc-client-dev libkrb5-dev libssh2-1-dev \ 26 | unzip libpcre3 libpcre3-dev \ 27 | poppler-utils ghostscript libmagickwand-6.q16-dev libsnmp-dev libedit-dev libreadline6-dev libsodium-dev \ 28 | freetds-bin freetds-dev freetds-common libct4 libsybdb5 tdsodbc libreadline-dev librecode-dev libpspell-dev libonig-dev 29 | 30 | RUN docker-php-ext-configure imap --with-kerberos --with-imap-ssl && \ 31 | docker-php-ext-install imap iconv 32 | 33 | # fix for docker-php-ext-install pdo_dblib 34 | # https://stackoverflow.com/questions/43617752/docker-php-and-freetds-cannot-find-freetds-in-know-installation-directories 35 | RUN ln -s /usr/lib/x86_64-linux-gnu/libsybdb.so /usr/lib/ 36 | RUN docker-php-ext-install pdo_dblib 37 | 38 | RUN docker-php-ext-install bcmath bz2 calendar ctype curl dba dom 39 | RUN docker-php-ext-install fileinfo exif ftp gettext gmp 40 | RUN docker-php-ext-install intl ldap mbstring mysqli 41 | RUN docker-php-ext-install opcache pcntl pspell 42 | RUN docker-php-ext-install pdo_mysql pdo_pgsql pdo_sqlite pgsql phar posix 43 | RUN docker-php-ext-install session shmop simplexml soap sockets sodium 44 | RUN docker-php-ext-install sysvmsg sysvsem sysvshm 45 | RUN docker-php-ext-install snmp 46 | RUN docker-php-ext-install xml xsl 47 | RUN docker-php-ext-install tidy tokenizer zend_test zip 48 | RUN docker-php-ext-install filter 49 | 50 | # install pecl extension 51 | RUN pecl install ds && \ 52 | pecl install imagick && \ 53 | pecl install igbinary && \ 54 | pecl install memcached && \ 55 | pecl install mcrypt && \ 56 | docker-php-ext-enable ds imagick igbinary memcached 57 | 58 | RUN pecl install mongodb && docker-php-ext-enable mongodb 59 | 60 | # install xdebug 61 | # RUN pecl install xdebug && docker-php-ext-enable xdebug 62 | 63 | RUN yes "" | pecl install msgpack && \ 64 | docker-php-ext-enable msgpack 65 | 66 | # install APCu 67 | RUN pecl install apcu && \ 68 | docker-php-ext-enable apcu --ini-name docker-php-ext-10-apcu.ini 69 | 70 | RUN apt-get update -y && apt-get install -y apt-transport-https locales gnupg 71 | 72 | # install MSSQL support and ODBC driver 73 | # RUN curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add - && \ 74 | # curl https://packages.microsoft.com/config/debian/8/prod.list > /etc/apt/sources.list.d/mssql-release.list && \ 75 | # export DEBIAN_FRONTEND=noninteractive && apt-get update -y && \ 76 | # ACCEPT_EULA=Y apt-get install -y msodbcsql unixodbc-dev 77 | # RUN set -xe \ 78 | # && pecl install pdo_sqlsrv \ 79 | # && docker-php-ext-enable pdo_sqlsrv \ 80 | # && apt-get purge -y unixodbc-dev && apt-get autoremove -y && apt-get clean 81 | 82 | # RUN docker-php-ext-configure spl && docker-php-ext-install spl 83 | 84 | # install GD 85 | RUN docker-php-ext-configure gd \ 86 | --with-jpeg \ 87 | --with-xpm \ 88 | --with-webp \ 89 | --with-freetype \ 90 | && docker-php-ext-install -j$(nproc) gd 91 | 92 | # set locale to utf-8 93 | RUN echo "en_US.UTF-8 UTF-8" > /etc/locale.gen && locale-gen 94 | ENV LANG='en_US.UTF-8' LANGUAGE='en_US:en' LC_ALL='en_US.UTF-8' 95 | 96 | #-------------------------------------------------------------------------- 97 | # Final Touches 98 | #-------------------------------------------------------------------------- 99 | 100 | # install required libs for health check 101 | RUN apt-get -y install libfcgi0ldbl nano htop iotop lsof cron mariadb-client redis-tools wget 102 | 103 | # install composer 104 | RUN EXPECTED_CHECKSUM="$(wget -q -O - https://composer.github.io/installer.sig)" && \ 105 | php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" && \ 106 | ACTUAL_CHECKSUM="$(php -r "echo hash_file('sha384', 'composer-setup.php');")" && \ 107 | if [ "$EXPECTED_CHECKSUM" != "$ACTUAL_CHECKSUM" ]; then >&2 echo 'ERROR: Invalid installer checksum' && exit 1; fi 108 | 109 | RUN php composer-setup.php --quiet && rm composer-setup.php && \ 110 | mv composer.phar /usr/local/sbin/composer && \ 111 | chmod +x /usr/local/sbin/composer 112 | 113 | # install NewRelic agent 114 | RUN echo 'deb [trusted=yes] http://apt.newrelic.com/debian/ newrelic non-free' | tee /etc/apt/sources.list.d/newrelic.list && \ 115 | curl https://download.newrelic.com/548C16BF.gpg | apt-key add - && \ 116 | apt-get -y update && \ 117 | DEBIAN_FRONTEND=noninteractive apt-get -y install newrelic-php5 newrelic-sysmond && \ 118 | export NR_INSTALL_SILENT=1 && newrelic-install install 119 | 120 | # install SendGrid 121 | RUN echo "postfix postfix/mailname string localhost" | debconf-set-selections && \ 122 | echo "postfix postfix/main_mailer_type string 'Internet Site'" | debconf-set-selections && \ 123 | DEBIAN_FRONTEND=noninteractive apt-get install postfix libsasl2-modules -y 124 | 125 | # Set default work directory 126 | ADD scripts/* /usr/local/bin/ 127 | RUN chmod +x /usr/local/bin/* 128 | 129 | # Add default configuration files 130 | ADD configs/php.ini /usr/local/etc/php/ 131 | ADD configs/www.conf /usr/local/etc/php-fpm.d/ 132 | 133 | # Health check 134 | RUN echo '#!/bin/bash' > /healthcheck && \ 135 | echo 'env -i SCRIPT_NAME=/health SCRIPT_FILENAME=/health REQUEST_METHOD=GET cgi-fcgi -bind -connect 127.0.0.1:9000 || exit 1' >> /healthcheck && \ 136 | chmod +x /healthcheck 137 | 138 | # Clean up 139 | RUN apt-get remove -y git && apt-get autoremove -y && apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* 140 | 141 | WORKDIR / 142 | -------------------------------------------------------------------------------- /8.0/configs/cron: -------------------------------------------------------------------------------- 1 | * * * * * root /cfgs/job.sh 2 | -------------------------------------------------------------------------------- /8.0/configs/job.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | echo "[ cronjob task ] executed at `date`" > /proc/1/fd/2 3 | -------------------------------------------------------------------------------- /8.0/configs/pools/test1.conf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/markhilton/docker-php-fpm/4c4c07d77ac886627885ab82d5ca1e1ceeb7119f/8.0/configs/pools/test1.conf -------------------------------------------------------------------------------- /8.0/configs/pools/test2.conf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/markhilton/docker-php-fpm/4c4c07d77ac886627885ab82d5ca1e1ceeb7119f/8.0/configs/pools/test2.conf -------------------------------------------------------------------------------- /8.0/configs/pools/test3-pool.conf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/markhilton/docker-php-fpm/4c4c07d77ac886627885ab82d5ca1e1ceeb7119f/8.0/configs/pools/test3-pool.conf -------------------------------------------------------------------------------- /8.0/configs/pools/test4-pool.conf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/markhilton/docker-php-fpm/4c4c07d77ac886627885ab82d5ca1e1ceeb7119f/8.0/configs/pools/test4-pool.conf -------------------------------------------------------------------------------- /8.0/configs/start.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | echo "[ start.sh ] Boot script test..." > /proc/1/fd/2 3 | -------------------------------------------------------------------------------- /8.0/docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: "3" 2 | 3 | services: 4 | php73: 5 | build: 6 | context: ./ 7 | dockerfile: Dockerfile 8 | depends_on: 9 | - redis 10 | hostname: php73 11 | container_name: php73 12 | volumes: 13 | - ./configs:/cfgs 14 | env_file: .env 15 | 16 | redis: 17 | image: redis:latest 18 | -------------------------------------------------------------------------------- /8.0/scripts/crontab.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | if [ ! "$PHP_CRONTABS_PATH" == "" ]; then 4 | echo "env CRONTABS_PATH: setting up crontabs [ $PHP_CRONTABS_PATH ]:"; 5 | for f in ${PHP_CRONTABS_PATH}; do 6 | echo " - $f"; 7 | rm -f /etc/cron.d/${f##*/} 8 | cp $f /etc/cron.d/ 9 | chmod 0644 /etc/cron.d/${f##*/} 10 | done 11 | 12 | touch /var/log/cron.log 13 | printenv | grep -v "no_proxy" >> /etc/default/locale 14 | /etc/init.d/cron start > /dev/null 15 | fi 16 | -------------------------------------------------------------------------------- /8.0/scripts/docker-boot: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | echo "[`date +"%d-%b-%Y %T"`] PHP-FPM Docker container boot" 4 | 5 | ### create system user for php pool 6 | if [ ! "$PHP_USER" == "" ] && [ ! "$PHP_UID" == "" ] && [ ! "$PHP_GID" == "" ] && [ ! "$PHP_HOME" == "" ]; then 7 | echo "env PHP_USER: creating new system user: ${PHP_USER} ${PHP_UID}:${PHP_GID} ${PHP_HOME}" 8 | mkdir -p $PHP_HOME && \ 9 | groupadd -f $PHP_USER -g $PHP_GID && \ 10 | useradd -d $PHP_HOME -u $PHP_UID -g $PHP_GID -s /usr/sbin/nologin $PHP_USER 11 | fi 12 | 13 | 14 | ### load PHP ini configurations 15 | if [ ! "$PHP_INI_PATH" == "" ]; then 16 | echo "env PHP_INI_PATH: copy from [ $PHP_INI_PATH ] into [ /usr/local/etc/php/conf.d/ ] folder" 17 | for f in ${PHP_INI_PATH}; do 18 | echo " - $f"; 19 | rm -f /usr/local/etc/php/conf.d/${f##*/} 20 | cp $f /usr/local/etc/php/conf.d/ 21 | done 22 | fi 23 | 24 | 25 | ### make sure to create clean php-fpm.conf 26 | ### to avoid adding multiple times the same lines next 27 | ### in case container is restarting 28 | echo "[global]" > /usr/local/etc/php-fpm.conf 29 | echo "include=etc/php-fpm.d/*.conf" >> /usr/local/etc/php-fpm.conf 30 | 31 | ### load PHP-FPM pool configurations 32 | if [ ! "$PHP_POOL_PATH" == "" ]; then 33 | echo "env PHP_POOL_PATH: copy from [ $PHP_POOL_PATH ] into [ /usr/local/etc/php-fpm.d/ ] folder" 34 | for f in ${PHP_POOL_PATH}; do 35 | echo " - $f"; 36 | rm -f /usr/local/etc/php-fpm.d/${f##*/} 37 | cp $f /usr/local/etc/php-fpm.d/ 38 | done 39 | fi 40 | 41 | 42 | ### scan for config files in folders from PHP_INI_SCAN_DIR 43 | if [ ! -z ${PHP_INI_SCAN_DIR+x} ] && [ "$PHP_INI_SCAN_DIR" != "" ] ; then 44 | echo "env PHP_INI_SCAN_DIR: copy from [ $PHP_INI_SCAN_DIR ] into [ /usr/local/etc/php-fpm.d/ ] folder" 45 | 46 | ### break down path by : separator 47 | IFS=':' read -ra DIRECTORIES <<< "$PHP_INI_SCAN_DIR" 48 | 49 | for DIR in "${DIRECTORIES[@]}"; do 50 | ### check if there are any php pool configuration files to copy 51 | COUNT=`ls -1 $DIR/*.conf 2>/dev/null | wc -l` 52 | 53 | if [ $COUNT != "0" ] ; then 54 | echo " - $DIR/*.conf"; 55 | cp -f $DIR/*.conf /usr/local/etc/php-fpm.d/ 56 | fi 57 | done 58 | fi 59 | 60 | 61 | ### load boot bash scripts 62 | for f in /usr/local/bin/*.sh; do 63 | /bin/bash -c $f 64 | done 65 | 66 | ### load additional on-demand scripts 67 | if [ ! -z ${PHP_BOOT_SCRIPTS+x} ] && [ "$PHP_BOOT_SCRIPTS" != "" ]; then 68 | echo "env PHP_BOOT_SCRIPTS: executing scripts in [ $PHP_BOOT_SCRIPTS ]" 69 | 70 | for f in ${PHP_BOOT_SCRIPTS}; do 71 | echo " - $f"; 72 | 73 | rm -f /usr/local/bin/${f##*/} 74 | cp $f /usr/local/bin/ 75 | 76 | chmod +x /usr/local/bin/${f##*/} 77 | done 78 | 79 | for f in ${PHP_BOOT_SCRIPTS}; do 80 | /bin/bash -c /usr/local/bin/${f##*/} 81 | done 82 | fi 83 | 84 | ### expose php version 85 | echo 86 | /usr/local/bin/php -v 87 | -------------------------------------------------------------------------------- /8.0/scripts/docker-php-entrypoint: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -e 3 | 4 | /usr/local/bin/docker-boot 5 | 6 | # first arg is `-f` or `--some-option` 7 | if [ "${1#-}" != "$1" ]; then 8 | set -- php-fpm "$@" 9 | fi 10 | 11 | exec "$@" 12 | -------------------------------------------------------------------------------- /8.0/scripts/emailtest.php: -------------------------------------------------------------------------------- 1 | /dev/null 9 | 10 | chmod u+rw,g+rw,o+rw /var/log/newrelic/newrelic-daemon.log 11 | else 12 | rm -f /usr/local/etc/php/conf.d/newrelic.ini 13 | fi 14 | -------------------------------------------------------------------------------- /8.0/scripts/phpsendmail: -------------------------------------------------------------------------------- 1 | #!/usr/local/bin/php 2 | 8 | * https://www.howtoforge.com/how-to-log-emails-sent-with-phps-mail-function-to-detect-form-spam 9 | */ 10 | 11 | $sendmail_bin = '/usr/sbin/sendmail'; 12 | 13 | // Get the email content 14 | $mail = ''; 15 | $logline = ''; 16 | $pointer = fopen('php://stdin', 'r'); 17 | 18 | while ($line = fgets($pointer)) { 19 | if (preg_match('/^to:/i', $line) || preg_match('/^from:/i', $line)) { 20 | $logline .= trim($line) . ' '; 21 | } 22 | $mail .= $line; 23 | } 24 | 25 | // Compose the sendmail command 26 | $command = 'echo ' . escapeshellarg($mail) . ' | ' . $sendmail_bin . ' -t -i'; 27 | 28 | if (isset($_SERVER['argc'])) { 29 | for ($i = 1; $i < $_SERVER['argc']; $i++) { 30 | $command .= escapeshellarg($_SERVER['argv'][$i]) . ' '; 31 | } 32 | } 33 | 34 | // Write the log 35 | error_log("Email sent: " . $logline); 36 | 37 | // Execute the command 38 | return shell_exec($command); 39 | -------------------------------------------------------------------------------- /8.0/scripts/sendgrid.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | if [ ! -z ${SENDGRID_API_KEY+x} ] && [ "$SENDGRID_API_KEY" != "" ]; then 4 | echo "env SENDGRID_API_KEY: sendgrid credentials for email routing"; 5 | echo "[smtp.sendgrid.net]:2525 apikey:${SENDGRID_API_KEY}" > /etc/postfix/sasl_passwd 6 | 7 | postmap /etc/postfix/sasl_passwd 8 | chmod 600 /etc/postfix/sasl_passwd.db 9 | rm /etc/postfix/sasl_passwd 10 | 11 | ### update email relay configuration for SendGrid 12 | sed -i 's/default_transport = error//g' /etc/postfix/main.cf 13 | sed -i 's/relay_transport = error//g' /etc/postfix/main.cf 14 | 15 | ### delete following lines if already exist before adding 16 | sed -i '/relayhost/d' /etc/postfix/main.cf 17 | sed -i '/smtp_tls_security_level/d' /etc/postfix/main.cf 18 | sed -i '/smtp_sasl_auth_enable/d' /etc/postfix/main.cf 19 | sed -i '/smtp_sasl_password_maps/d' /etc/postfix/main.cf 20 | sed -i '/header_size_limit/d' /etc/postfix/main.cf 21 | sed -i '/smtp_sasl_security_options/d' /etc/postfix/main.cf 22 | 23 | ### add following lines 24 | echo "relayhost = [smtp.sendgrid.net]:2525" >> /etc/postfix/main.cf 25 | echo "smtp_tls_security_level = encrypt" >> /etc/postfix/main.cf 26 | echo "smtp_sasl_auth_enable = yes" >> /etc/postfix/main.cf 27 | echo "smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd" >> /etc/postfix/main.cf 28 | echo "header_size_limit = 4096000" >> /etc/postfix/main.cf 29 | echo "smtp_sasl_security_options = noanonymous" >> /etc/postfix/main.cf 30 | 31 | /etc/init.d/postfix start > /dev/null 32 | 33 | ### send test email if TEST_EMAIL env variable is set 34 | if [ ! -z ${TEST_EMAIL+x} ] && [ "$TEST_EMAIL" != "" ]; then 35 | echo " - sending test email to: [ $TEST_EMAIL ]"; 36 | php /usr/local/bin/emailtest.php 37 | fi 38 | fi 39 | -------------------------------------------------------------------------------- /8.0/scripts/session.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | ### update PHP session handler 4 | if [ ! "$PHP_SESSION_HANDLER" == "" ] && [ ! "$PHP_SESSION_PATH" == "" ]; then 5 | echo "env PHP_SESSION_HANDLER: updating php session handler [ $PHP_SESSION_PATH ]" 6 | echo "session.save_handler = $PHP_SESSION_HANDLER" > /usr/local/etc/php/conf.d/zz-session.ini 7 | echo "session.save_path = \"$PHP_SESSION_PATH\"" >> /usr/local/etc/php/conf.d/zz-session.ini 8 | fi 9 | -------------------------------------------------------------------------------- /8.1/.env-example: -------------------------------------------------------------------------------- 1 | PHP_UID=1000 2 | PHP_GID=1000 3 | PHP_HOME=/app 4 | PHP_USER=php-fpm 5 | # PHP_INI_SCAN_DIR=/cfgs:/usr/local/etc/php/conf.d 6 | PHP_INI_PATH=/cfgs/php.ini 7 | PHP_POOL_PATH=/cfgs/*/*-pool.conf 8 | PHP_BOOT_SCRIPTS=/cfgs/start.sh 9 | PHP_CRONTABS_PATH=/cfgs/cron 10 | PHP_SESSION_HANDLER=redis 11 | PHP_SESSION_PATH=tcp://redis.host:6379 12 | 13 | # private 14 | TEST_EMAIL=name@domain.com 15 | NEWRELIC_LICENSE=newrelic_license 16 | SENDGRID_API_KEY=sendgrid_api_key 17 | -------------------------------------------------------------------------------- /8.1/.gitignore: -------------------------------------------------------------------------------- 1 | .env 2 | -------------------------------------------------------------------------------- /8.1/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM php:8.1-fpm 2 | 3 | RUN apt-get update -y 4 | RUN apt-get -y install gcc make autoconf libc-dev pkg-config libzip-dev 5 | 6 | RUN apt-get install -y --no-install-recommends \ 7 | git \ 8 | libmemcached-dev \ 9 | libz-dev \ 10 | libpq-dev \ 11 | libssl-dev libssl-doc libsasl2-dev \ 12 | libmcrypt-dev \ 13 | libxml2-dev \ 14 | zlib1g-dev libicu-dev g++ \ 15 | libldap2-dev libbz2-dev \ 16 | curl libcurl4-openssl-dev \ 17 | libgmp-dev firebird-dev libib-util \ 18 | re2c libpng++-dev \ 19 | libwebp-dev libjpeg-dev libjpeg62-turbo-dev libpng-dev libxpm-dev libvpx-dev libfreetype6-dev \ 20 | libmagick++-dev \ 21 | libmagickwand-dev \ 22 | zlib1g-dev libgd-dev \ 23 | libtidy-dev libxslt1-dev libmagic-dev libexif-dev file \ 24 | sqlite3 libsqlite3-dev libxslt-dev \ 25 | libmhash2 libmhash-dev libc-client-dev libkrb5-dev libssh2-1-dev \ 26 | unzip libpcre3 libpcre3-dev \ 27 | poppler-utils ghostscript libmagickwand-6.q16-dev libsnmp-dev libedit-dev libreadline6-dev libsodium-dev \ 28 | freetds-bin freetds-dev freetds-common libct4 libsybdb5 tdsodbc libreadline-dev librecode-dev libpspell-dev libonig-dev 29 | 30 | RUN docker-php-ext-configure imap --with-kerberos --with-imap-ssl && \ 31 | docker-php-ext-install imap iconv 32 | 33 | # fix for docker-php-ext-install pdo_dblib 34 | # https://stackoverflow.com/questions/43617752/docker-php-and-freetds-cannot-find-freetds-in-know-installation-directories 35 | RUN ln -s /usr/lib/x86_64-linux-gnu/libsybdb.so /usr/lib/ 36 | RUN docker-php-ext-install pdo_dblib 37 | 38 | RUN docker-php-ext-install bcmath bz2 calendar ctype curl dba dom 39 | RUN docker-php-ext-install fileinfo exif ftp gettext gmp 40 | RUN docker-php-ext-install intl ldap mbstring mysqli 41 | RUN docker-php-ext-install opcache pcntl pspell 42 | RUN docker-php-ext-install pdo_mysql pdo_pgsql pdo_sqlite pgsql phar posix 43 | RUN docker-php-ext-install session shmop simplexml soap sockets sodium 44 | RUN docker-php-ext-install sysvmsg sysvsem sysvshm 45 | RUN docker-php-ext-install snmp 46 | RUN docker-php-ext-install xml xsl 47 | RUN docker-php-ext-install tidy zip 48 | RUN docker-php-ext-install filter 49 | 50 | # install pecl extension 51 | RUN pecl install ds && \ 52 | pecl install imagick && \ 53 | pecl install igbinary && \ 54 | pecl install memcached && \ 55 | pecl install mcrypt && \ 56 | docker-php-ext-enable ds imagick igbinary memcached 57 | 58 | RUN pecl install mongodb && docker-php-ext-enable mongodb 59 | 60 | # install xdebug 61 | # RUN pecl install xdebug && docker-php-ext-enable xdebug 62 | 63 | RUN yes "" | pecl install msgpack && \ 64 | docker-php-ext-enable msgpack 65 | 66 | # install APCu 67 | RUN pecl install apcu && \ 68 | docker-php-ext-enable apcu --ini-name docker-php-ext-10-apcu.ini 69 | 70 | RUN apt-get update -y && apt-get install -y apt-transport-https locales gnupg 71 | 72 | # install MSSQL support and ODBC driver 73 | # RUN curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add - && \ 74 | # curl https://packages.microsoft.com/config/debian/8/prod.list > /etc/apt/sources.list.d/mssql-release.list && \ 75 | # export DEBIAN_FRONTEND=noninteractive && apt-get update -y && \ 76 | # ACCEPT_EULA=Y apt-get install -y msodbcsql unixodbc-dev 77 | # RUN set -xe \ 78 | # && pecl install pdo_sqlsrv \ 79 | # && docker-php-ext-enable pdo_sqlsrv \ 80 | # && apt-get purge -y unixodbc-dev && apt-get autoremove -y && apt-get clean 81 | 82 | # RUN docker-php-ext-configure spl && docker-php-ext-install spl 83 | 84 | # install GD 85 | RUN docker-php-ext-configure gd \ 86 | --with-jpeg \ 87 | --with-xpm \ 88 | --with-webp \ 89 | --with-freetype \ 90 | && docker-php-ext-install -j$(nproc) gd 91 | 92 | # set locale to utf-8 93 | RUN echo "en_US.UTF-8 UTF-8" > /etc/locale.gen && locale-gen 94 | ENV LANG='en_US.UTF-8' LANGUAGE='en_US:en' LC_ALL='en_US.UTF-8' 95 | 96 | #-------------------------------------------------------------------------- 97 | # Final Touches 98 | #-------------------------------------------------------------------------- 99 | 100 | # install required libs for health check 101 | RUN apt-get -y install libfcgi0ldbl nano htop iotop lsof cron mariadb-client redis-tools wget 102 | 103 | # install composer 104 | RUN EXPECTED_CHECKSUM="$(wget -q -O - https://composer.github.io/installer.sig)" && \ 105 | php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" && \ 106 | ACTUAL_CHECKSUM="$(php -r "echo hash_file('sha384', 'composer-setup.php');")" && \ 107 | if [ "$EXPECTED_CHECKSUM" != "$ACTUAL_CHECKSUM" ]; then >&2 echo 'ERROR: Invalid installer checksum' && exit 1; fi 108 | 109 | RUN php composer-setup.php --quiet && rm composer-setup.php && \ 110 | mv composer.phar /usr/local/sbin/composer && \ 111 | chmod +x /usr/local/sbin/composer 112 | 113 | # install NewRelic agent 114 | RUN echo 'deb [trusted=yes] http://apt.newrelic.com/debian/ newrelic non-free' | tee /etc/apt/sources.list.d/newrelic.list && \ 115 | curl https://download.newrelic.com/548C16BF.gpg | apt-key add - && \ 116 | apt-get -y update && \ 117 | DEBIAN_FRONTEND=noninteractive apt-get -y install newrelic-php5 newrelic-sysmond && \ 118 | export NR_INSTALL_SILENT=1 && newrelic-install install 119 | 120 | # install SendGrid 121 | RUN echo "postfix postfix/mailname string localhost" | debconf-set-selections && \ 122 | echo "postfix postfix/main_mailer_type string 'Internet Site'" | debconf-set-selections && \ 123 | DEBIAN_FRONTEND=noninteractive apt-get install postfix libsasl2-modules -y 124 | 125 | # Set default work directory 126 | ADD scripts/* /usr/local/bin/ 127 | RUN chmod +x /usr/local/bin/* 128 | 129 | # Add default configuration files 130 | ADD configs/php.ini /usr/local/etc/php/ 131 | ADD configs/www.conf /usr/local/etc/php-fpm.d/ 132 | 133 | # Health check 134 | RUN echo '#!/bin/bash' > /healthcheck && \ 135 | echo 'env -i SCRIPT_NAME=/health SCRIPT_FILENAME=/health REQUEST_METHOD=GET cgi-fcgi -bind -connect 127.0.0.1:9000 || exit 1' >> /healthcheck && \ 136 | chmod +x /healthcheck 137 | 138 | # Clean up 139 | RUN apt-get remove -y git && apt-get autoremove -y && apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* 140 | 141 | WORKDIR / 142 | -------------------------------------------------------------------------------- /8.1/configs/cron: -------------------------------------------------------------------------------- 1 | * * * * * root /cfgs/job.sh 2 | -------------------------------------------------------------------------------- /8.1/configs/job.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | echo "[ cronjob task ] executed at `date`" > /proc/1/fd/2 3 | -------------------------------------------------------------------------------- /8.1/configs/pools/test1.conf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/markhilton/docker-php-fpm/4c4c07d77ac886627885ab82d5ca1e1ceeb7119f/8.1/configs/pools/test1.conf -------------------------------------------------------------------------------- /8.1/configs/pools/test2.conf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/markhilton/docker-php-fpm/4c4c07d77ac886627885ab82d5ca1e1ceeb7119f/8.1/configs/pools/test2.conf -------------------------------------------------------------------------------- /8.1/configs/pools/test3-pool.conf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/markhilton/docker-php-fpm/4c4c07d77ac886627885ab82d5ca1e1ceeb7119f/8.1/configs/pools/test3-pool.conf -------------------------------------------------------------------------------- /8.1/configs/pools/test4-pool.conf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/markhilton/docker-php-fpm/4c4c07d77ac886627885ab82d5ca1e1ceeb7119f/8.1/configs/pools/test4-pool.conf -------------------------------------------------------------------------------- /8.1/configs/start.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | echo "[ start.sh ] Boot script test..." > /proc/1/fd/2 3 | -------------------------------------------------------------------------------- /8.1/docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: "3" 2 | 3 | services: 4 | php73: 5 | build: 6 | context: ./ 7 | dockerfile: Dockerfile 8 | depends_on: 9 | - redis 10 | hostname: php73 11 | container_name: php73 12 | volumes: 13 | - ./configs:/cfgs 14 | env_file: .env 15 | 16 | redis: 17 | image: redis:latest 18 | -------------------------------------------------------------------------------- /8.1/scripts/crontab.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | if [ ! "$PHP_CRONTABS_PATH" == "" ]; then 4 | echo "env CRONTABS_PATH: setting up crontabs [ $PHP_CRONTABS_PATH ]:"; 5 | for f in ${PHP_CRONTABS_PATH}; do 6 | echo " - $f"; 7 | rm -f /etc/cron.d/${f##*/} 8 | cp $f /etc/cron.d/ 9 | chmod 0644 /etc/cron.d/${f##*/} 10 | done 11 | 12 | touch /var/log/cron.log 13 | printenv | grep -v "no_proxy" >> /etc/default/locale 14 | /etc/init.d/cron start > /dev/null 15 | fi 16 | -------------------------------------------------------------------------------- /8.1/scripts/docker-boot: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | echo "[`date +"%d-%b-%Y %T"`] PHP-FPM Docker container boot" 4 | 5 | ### create system user for php pool 6 | if [ ! "$PHP_USER" == "" ] && [ ! "$PHP_UID" == "" ] && [ ! "$PHP_GID" == "" ] && [ ! "$PHP_HOME" == "" ]; then 7 | echo "env PHP_USER: creating new system user: ${PHP_USER} ${PHP_UID}:${PHP_GID} ${PHP_HOME}" 8 | mkdir -p $PHP_HOME && \ 9 | groupadd -f $PHP_USER -g $PHP_GID && \ 10 | useradd -d $PHP_HOME -u $PHP_UID -g $PHP_GID -s /usr/sbin/nologin $PHP_USER 11 | fi 12 | 13 | 14 | ### load PHP ini configurations 15 | if [ ! "$PHP_INI_PATH" == "" ]; then 16 | echo "env PHP_INI_PATH: copy from [ $PHP_INI_PATH ] into [ /usr/local/etc/php/conf.d/ ] folder" 17 | for f in ${PHP_INI_PATH}; do 18 | echo " - $f"; 19 | rm -f /usr/local/etc/php/conf.d/${f##*/} 20 | cp $f /usr/local/etc/php/conf.d/ 21 | done 22 | fi 23 | 24 | 25 | ### make sure to create clean php-fpm.conf 26 | ### to avoid adding multiple times the same lines next 27 | ### in case container is restarting 28 | echo "[global]" > /usr/local/etc/php-fpm.conf 29 | echo "include=etc/php-fpm.d/*.conf" >> /usr/local/etc/php-fpm.conf 30 | 31 | ### load PHP-FPM pool configurations 32 | if [ ! "$PHP_POOL_PATH" == "" ]; then 33 | echo "env PHP_POOL_PATH: copy from [ $PHP_POOL_PATH ] into [ /usr/local/etc/php-fpm.d/ ] folder" 34 | for f in ${PHP_POOL_PATH}; do 35 | echo " - $f"; 36 | rm -f /usr/local/etc/php-fpm.d/${f##*/} 37 | cp $f /usr/local/etc/php-fpm.d/ 38 | done 39 | fi 40 | 41 | 42 | ### scan for config files in folders from PHP_INI_SCAN_DIR 43 | if [ ! -z ${PHP_INI_SCAN_DIR+x} ] && [ "$PHP_INI_SCAN_DIR" != "" ] ; then 44 | echo "env PHP_INI_SCAN_DIR: copy from [ $PHP_INI_SCAN_DIR ] into [ /usr/local/etc/php-fpm.d/ ] folder" 45 | 46 | ### break down path by : separator 47 | IFS=':' read -ra DIRECTORIES <<< "$PHP_INI_SCAN_DIR" 48 | 49 | for DIR in "${DIRECTORIES[@]}"; do 50 | ### check if there are any php pool configuration files to copy 51 | COUNT=`ls -1 $DIR/*.conf 2>/dev/null | wc -l` 52 | 53 | if [ $COUNT != "0" ] ; then 54 | echo " - $DIR/*.conf"; 55 | cp -f $DIR/*.conf /usr/local/etc/php-fpm.d/ 56 | fi 57 | done 58 | fi 59 | 60 | 61 | ### load boot bash scripts 62 | for f in /usr/local/bin/*.sh; do 63 | /bin/bash -c $f 64 | done 65 | 66 | ### load additional on-demand scripts 67 | if [ ! -z ${PHP_BOOT_SCRIPTS+x} ] && [ "$PHP_BOOT_SCRIPTS" != "" ]; then 68 | echo "env PHP_BOOT_SCRIPTS: executing scripts in [ $PHP_BOOT_SCRIPTS ]" 69 | 70 | for f in ${PHP_BOOT_SCRIPTS}; do 71 | echo " - $f"; 72 | 73 | rm -f /usr/local/bin/${f##*/} 74 | cp $f /usr/local/bin/ 75 | 76 | chmod +x /usr/local/bin/${f##*/} 77 | done 78 | 79 | for f in ${PHP_BOOT_SCRIPTS}; do 80 | /bin/bash -c /usr/local/bin/${f##*/} 81 | done 82 | fi 83 | 84 | ### expose php version 85 | echo 86 | /usr/local/bin/php -v 87 | -------------------------------------------------------------------------------- /8.1/scripts/docker-php-entrypoint: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -e 3 | 4 | /usr/local/bin/docker-boot 5 | 6 | # first arg is `-f` or `--some-option` 7 | if [ "${1#-}" != "$1" ]; then 8 | set -- php-fpm "$@" 9 | fi 10 | 11 | exec "$@" 12 | -------------------------------------------------------------------------------- /8.1/scripts/emailtest.php: -------------------------------------------------------------------------------- 1 | /dev/null 9 | 10 | chmod u+rw,g+rw,o+rw /var/log/newrelic/newrelic-daemon.log 11 | else 12 | rm -f /usr/local/etc/php/conf.d/newrelic.ini 13 | fi 14 | -------------------------------------------------------------------------------- /8.1/scripts/phpsendmail: -------------------------------------------------------------------------------- 1 | #!/usr/local/bin/php 2 | 8 | * https://www.howtoforge.com/how-to-log-emails-sent-with-phps-mail-function-to-detect-form-spam 9 | */ 10 | 11 | $sendmail_bin = '/usr/sbin/sendmail'; 12 | 13 | // Get the email content 14 | $mail = ''; 15 | $logline = ''; 16 | $pointer = fopen('php://stdin', 'r'); 17 | 18 | while ($line = fgets($pointer)) { 19 | if (preg_match('/^to:/i', $line) || preg_match('/^from:/i', $line)) { 20 | $logline .= trim($line) . ' '; 21 | } 22 | $mail .= $line; 23 | } 24 | 25 | // Compose the sendmail command 26 | $command = 'echo ' . escapeshellarg($mail) . ' | ' . $sendmail_bin . ' -t -i'; 27 | 28 | if (isset($_SERVER['argc'])) { 29 | for ($i = 1; $i < $_SERVER['argc']; $i++) { 30 | $command .= escapeshellarg($_SERVER['argv'][$i]) . ' '; 31 | } 32 | } 33 | 34 | // Write the log 35 | error_log("Email sent: " . $logline); 36 | 37 | // Execute the command 38 | return shell_exec($command); 39 | -------------------------------------------------------------------------------- /8.1/scripts/sendgrid.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | if [ ! -z ${SENDGRID_API_KEY+x} ] && [ "$SENDGRID_API_KEY" != "" ]; then 4 | echo "env SENDGRID_API_KEY: sendgrid credentials for email routing"; 5 | echo "[smtp.sendgrid.net]:2525 apikey:${SENDGRID_API_KEY}" > /etc/postfix/sasl_passwd 6 | 7 | postmap /etc/postfix/sasl_passwd 8 | chmod 600 /etc/postfix/sasl_passwd.db 9 | rm /etc/postfix/sasl_passwd 10 | 11 | ### update email relay configuration for SendGrid 12 | sed -i 's/default_transport = error//g' /etc/postfix/main.cf 13 | sed -i 's/relay_transport = error//g' /etc/postfix/main.cf 14 | 15 | ### delete following lines if already exist before adding 16 | sed -i '/relayhost/d' /etc/postfix/main.cf 17 | sed -i '/smtp_tls_security_level/d' /etc/postfix/main.cf 18 | sed -i '/smtp_sasl_auth_enable/d' /etc/postfix/main.cf 19 | sed -i '/smtp_sasl_password_maps/d' /etc/postfix/main.cf 20 | sed -i '/header_size_limit/d' /etc/postfix/main.cf 21 | sed -i '/smtp_sasl_security_options/d' /etc/postfix/main.cf 22 | 23 | ### add following lines 24 | echo "relayhost = [smtp.sendgrid.net]:2525" >> /etc/postfix/main.cf 25 | echo "smtp_tls_security_level = encrypt" >> /etc/postfix/main.cf 26 | echo "smtp_sasl_auth_enable = yes" >> /etc/postfix/main.cf 27 | echo "smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd" >> /etc/postfix/main.cf 28 | echo "header_size_limit = 4096000" >> /etc/postfix/main.cf 29 | echo "smtp_sasl_security_options = noanonymous" >> /etc/postfix/main.cf 30 | 31 | /etc/init.d/postfix start > /dev/null 32 | 33 | ### send test email if TEST_EMAIL env variable is set 34 | if [ ! -z ${TEST_EMAIL+x} ] && [ "$TEST_EMAIL" != "" ]; then 35 | echo " - sending test email to: [ $TEST_EMAIL ]"; 36 | php /usr/local/bin/emailtest.php 37 | fi 38 | fi 39 | -------------------------------------------------------------------------------- /8.1/scripts/session.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | ### update PHP session handler 4 | if [ ! "$PHP_SESSION_HANDLER" == "" ] && [ ! "$PHP_SESSION_PATH" == "" ]; then 5 | echo "env PHP_SESSION_HANDLER: updating php session handler [ $PHP_SESSION_PATH ]" 6 | echo "session.save_handler = $PHP_SESSION_HANDLER" > /usr/local/etc/php/conf.d/zz-session.ini 7 | echo "session.save_path = \"$PHP_SESSION_PATH\"" >> /usr/local/etc/php/conf.d/zz-session.ini 8 | fi 9 | -------------------------------------------------------------------------------- /8.2/.env-example: -------------------------------------------------------------------------------- 1 | PHP_UID=1000 2 | PHP_GID=1000 3 | PHP_HOME=/app 4 | PHP_USER=php-fpm 5 | # PHP_INI_SCAN_DIR=/cfgs:/usr/local/etc/php/conf.d 6 | PHP_INI_PATH=/cfgs/php.ini 7 | PHP_POOL_PATH=/cfgs/*/*-pool.conf 8 | PHP_BOOT_SCRIPTS=/cfgs/start.sh 9 | PHP_CRONTABS_PATH=/cfgs/cron 10 | PHP_SESSION_HANDLER=redis 11 | PHP_SESSION_PATH=tcp://redis.host:6379 12 | 13 | # private 14 | TEST_EMAIL=name@domain.com 15 | NEWRELIC_LICENSE=newrelic_license 16 | SENDGRID_API_KEY=sendgrid_api_key 17 | -------------------------------------------------------------------------------- /8.2/.gitignore: -------------------------------------------------------------------------------- 1 | .env 2 | -------------------------------------------------------------------------------- /8.2/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM php:8.2-fpm 2 | 3 | RUN apt-get update -y 4 | RUN apt-get -y install gcc make autoconf libc-dev pkg-config libzip-dev 5 | 6 | RUN apt-get install -y --no-install-recommends \ 7 | git \ 8 | libz-dev \ 9 | libpq-dev \ 10 | libxml2-dev \ 11 | libmemcached-dev \ 12 | libldap2-dev libbz2-dev \ 13 | zlib1g-dev libicu-dev g++ \ 14 | libssl-dev libssl-doc libsasl2-dev \ 15 | curl libcurl4-openssl-dev 16 | 17 | RUN apt-get install -y --no-install-recommends \ 18 | libgmp-dev firebird-dev libib-util 19 | 20 | RUN apt-get install -y --no-install-recommends \ 21 | re2c libpng++-dev libwebp-dev libjpeg-dev libjpeg62-turbo-dev libpng-dev libxpm-dev libvpx-dev libfreetype6-dev 22 | 23 | RUN apt-get install -y --no-install-recommends \ 24 | python3-lib2to3 libmagick++-dev libmagickwand-dev 25 | 26 | RUN apt-get install -y --no-install-recommends \ 27 | zlib1g-dev libgd-dev \ 28 | unzip libpcre3 libpcre3-dev \ 29 | sqlite3 libsqlite3-dev libxslt-dev \ 30 | libtidy-dev libxslt1-dev libmagic-dev libexif-dev file \ 31 | libmhash2 libmhash-dev libc-client-dev libkrb5-dev libssh2-1-dev \ 32 | poppler-utils ghostscript libmagickwand-6.q16-dev libsnmp-dev libedit-dev libreadline6-dev libsodium-dev \ 33 | freetds-bin freetds-dev freetds-common libct4 libsybdb5 tdsodbc libreadline-dev librecode-dev libpspell-dev libonig-dev 34 | 35 | # issue on linux/amd64 36 | RUN docker-php-ext-configure imap --with-kerberos --with-imap-ssl && docker-php-ext-install imap 37 | 38 | # fix for docker-php-ext-install pdo_dblib 39 | # https://stackoverflow.com/questions/43617752/docker-php-and-freetds-cannot-find-freetds-in-know-installation-directories 40 | RUN ln -s /usr/lib/x86_64-linux-gnu/libsybdb.so /usr/lib/ 41 | RUN docker-php-ext-install pdo_dblib 42 | 43 | RUN docker-php-ext-install dba 44 | RUN docker-php-ext-install ldap 45 | RUN docker-php-ext-install bcmath 46 | RUN docker-php-ext-install bz2 47 | RUN docker-php-ext-install calendar 48 | RUN docker-php-ext-install ctype 49 | RUN docker-php-ext-install curl 50 | RUN docker-php-ext-install dom 51 | RUN docker-php-ext-install fileinfo 52 | RUN docker-php-ext-install filter 53 | RUN docker-php-ext-install exif 54 | RUN docker-php-ext-install ftp 55 | RUN docker-php-ext-install gettext 56 | RUN docker-php-ext-install gmp 57 | RUN docker-php-ext-install iconv 58 | RUN docker-php-ext-install intl 59 | RUN docker-php-ext-install mbstring 60 | RUN docker-php-ext-install mysqli 61 | RUN docker-php-ext-install opcache 62 | RUN docker-php-ext-install pcntl 63 | RUN docker-php-ext-install pspell 64 | RUN docker-php-ext-install pdo_mysql 65 | RUN docker-php-ext-install pdo_pgsql 66 | RUN docker-php-ext-install pdo_sqlite 67 | RUN docker-php-ext-install pgsql 68 | RUN docker-php-ext-install phar 69 | RUN docker-php-ext-install posix 70 | RUN docker-php-ext-install session 71 | RUN docker-php-ext-install shmop 72 | RUN docker-php-ext-install simplexml 73 | RUN docker-php-ext-install soap 74 | RUN docker-php-ext-install sockets 75 | RUN docker-php-ext-install sodium 76 | RUN docker-php-ext-install sysvmsg 77 | RUN docker-php-ext-install sysvsem 78 | RUN docker-php-ext-install sysvshm 79 | RUN docker-php-ext-install snmp 80 | RUN docker-php-ext-install tidy 81 | RUN docker-php-ext-install zip 82 | RUN docker-php-ext-install xsl 83 | RUN docker-php-ext-install xml 84 | 85 | # install GD 86 | RUN docker-php-ext-configure gd --with-jpeg --with-xpm --with-webp --with-freetype && \ 87 | docker-php-ext-install -j$(nproc) gd 88 | 89 | # build fails with spl 90 | # RUN docker-php-ext-configure spl && docker-php-ext-install spl 91 | 92 | # install pecl extension 93 | RUN pecl install ds && docker-php-ext-enable ds 94 | RUN pecl install memcached && docker-php-ext-enable memcached 95 | RUN pecl install imagick && docker-php-ext-enable imagick 96 | RUN pecl install igbinary && docker-php-ext-enable igbinary 97 | RUN pecl install mongodb && docker-php-ext-enable mongodb 98 | RUN pecl install apcu && docker-php-ext-enable apcu --ini-name docker-php-ext-10-apcu.ini 99 | RUN yes "" | pecl install msgpack && docker-php-ext-enable msgpack 100 | 101 | # install xdebug 102 | # RUN pecl install xdebug && docker-php-ext-enable xdebug 103 | 104 | 105 | RUN apt-get update -y && apt-get install -y apt-transport-https locales gnupg 106 | 107 | # install MSSQL support and ODBC driver 108 | # RUN curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add - && \ 109 | # curl https://packages.microsoft.com/config/debian/8/prod.list > /etc/apt/sources.list.d/mssql-release.list && \ 110 | # export DEBIAN_FRONTEND=noninteractive && apt-get update -y && \ 111 | # ACCEPT_EULA=Y apt-get install -y msodbcsql unixodbc-dev 112 | # RUN set -xe \ 113 | # && pecl install pdo_sqlsrv \ 114 | # && docker-php-ext-enable pdo_sqlsrv \ 115 | # && apt-get purge -y unixodbc-dev && apt-get autoremove -y && apt-get clean 116 | 117 | # set locale to utf-8 118 | RUN echo "en_US.UTF-8 UTF-8" > /etc/locale.gen && locale-gen 119 | ENV LANG='en_US.UTF-8' LANGUAGE='en_US:en' LC_ALL='en_US.UTF-8' 120 | 121 | #-------------------------------------------------------------------------- 122 | # Final Touches 123 | #-------------------------------------------------------------------------- 124 | 125 | # install required libs for health check 126 | RUN apt-get -y install libfcgi0ldbl nano htop iotop lsof cron mariadb-client redis-tools wget 127 | 128 | # install composer 129 | RUN EXPECTED_CHECKSUM="$(wget -q -O - https://composer.github.io/installer.sig)" && \ 130 | php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" && \ 131 | ACTUAL_CHECKSUM="$(php -r "echo hash_file('sha384', 'composer-setup.php');")" && \ 132 | if [ "$EXPECTED_CHECKSUM" != "$ACTUAL_CHECKSUM" ]; then >&2 echo 'ERROR: Invalid installer checksum' && exit 1; fi 133 | 134 | RUN php composer-setup.php --quiet && rm composer-setup.php && \ 135 | mv composer.phar /usr/local/sbin/composer && \ 136 | chmod +x /usr/local/sbin/composer 137 | 138 | # install SendGrid 139 | RUN echo "postfix postfix/mailname string localhost" | debconf-set-selections && \ 140 | echo "postfix postfix/main_mailer_type string 'Internet Site'" | debconf-set-selections && \ 141 | DEBIAN_FRONTEND=noninteractive apt-get install postfix libsasl2-modules -y 142 | 143 | # install NewRelic - issue on linux/arm/v7 144 | RUN export NEW_RELIC_AGENT_VERSION=10.11.0.3 \ 145 | && curl -L https://download.newrelic.com/php_agent/archive/${NEW_RELIC_AGENT_VERSION}/newrelic-php5-${NEW_RELIC_AGENT_VERSION}-linux.tar.gz | tar -C /tmp -zx \ 146 | && export NR_INSTALL_USE_CP_NOT_LN=1 \ 147 | && export NR_INSTALL_SILENT=1 \ 148 | && /tmp/newrelic-php5-${NEW_RELIC_AGENT_VERSION}-linux/newrelic-install install \ 149 | && rm -rf /tmp/newrelic-php5-* /tmp/nrinstall* 150 | 151 | # Set default work directory 152 | ADD scripts/* /usr/local/bin/ 153 | RUN chmod +x /usr/local/bin/* 154 | 155 | # Add default configuration files 156 | ADD configs/php.ini /usr/local/etc/php/ 157 | ADD configs/www.conf /usr/local/etc/php-fpm.d/ 158 | 159 | # Health check 160 | RUN echo '#!/bin/bash' > /healthcheck && \ 161 | echo 'env -i SCRIPT_NAME=/health SCRIPT_FILENAME=/health REQUEST_METHOD=GET cgi-fcgi -bind -connect 127.0.0.1:9000 || exit 1' >> /healthcheck && \ 162 | chmod +x /healthcheck 163 | 164 | # Clean up 165 | RUN apt-get remove -y git && apt-get autoremove -y && apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* 166 | 167 | WORKDIR / 168 | -------------------------------------------------------------------------------- /8.2/configs/cron: -------------------------------------------------------------------------------- 1 | * * * * * root /cfgs/job.sh 2 | -------------------------------------------------------------------------------- /8.2/configs/job.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | echo "[ cronjob task ] executed at `date`" > /proc/1/fd/2 3 | -------------------------------------------------------------------------------- /8.2/configs/pools/test1.conf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/markhilton/docker-php-fpm/4c4c07d77ac886627885ab82d5ca1e1ceeb7119f/8.2/configs/pools/test1.conf -------------------------------------------------------------------------------- /8.2/configs/pools/test2.conf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/markhilton/docker-php-fpm/4c4c07d77ac886627885ab82d5ca1e1ceeb7119f/8.2/configs/pools/test2.conf -------------------------------------------------------------------------------- /8.2/configs/pools/test3-pool.conf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/markhilton/docker-php-fpm/4c4c07d77ac886627885ab82d5ca1e1ceeb7119f/8.2/configs/pools/test3-pool.conf -------------------------------------------------------------------------------- /8.2/configs/pools/test4-pool.conf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/markhilton/docker-php-fpm/4c4c07d77ac886627885ab82d5ca1e1ceeb7119f/8.2/configs/pools/test4-pool.conf -------------------------------------------------------------------------------- /8.2/configs/start.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | echo "[ start.sh ] Boot script test..." > /proc/1/fd/2 3 | -------------------------------------------------------------------------------- /8.2/docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: "3" 2 | 3 | services: 4 | php82: 5 | build: 6 | context: ./ 7 | dockerfile: Dockerfile 8 | depends_on: 9 | - redis 10 | hostname: php82 11 | container_name: php82 12 | volumes: 13 | - ./configs:/cfgs 14 | env_file: .env 15 | 16 | redis: 17 | image: redis:latest 18 | -------------------------------------------------------------------------------- /8.2/scripts/crontab.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | if [ ! "$PHP_CRONTABS_PATH" == "" ]; then 4 | echo "env CRONTABS_PATH: setting up crontabs [ $PHP_CRONTABS_PATH ]:"; 5 | for f in ${PHP_CRONTABS_PATH}; do 6 | echo " - $f"; 7 | rm -f /etc/cron.d/${f##*/} 8 | cp $f /etc/cron.d/ 9 | chmod 0644 /etc/cron.d/${f##*/} 10 | done 11 | 12 | touch /var/log/cron.log 13 | printenv | grep -v "no_proxy" >> /etc/default/locale 14 | /etc/init.d/cron start > /dev/null 15 | fi 16 | -------------------------------------------------------------------------------- /8.2/scripts/docker-boot: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | echo "[`date +"%d-%b-%Y %T"`] PHP-FPM Docker container boot" 4 | 5 | ### create system user for php pool 6 | if [ ! "$PHP_USER" == "" ] && [ ! "$PHP_UID" == "" ] && [ ! "$PHP_GID" == "" ] && [ ! "$PHP_HOME" == "" ]; then 7 | echo "env PHP_USER: creating new system user: ${PHP_USER} ${PHP_UID}:${PHP_GID} ${PHP_HOME}" 8 | mkdir -p $PHP_HOME && \ 9 | groupadd -f $PHP_USER -g $PHP_GID && \ 10 | useradd -d $PHP_HOME -u $PHP_UID -g $PHP_GID -s /usr/sbin/nologin $PHP_USER 11 | fi 12 | 13 | 14 | ### load PHP ini configurations 15 | if [ ! "$PHP_INI_PATH" == "" ]; then 16 | echo "env PHP_INI_PATH: copy from [ $PHP_INI_PATH ] into [ /usr/local/etc/php/conf.d/ ] folder" 17 | for f in ${PHP_INI_PATH}; do 18 | echo " - $f"; 19 | rm -f /usr/local/etc/php/conf.d/${f##*/} 20 | cp $f /usr/local/etc/php/conf.d/ 21 | done 22 | fi 23 | 24 | 25 | ### make sure to create clean php-fpm.conf 26 | ### to avoid adding multiple times the same lines next 27 | ### in case container is restarting 28 | echo "[global]" > /usr/local/etc/php-fpm.conf 29 | echo "include=etc/php-fpm.d/*.conf" >> /usr/local/etc/php-fpm.conf 30 | 31 | ### load PHP-FPM pool configurations 32 | if [ ! "$PHP_POOL_PATH" == "" ]; then 33 | echo "env PHP_POOL_PATH: copy from [ $PHP_POOL_PATH ] into [ /usr/local/etc/php-fpm.d/ ] folder" 34 | for f in ${PHP_POOL_PATH}; do 35 | echo " - $f"; 36 | rm -f /usr/local/etc/php-fpm.d/${f##*/} 37 | cp $f /usr/local/etc/php-fpm.d/ 38 | done 39 | fi 40 | 41 | 42 | ### scan for config files in folders from PHP_INI_SCAN_DIR 43 | if [ ! -z ${PHP_INI_SCAN_DIR+x} ] && [ "$PHP_INI_SCAN_DIR" != "" ] ; then 44 | echo "env PHP_INI_SCAN_DIR: copy from [ $PHP_INI_SCAN_DIR ] into [ /usr/local/etc/php-fpm.d/ ] folder" 45 | 46 | ### break down path by : separator 47 | IFS=':' read -ra DIRECTORIES <<< "$PHP_INI_SCAN_DIR" 48 | 49 | for DIR in "${DIRECTORIES[@]}"; do 50 | ### check if there are any php pool configuration files to copy 51 | COUNT=`ls -1 $DIR/*.conf 2>/dev/null | wc -l` 52 | 53 | if [ $COUNT != "0" ] ; then 54 | echo " - $DIR/*.conf"; 55 | cp -f $DIR/*.conf /usr/local/etc/php-fpm.d/ 56 | fi 57 | done 58 | fi 59 | 60 | 61 | ### load boot bash scripts 62 | for f in /usr/local/bin/*.sh; do 63 | /bin/bash -c $f 64 | done 65 | 66 | ### load additional on-demand scripts 67 | if [ ! -z ${PHP_BOOT_SCRIPTS+x} ] && [ "$PHP_BOOT_SCRIPTS" != "" ]; then 68 | echo "env PHP_BOOT_SCRIPTS: executing scripts in [ $PHP_BOOT_SCRIPTS ]" 69 | 70 | for f in ${PHP_BOOT_SCRIPTS}; do 71 | echo " - $f"; 72 | 73 | rm -f /usr/local/bin/${f##*/} 74 | cp $f /usr/local/bin/ 75 | 76 | chmod +x /usr/local/bin/${f##*/} 77 | done 78 | 79 | for f in ${PHP_BOOT_SCRIPTS}; do 80 | /bin/bash -c /usr/local/bin/${f##*/} 81 | done 82 | fi 83 | 84 | ### expose php version 85 | echo 86 | /usr/local/bin/php -v 87 | -------------------------------------------------------------------------------- /8.2/scripts/docker-php-entrypoint: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -e 3 | 4 | /usr/local/bin/docker-boot 5 | 6 | # first arg is `-f` or `--some-option` 7 | if [ "${1#-}" != "$1" ]; then 8 | set -- php-fpm "$@" 9 | fi 10 | 11 | exec "$@" 12 | -------------------------------------------------------------------------------- /8.2/scripts/emailtest.php: -------------------------------------------------------------------------------- 1 | 8 | * https://www.howtoforge.com/how-to-log-emails-sent-with-phps-mail-function-to-detect-form-spam 9 | */ 10 | 11 | $sendmail_bin = '/usr/sbin/sendmail'; 12 | 13 | // Get the email content 14 | $mail = ''; 15 | $logline = ''; 16 | $pointer = fopen('php://stdin', 'r'); 17 | 18 | while ($line = fgets($pointer)) { 19 | if (preg_match('/^to:/i', $line) || preg_match('/^from:/i', $line)) { 20 | $logline .= trim($line) . ' '; 21 | } 22 | $mail .= $line; 23 | } 24 | 25 | // Compose the sendmail command 26 | $command = 'echo ' . escapeshellarg($mail) . ' | ' . $sendmail_bin . ' -t -i'; 27 | 28 | if (isset($_SERVER['argc'])) { 29 | for ($i = 1; $i < $_SERVER['argc']; $i++) { 30 | $command .= escapeshellarg($_SERVER['argv'][$i]) . ' '; 31 | } 32 | } 33 | 34 | // Write the log 35 | error_log("Email sent: " . $logline); 36 | 37 | // Execute the command 38 | return shell_exec($command); 39 | -------------------------------------------------------------------------------- /8.2/scripts/sendgrid.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | if [ ! -z ${SENDGRID_API_KEY+x} ] && [ "$SENDGRID_API_KEY" != "" ]; then 4 | echo "env SENDGRID_API_KEY: sendgrid credentials for email routing"; 5 | echo "[smtp.sendgrid.net]:2525 apikey:${SENDGRID_API_KEY}" > /etc/postfix/sasl_passwd 6 | 7 | postmap /etc/postfix/sasl_passwd 8 | chmod 600 /etc/postfix/sasl_passwd.db 9 | rm /etc/postfix/sasl_passwd 10 | 11 | ### update email relay configuration for SendGrid 12 | sed -i 's/default_transport = error//g' /etc/postfix/main.cf 13 | sed -i 's/relay_transport = error//g' /etc/postfix/main.cf 14 | 15 | ### delete following lines if already exist before adding 16 | sed -i '/relayhost/d' /etc/postfix/main.cf 17 | sed -i '/smtp_tls_security_level/d' /etc/postfix/main.cf 18 | sed -i '/smtp_sasl_auth_enable/d' /etc/postfix/main.cf 19 | sed -i '/smtp_sasl_password_maps/d' /etc/postfix/main.cf 20 | sed -i '/header_size_limit/d' /etc/postfix/main.cf 21 | sed -i '/smtp_sasl_security_options/d' /etc/postfix/main.cf 22 | 23 | ### add following lines 24 | echo "relayhost = [smtp.sendgrid.net]:2525" >> /etc/postfix/main.cf 25 | echo "smtp_tls_security_level = encrypt" >> /etc/postfix/main.cf 26 | echo "smtp_sasl_auth_enable = yes" >> /etc/postfix/main.cf 27 | echo "smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd" >> /etc/postfix/main.cf 28 | echo "header_size_limit = 4096000" >> /etc/postfix/main.cf 29 | echo "smtp_sasl_security_options = noanonymous" >> /etc/postfix/main.cf 30 | 31 | /etc/init.d/postfix start > /dev/null 32 | 33 | ### send test email if TEST_EMAIL env variable is set 34 | if [ ! -z ${TEST_EMAIL+x} ] && [ "$TEST_EMAIL" != "" ]; then 35 | echo " - sending test email to: [ $TEST_EMAIL ]"; 36 | php /usr/local/bin/emailtest.php 37 | fi 38 | fi 39 | -------------------------------------------------------------------------------- /8.2/scripts/session.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | ### update PHP session handler 4 | if [ ! "$PHP_SESSION_HANDLER" == "" ] && [ ! "$PHP_SESSION_PATH" == "" ]; then 5 | echo "env PHP_SESSION_HANDLER: updating php session handler [ $PHP_SESSION_PATH ]" 6 | echo "session.save_handler = $PHP_SESSION_HANDLER" > /usr/local/etc/php/conf.d/zz-session.ini 7 | echo "session.save_path = \"$PHP_SESSION_PATH\"" >> /usr/local/etc/php/conf.d/zz-session.ini 8 | fi 9 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 Mark Hilton 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # PHP-FPM Docker Images 2 | 3 | Docker container to install and run [PHP-FPM](https://php-fpm.org/). 4 | 5 | ## Project Goal 6 | 7 | Out of the box, multi-version, fully loaded PHP-FPM docker images, that can support all my PHP projects. I work with WordPress & Laravel. 8 | The images are no light weight. The aim is to support maximum number of features out of the box, that could be easily turn ON/OFF with environment settings. 9 | 10 | ## Supported branches and respective Dockerfile links 11 | 12 | - 8.2 [Dockerfile](https://github.com/markhilton/docker-php-fpm/blob/master/8.2/Dockerfile) 13 | - 8.1 [Dockerfile](https://github.com/markhilton/docker-php-fpm/blob/master/8.1/Dockerfile) 14 | - 8.0 [Dockerfile](https://github.com/markhilton/docker-php-fpm/blob/master/8.0/Dockerfile) 15 | - 7.4 [Dockerfile](https://github.com/markhilton/docker-php-fpm/blob/master/7.4/Dockerfile) 16 | - 7.3 [Dockerfile](https://github.com/markhilton/docker-php-fpm/blob/master/7.3/Dockerfile) 17 | - 7.2 [Dockerfile](https://github.com/markhilton/docker-php-fpm/blob/master/7.2/Dockerfile) 18 | - 7.1 [Dockerfile](https://github.com/markhilton/docker-php-fpm/blob/master/7.1/Dockerfile) 19 | - 5.6 [Dockerfile](https://github.com/markhilton/docker-php-fpm/blob/master/5.6/Dockerfile) 20 | 21 | ## What is PHP-FPM ? 22 | 23 | PHP-FPM (FastCGI Process Manager) is an alternative FastCGI implementation for PHP. 24 | 25 | ## Environment variables 26 | 27 | Use following environment variables to configure docker container php process manager during container boot up: 28 | 29 | ### [system user](https://manpages.debian.org/stretch/adduser/adduser.8.en.html) 30 | 31 | ```bash 32 | PHP_UID=1000 33 | PHP_GID=1000 34 | PHP_HOME=/app 35 | PHP_USER=php-fpm 36 | ``` 37 | 38 | will run create a system user called `php-fpm` with UID:GUID 1000:1000 and home directory `/app`, which then can be referenced in your php-fpm manager pool configuration file. 39 | 40 | ### [php.ini configuration](http://php.net/manual/en/ini.php) 41 | 42 | ```bash 43 | PHP_INI_PATH=/path/to/php.ini 44 | ``` 45 | 46 | will include specified `php.ini` configuration during php-fpm manager start. It allows to use a wildcard in case you would like to include several .ini configuration files. 47 | 48 | ### [php-fpm pool configurations](http://php.net/manual/en/install.fpm.configuration.php) 49 | 50 | ```bash 51 | PHP_POOL_PATH=/path/to/pool.conf 52 | ``` 53 | 54 | will include specified `pool.conf` configuration during php-fpm manager start. It allows to use a wildcard in case you would like to include several .conf configuration files. 55 | **ATTENTION:** default `www.conf` pool configuration will be loaded, unless you specify path to your custom `www.conf`. 56 | 57 | ### boot scripts 58 | 59 | ```bash 60 | PHP_BOOT_SCRIPTS=/path/to/*.sh 61 | ``` 62 | 63 | will run scripts or a single script from specified path during container boot, before php-fpm manager starts up. Useful in cases when you want to include several pools configurations, where each pool uses a different system user (shared hosting). In those cases you would need to create each system user before php-fom manager starts up. `PHP_BOOT_SCRIPTS` could be use to point to a bash script that will create those system users. 64 | 65 | ### [crontabs](http://crontab.org/) 66 | 67 | ```bash 68 | PHP_CRONTABS_PATH=/path/to/cronttab_scripts 69 | ``` 70 | 71 | will install a crontab defined in `/path/to/cronttab_scripts` and start crontab daemon inside container. 72 | 73 | **example Laravel crontab** 74 | 75 | ```bash 76 | # 77 | # Laravel task scheduler 78 | # 79 | # ATTENTION: 80 | # crontab sh shell requires: 81 | # - a full path to php cli interpreter 82 | # - current dir change to laravel artisan 83 | # - an empty line is required at the end of this file for a valid cron file 84 | 85 | * * * * * php-cli cd /app && /usr/local/bin/php artisan schedule:run 86 | ``` 87 | 88 | ### [NewRelic APM](https://docs.newrelic.com/docs/agents/php-agent/getting-started/introduction-new-relic-php) 89 | 90 | ```bash 91 | NEWRELIC_LICENSE=license_string 92 | ``` 93 | 94 | will turn on NewRelic extension to monitor PHP application performance. 95 | 96 | ### [SendGrid](https://sendgrid.com/) 97 | 98 | starting from latest 7.3 container the Sendgrid login & password credentials are deprecated in favor of API key. 99 | 100 | _deprecated:_ 101 | 102 | ```bash 103 | SMTP_LOGIN=sendgrid_login 104 | SMTP_PASSWORD=sendgrid_password 105 | ``` 106 | 107 | _in favor of API key:_ 108 | 109 | ```bash 110 | SENDGRID_API_KEY=api_key_string 111 | ``` 112 | 113 | will update default email routing via SendGrid. Google Cloud blocks SMTP port 25 by default, so this could be useful solution to set up an alternative email routing before php-fpm manager starts up. 114 | 115 | ```bash 116 | TEST_EMAIL=email@domain.com 117 | ``` 118 | 119 | if set, on container boot the test script will send an email using PHP mail function to given recipient address. 120 | 121 | ### [session handler](http://php.net/manual/en/class.sessionhandler.php) 122 | 123 | to support Redis or Memcached PHP session handler. 124 | 125 | ```bash 126 | PHP_SESSION_HANDLER=php_session_handler 127 | PHP_SESSION_PATH=php_session_path 128 | ``` 129 | 130 | will update default PHP session handler. Useful in cluster environments, to allow shared PHP sessions between cluster instances. 131 | 132 | **[Example Redis session]**(https://www.digitalocean.com/community/tutorials/how-to-set-up-a-redis-server-as-a-session-handler-for-php-on-ubuntu-14-04) 133 | 134 | ```bash 135 | PHP_SESSION_HANDLER=redis 136 | PHP_SESSION_PATH=tcp://redis.host:6379 137 | ``` 138 | 139 | This will set php.ini global session handler to use Redis server accessible at 140 | `redis.host` DNS endpoint name and port 6379. 141 | 142 | **[Example Memcached session]**(https://www.digitalocean.com/community/tutorials/how-to-share-php-sessions-on-multiple-memcached-servers-on-ubuntu-14-04) 143 | 144 | ```bash 145 | PHP_SESSION_HANDLER=memcached 146 | PHP_SESSION_PATH=memcached.host:11211 147 | ``` 148 | 149 | This will set php.ini global session handler to use Memcached server accessible at `memcached.host` DNS endpoint name and port 11211. 150 | 151 | ### [Supervisord](http://supervisord.org/) 152 | 153 | ```bash 154 | SUPERVISORD_PATH=/path/to/supervisord.conf 155 | ``` 156 | 157 | Allows to control and monitor multiple processes running inside the container. Example use case: ensure that there are minimum 8 simultaniously run Laravel Queues available at any time to process scheduled tasks. 158 | 159 | Note that if you use supervisord the container boot script will create a `/healthcheck` file to monitor supervisord main process, which can be used to monitor container health. This example configuration for `docker-compose.yaml` will ensure that container does not exit after boot and redirect supervisord logs into stdout. 160 | 161 | ```bash 162 | command: [ "tail", '-f', '/var/log/supervisor/supervisord.log' ] 163 | healthcheck: 164 | test: /healthcheck 165 | retries: 3 166 | timeout: 5s 167 | interval: 5s 168 | ``` 169 | 170 | ### php access log (on|off) 171 | 172 | ```bash 173 | PHP_ACCESS_LOG=off 174 | ``` 175 | 176 | turns on|off php access log to docker container stdout. 177 | 178 | ### php error log (on|off) 179 | 180 | ```bash 181 | PHP_ERROR_LOG=on 182 | ``` 183 | 184 | turns on|off php error log to docker container stdout. 185 | 186 | ## Installed extensions 187 | 188 | - apc 189 | - apcu 190 | - bcmath 191 | - bz2 192 | - calendar 193 | - Core 194 | - ctype 195 | - curl 196 | - date 197 | - dba 198 | - dom 199 | - ds 200 | - enchant 201 | - exif 202 | - fileinfo 203 | - filter 204 | - ftp 205 | - gd 206 | - gettext 207 | - gmp 208 | - hash 209 | - iconv 210 | - igbinary 211 | - imagick 212 | - imap 213 | - interbase 214 | - intl 215 | - json 216 | - ldap 217 | - libxml 218 | - mbstring 219 | - memcache 220 | - memcached 221 | - mongodb 222 | - msgpack 223 | - mysqli 224 | - mysqlnd 225 | - newrelic 226 | - openssl 227 | - pcntl 228 | - pcre 229 | - PDO 230 | - pdo_dblib 231 | - pdo_mysql 232 | - pdo_pgsql 233 | - pdo_sqlite 234 | - pdo_sqlsrv 235 | - pgsql 236 | - Phar 237 | - posix 238 | - pspell 239 | - readline 240 | - recode 241 | - redis 242 | - Reflection 243 | - session 244 | - shmop 245 | - SimpleXML 246 | - soap 247 | - sockets 248 | - sodium 249 | - SPL 250 | - sqlite3 251 | - ssh2 252 | - standard 253 | - sysvmsg 254 | - sysvsem 255 | - sysvshm 256 | - test 257 | - tidy 258 | - tokenizer 259 | - wddx 260 | - xdebug 261 | - xml 262 | - xmlreader 263 | - xmlrpc 264 | - xmlwriter 265 | - xsl 266 | - Zend OPcache 267 | - zip 268 | - zlib 269 | 270 | ## Installed Zend Modules 271 | 272 | - Xdebug 273 | - Zend OPcache 274 | 275 | ## Pull latest image 276 | 277 | ```sh 278 | docker pull crunchgeek/php-fpm:7.2 279 | ``` 280 | 281 | ## Running PHP apps 282 | 283 | ### Running image 284 | 285 | Run the PHP-FPM image, mounting a directory from your host. 286 | 287 | ```sh 288 | docker run -it --name php-fpm -v /path/to/your/app:/app crunchgeek/php-fpm:7.2 php script.php 289 | ``` 290 | 291 | or using [Docker Compose](https://docs.docker.com/compose/): 292 | 293 | ```sh 294 | version: '3' 295 | services: 296 | php-fpm: 297 | container_name: php-fpm 298 | image: crunchgeek/php-fpm:7.3 299 | entrypoint: php index.php 300 | volumes: 301 | - /path/to/your/app:/app 302 | ``` 303 | 304 | ### Running as server 305 | 306 | ```sh 307 | docker run --rm --name php-fpm -v /path/to/your/app:/app -p 8000:8000 crunchgeek/php-fpm:7.2 php -S 0.0.0.0:8000 /app/index.php 308 | ``` 309 | 310 | ### Logging 311 | 312 | ```sh 313 | docker logs php-fpm 314 | ``` 315 | 316 | # Listing installed extensions 317 | 318 | ```sh 319 | docker run --rm -it crunchgeek/php-fpm:7.2 php -m 320 | ``` 321 | 322 | # Release Notes 323 | 324 | ## PHP-FPM 7.4 325 | 326 | Extensions that failed to build from 7.3 to [7.4](https://www.php.net/ChangeLog-7.php): 327 | 328 | - mhash (Implemented RFC: The hash extension is now an integral part of PHP and cannot be disabled) 329 | - interbase (Unbundled the InterBase extension and moved it to PECL) 330 | - recode (Unbundled the recode extension) 331 | - wddx (Deprecated and unbundled the WDDX extension) 332 | - docker-php-ext-configure gd --with-png [only PNG](https://github.com/docker-library/php/issues/912) 333 | -------------------------------------------------------------------------------- /cloudbuild.yaml: -------------------------------------------------------------------------------- 1 | steps: 2 | # slack deployment status 3 | - name: 'gcr.io/cloud-builders/curl' 4 | args: 5 | [ 6 | '-X', 7 | 'POST', 8 | '-H', 9 | 'Content-type: application/json', 10 | '--data', 11 | '{"text":"gcr.io/${PROJECT_ID}/${_IMAGE}:${_VERSION}${BRANCH_NAME}${TAG_NAME} build started!"}', 12 | '${_WEBHOOK_URL}', 13 | ] 14 | 15 | - name: 'gcr.io/cloud-builders/docker' 16 | args: [ 'build', '-t', 'gcr.io/$PROJECT_ID/$_IMAGE:$_VERSION$BRANCH_NAME$TAG_NAME', '-f', '$_VERSION/Dockerfile', '.' ] 17 | 18 | # slack deployment status 19 | - name: 'gcr.io/cloud-builders/curl' 20 | args: 21 | [ 22 | '-X', 23 | 'POST', 24 | '-H', 25 | 'Content-type: application/json', 26 | '--data', 27 | '{"text":"gcr.io/${PROJECT_ID}/${_IMAGE}:${_VERSION}${BRANCH_NAME}${TAG_NAME} build completed!"}', 28 | '${_WEBHOOK_URL}', 29 | ] 30 | 31 | # extend timeout to 40 min 32 | timeout: 2400s 33 | 34 | # store artifact 35 | images: ['gcr.io/$PROJECT_ID/$_IMAGE:$_VERSION$BRANCH_NAME$TAG_NAME'] 36 | 37 | # arguments 38 | substitutions: 39 | _IMAGE: php-fpm 40 | _VERSION: "7.4" # PHP runtime version 41 | _WEBHOOK_URL: https://hooks.slack.com/services/A/B/C # slack notifications 42 | --------------------------------------------------------------------------------