├── .gitignore ├── LICENSE ├── makedb.php ├── README.md ├── Dockerfile ├── docker-entrypoint.sh ├── nginx └── bedrock └── php └── www.conf /.gitignore: -------------------------------------------------------------------------------- 1 | /Web/wordpress/* 2 | /Web/.vagrant/* 3 | 4 | /Web/wp-content/themes 5 | /Web/wp-content/plugins 6 | 7 | .DS_Store -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016 Adam Yeats 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 | -------------------------------------------------------------------------------- /makedb.php: -------------------------------------------------------------------------------- 1 | makedb.php, 1 => "$MS_DB_HOST", 2 => "$MS_DB_USER", 3 => "$MS_DB_PASSWORD", 4 => "$MS_DB_NAME" 3 | // 4 | $stderr = fopen('php://stderr', 'w'); 5 | fwrite($stderr, "\nEnsuring a WordPress database is present...\n"); 6 | 7 | if (strpos($argv[1], ':') !== false) 8 | { 9 | list($host, $port) = explode(':', $argv[1], 2); 10 | } 11 | else 12 | { 13 | $host = $argv[1]; 14 | $port = 3306; 15 | } 16 | 17 | $maxTries = 10; 18 | 19 | do 20 | { 21 | $mysql = new mysqli($host, $argv[2], $argv[3], '', (int) $port); 22 | if ($mysql->connect_error) 23 | { 24 | fwrite($stderr, "\nMySQL Connection Error: ({$mysql->connect_errno}) {$mysql->connect_error}\n"); 25 | --$maxTries; 26 | if ($maxTries <= 0) 27 | { 28 | exit(1); 29 | } 30 | sleep(3); 31 | } 32 | } 33 | while ($mysql->connect_error); 34 | 35 | if (!$mysql->query('CREATE DATABASE IF NOT EXISTS `' . $mysql->real_escape_string($argv[4]) . '`')) 36 | { 37 | fwrite($stderr, "\nMySQL 'CREATE DATABASE' Error: " . $mysql->error . "\n"); 38 | $mysql->close(); 39 | exit(1); 40 | } 41 | 42 | fwrite($stderr, "\nMySQL Database Created\n"); 43 | $mysql->close(); 44 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # docker-nginx-hhvm-bedrock 2 | :ship: a docker image for wordpress sites built with bedrock 3 | 4 | ## Note 5 | 6 | A year after releasing, I've come to the opinion that Docker is not best suited for this task. Containerizing WordPress seems a little heavy handed for something that can be solved using [Ansible](https://github.com/xadamy/provision/tree/master/bedrock-wordpress) and [Capstrano](https://github.com/xadamy/bedrock-capistrano) much easier, and is much more difficult to configure and debug. I will still be maintaining this repo for the time being, but my personal recommendation would be just to use a regular server instance and deploy using Capistrano or something similar. 7 | 8 | ## What is Bedrock? 9 | 10 | Bedrock is a modern WordPress stack that helps you get started with the best development tools and project structure. 11 | 12 | Much of the philosophy behind Bedrock is inspired by the [Twelve-Factor App](http://12factor.net/) methodology including the [WordPress specific version](https://roots.io/twelve-factor-wordpress/). 13 | 14 | ## Why use this image? 15 | 16 | Rather than using Apache, we instead use `nginx` dispatching `fastcgi` requests to HHVM, with a fallback to `php-fpm` if we get a bad gateway. This should make your Bedrock install a little quicker than your average WordPress installation. 17 | 18 | ## How to use this image 19 | 20 | ### Start a `bedrock` server instance 21 | 22 | ```console 23 | docker run --name your-project-name --link your-mysql-container-name:mysql -p 80:80 -e DB_NAME=your-db-name -e WP_HOME=your-wordpress-site.local adamyeats/docker-nginx-hhvm-bedrock 24 | ``` 25 | 26 | ### ... via [`docker-compose`](https://github.com/docker/compose) 27 | 28 | Example `docker-compose.yml` for `bedrock`: 29 | 30 | ```yaml 31 | wp: 32 | image: adamyeats/docker-nginx-hhvm-bedrock 33 | ports: 34 | - "80:80" 35 | links: 36 | - db:mysql 37 | - memcached:memcached # Optional 38 | volumes: 39 | - .:/var/www/html 40 | environment: 41 | DB_NAME: my_wordpress_project 42 | 43 | db: 44 | image: mariadb 45 | environment: 46 | MYSQL_ROOT_PASSWORD: root 47 | 48 | memcached: # Optional, recommeded for W3 Cache users 49 | image: memcached 50 | ``` 51 | 52 | Run `docker-compose up`, wait for it to initialize completely, and visit `http://host-ip`. Don't worry about any `Can't connect to MySQL server on 'mysql` messages in `STDOUT` if you're using Compose; sometimes the web process initializes before the DB process, and the script that creates your database if it doesn't exist complains that it can't find your DB. That'll fix itself in a few seconds. 53 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ubuntu:xenial 2 | 3 | # Originally based on https://github.com/philipz/docker-nginx-hhvm-wordpress 4 | MAINTAINER Adam Yeats 5 | 6 | # Get latest version of software-properties-common first 7 | RUN apt-get update && apt-get -y upgrade && apt-get -y install software-properties-common build-essential 8 | 9 | # Pre-add NGINX repo 10 | RUN echo "deb http://ppa.launchpad.net/nginx/stable/ubuntu xenial main" > /etc/apt/sources.list.d/nginx-$nginx-xenial.list 11 | RUN apt-key adv --keyserver keyserver.ubuntu.com --recv-keys C300EE8C 12 | 13 | # Pre-add NGINX repo 14 | RUN apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 0x5a16e7281be7a449 15 | RUN add-apt-repository "deb http://dl.hhvm.com/ubuntu $(lsb_release -sc) main" 16 | 17 | # Pre-add PHP repo 18 | RUN LC_ALL=C.UTF-8 add-apt-repository -y ppa:ondrej/php && apt-get -y update 19 | 20 | # If it's not going to change often do it first to allow Docker build to 21 | # use as much caching as possible to minimize build times 22 | RUN apt-get update && apt-get -y upgrade 23 | 24 | # Basic Requirements 25 | RUN apt-get -y install nginx git curl unzip wget python-pip 26 | 27 | # PHP 28 | RUN apt-get -y install php7.1 php7.1-cli php7.1-common php7.1-curl php7.1-dev php7.1-fpm php7.1-gd php7.1-mbstring php7.1-mcrypt php7.1-mysql php7.1-opcache php7.1-xml php7.1-xmlrpc php7.1-zip php-redis 29 | 30 | # WordPress Requirements 31 | RUN apt-get -y install libnuma-dev 32 | 33 | WORKDIR / 34 | 35 | # Install Composer 36 | RUN curl -sS https://getcomposer.org/installer | php 37 | RUN chmod +x composer.phar 38 | RUN mv composer.phar /usr/local/bin/composer 39 | 40 | # Install WP-CLI 41 | RUN curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar 42 | RUN chmod +x wp-cli.phar 43 | RUN mv wp-cli.phar /usr/local/bin/wp 44 | 45 | # Some misc cleanup 46 | WORKDIR / 47 | RUN apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* 48 | RUN rm /etc/nginx/sites-enabled/default 49 | 50 | # Map local files 51 | COPY nginx/bedrock /etc/nginx/sites-enabled/bedrock 52 | COPY php/www.conf /etc/php/7.1/fpm/pool.d/www.conf 53 | 54 | # install ngxtop, useful for debugging 55 | RUN pip install ngxtop 56 | 57 | # forward request and error logs to docker log collector 58 | RUN ln -sf /dev/stdout /var/log/nginx/access.log && ln -sf /dev/stderr /var/log/nginx/error.log 59 | RUN sed -i "/# server_name_in_redirect off;/ a\fastcgi_cache_path /var/run/nginx levels=1:2 keys_zone=drm_custom_cache:16m max_size=1024m inactive=60m;" /etc/nginx/nginx.conf 60 | 61 | COPY docker-entrypoint.sh /entrypoint.sh 62 | COPY makedb.php /makedb.php 63 | 64 | ENTRYPOINT ["/entrypoint.sh"] 65 | CMD ["nginx", "-g", "daemon off;"] 66 | -------------------------------------------------------------------------------- /docker-entrypoint.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -e 4 | 5 | if [ -n "$MYSQL_PORT_3306_TCP" ]; then 6 | if [ -z "$DB_HOST" ]; then 7 | DB_HOST='mysql' 8 | else 9 | echo >&2 "warning: both DB_HOST and MYSQL_PORT_3306_TCP found" 10 | echo >&2 " Connecting to DB_HOST ($DB_HOST)" 11 | echo >&2 " instead of the linked mysql container" 12 | fi 13 | fi 14 | 15 | if [ -z "$DB_HOST" ]; then 16 | echo >&2 "error: missing DB_HOST and MYSQL_PORT_3306_TCP environment variables" 17 | echo >&2 " Did you forget to --link some_mysql_container:mysql or set an external db" 18 | echo >&2 " with -e DB_HOST=hostname:port?" 19 | exit 1 20 | fi 21 | 22 | # If the DB user is 'root' then use the MySQL root password env var 23 | : ${DB_USER:=root} 24 | if [ "$DB_USER" = 'root' ]; then 25 | : ${DB_PASSWORD:=$MYSQL_ENV_MYSQL_ROOT_PASSWORD} 26 | fi 27 | : ${DB_NAME:=wordpress} 28 | 29 | if [ -z "$DB_PASSWORD" ]; then 30 | echo >&2 "error: missing required DB_PASSWORD environment variable" 31 | echo >&2 " Did you forget to -e DB_PASSWORD=... ?" 32 | echo >&2 33 | echo >&2 " (Also of interest might be DB_USER and DB_NAME.)" 34 | exit 1 35 | fi 36 | 37 | cd /var/www/html 38 | 39 | if ! [ -e web/index.php -a -e config/application.php ]; then 40 | echo >&2 "Bedrock wasn't found in $(pwd) - copying now..." 41 | 42 | if [ "$(ls -A)" ]; then 43 | echo >&2 "WARNING: $(pwd) is not empty - press Ctrl+C now if this is an error!" 44 | ( set -x; ls -A; sleep 10 ) 45 | 46 | rm /var/www/html/index.nginx-debian.html 47 | fi 48 | 49 | git clone https://github.com/roots/bedrock.git . 50 | 51 | echo >&2 "Now bulding Bedrock. Sit tight. This may take a while..." 52 | composer config --global secure-http false # i get really sad having to turn off security measures, but this wouldn't work without this :( 53 | composer up --no-dev --quiet --prefer-dist --no-interaction --optimize-autoloader 54 | 55 | chown -R www-data:www-data /var/www/html 56 | cp .env.example .env 57 | 58 | sed -i "s/database_name/$DB_NAME/g" .env 59 | sed -i "s/database_user/$DB_USER/g" .env 60 | sed -i "s/database_password/$DB_PASSWORD/g" .env 61 | sed -i "s/database_host/$DB_HOST/g" .env 62 | sed -i "s/example.com/$WP_HOME/g" .env 63 | 64 | echo >&2 "Complete! Bedrock has been successfully copied to $(pwd)" 65 | fi 66 | 67 | # Ensure the MySQL Database is created 68 | php /makedb.php "$DB_HOST" "$DB_USER" "$DB_PASSWORD" "$DB_NAME" 69 | 70 | # bring up our PHP binaries 71 | /etc/init.d/php7.1-fpm start 72 | /etc/init.d/hhvm start 73 | 74 | echo >&2 "========================================================================" 75 | echo >&2 76 | echo >&2 "Alright! This server is now configured to run Bedrock!" 77 | echo >&2 "You may need the following database information to install Bedrock later, so keep it safe:" 78 | echo >&2 "Host Name: $DB_HOST" 79 | echo >&2 "Database Name: $DB_NAME" 80 | echo >&2 "Database Username: $DB_USER" 81 | echo >&2 "Database Password: $DB_PASSWORD" 82 | echo >&2 83 | echo >&2 "========================================================================" 84 | 85 | exec "$@" 86 | -------------------------------------------------------------------------------- /nginx/bedrock: -------------------------------------------------------------------------------- 1 | server { 2 | server_name _; 3 | return 302 $scheme://example.com$request_uri; 4 | } 5 | 6 | server { 7 | listen 80 default_server; 8 | listen [::]:80 default_server; 9 | 10 | root /var/www/html/web; 11 | rewrite_log off; 12 | index index.php; 13 | 14 | server_name _; 15 | 16 | # The following three lines should be uncommented in a live env 17 | # (and the subsequent sendfile off directive should be commented). 18 | # This is to negate a weird bug in Virtualbox. 19 | # sendfile on; 20 | tcp_nopush on; 21 | tcp_nodelay on; 22 | sendfile off; 23 | keepalive_timeout 10s; 24 | types_hash_max_size 2048; 25 | include /etc/nginx/mime.types; 26 | default_type application/octet-stream; 27 | 28 | client_max_body_size 100M; 29 | 30 | gzip on; 31 | gzip_vary on; 32 | gzip_proxied any; 33 | gzip_comp_level 9; 34 | gzip_buffers 16 8k; 35 | gzip_http_version 1.1; 36 | gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript image/svg+xml; 37 | 38 | location / { 39 | try_files $uri $uri/ /index.php?$args; 40 | } 41 | 42 | # Add trailing slash to */wp-admin requests. 43 | rewrite /wp-admin$ $scheme://$host$uri/ permanent; 44 | 45 | # PHP-FPM 7.1 46 | location ~ \.(hh|php)$ { 47 | proxy_intercept_errors on; 48 | 49 | try_files $uri /index.php; 50 | 51 | # if our request is routed via hhvm, then use the fastcgi cache 52 | fastcgi_pass_header Set-Cookie; 53 | fastcgi_pass_header Cookie; 54 | fastcgi_ignore_headers Cache-Control Expires Set-Cookie; 55 | fastcgi_index index.php; 56 | fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; 57 | fastcgi_split_path_info ^(.+.php)(/.+)$; 58 | fastcgi_param PATH_INFO $fastcgi_path_info; 59 | fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info; 60 | fastcgi_intercept_errors on; 61 | include fastcgi_params; 62 | fastcgi_no_cache $no_cache; 63 | fastcgi_cache_bypass $no_cache; 64 | fastcgi_cache drm_custom_cache; 65 | fastcgi_cache_key $server_name|$request_uri; 66 | fastcgi_cache_valid 404 60m; 67 | fastcgi_cache_valid 200 60m; 68 | fastcgi_max_temp_file_size 4m; 69 | fastcgi_cache_use_stale updating; 70 | 71 | fastcgi_split_path_info ^(.+\.php)(/.+)$; 72 | include fastcgi_params; 73 | fastcgi_pass unix:/var/run/php/php7.1-fpm.sock; 74 | } 75 | 76 | # Directives to send expires headers and turn off 404 error logging. 77 | location ~* ^.+\.(ogg|ogv|svg|svgz|eot|otf|woff|mp4|ttf|rss|atom|jpg|jpeg|gif|png|ico|zip|tgz|gz|rar|bz2|doc|xls|exe|ppt|tar|mid|midi|wav|bmp|rtf)$ { 78 | access_log off; 79 | log_not_found off; 80 | add_header Pragma public; 81 | add_header Cache-Control "public"; 82 | expires 14d; 83 | } 84 | 85 | # Deny all attempts to access hidden files such as .htaccess, .htpasswd, .DS_Store (Mac). 86 | # Keep logging the requests to parse later (or to pass to firewall utilities such as fail2ban) 87 | location ~ /\. { 88 | deny all; 89 | } 90 | 91 | # Deny access to any files with a .php extension in the uploads directory 92 | # Works in sub-directory installs and also in multisite network 93 | # Keep logging the requests to parse later (or to pass to firewall utilities such as fail2ban) 94 | location ~* /(?:uploads|files)/.*\.php$ { 95 | deny all; 96 | } 97 | 98 | # define what we shouldn't normally cache 99 | set $no_cache ""; 100 | 101 | if ($request_method = POST) 102 | { 103 | set $no_cache 1; 104 | } 105 | 106 | if ($request_uri ~* "/(wp-admin/|wp-login.php)") 107 | { 108 | set $no_cache 1; 109 | } 110 | 111 | if ($http_cookie ~* "wordpress_logged_in_") 112 | { 113 | set $no_cache 1; 114 | } 115 | 116 | location = /favicon.ico { 117 | log_not_found off; 118 | access_log off; 119 | } 120 | 121 | location = /robots.txt { 122 | allow all; 123 | log_not_found off; 124 | access_log off; 125 | } 126 | 127 | # avoid a bit of information disclosure 128 | server_tokens off; 129 | server_name_in_redirect off; 130 | } 131 | -------------------------------------------------------------------------------- /php/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 /usr) 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 = /run/php/php7.1-fpm.sock 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 | ; Choose how the process manager will control the number of child processes. 73 | ; Possible Values: 74 | ; static - a fixed number (pm.max_children) of child processes; 75 | ; dynamic - the number of child processes are set dynamically based on the 76 | ; following directives. With this process management, there will be 77 | ; always at least 1 children. 78 | ; pm.max_children - the maximum number of children that can 79 | ; be alive at the same time. 80 | ; pm.start_servers - the number of children created on startup. 81 | ; pm.min_spare_servers - the minimum number of children in 'idle' 82 | ; state (waiting to process). If the number 83 | ; of 'idle' processes is less than this 84 | ; number then some children will be created. 85 | ; pm.max_spare_servers - the maximum number of children in 'idle' 86 | ; state (waiting to process). If the number 87 | ; of 'idle' processes is greater than this 88 | ; number then some children will be killed. 89 | ; ondemand - no children are created at startup. Children will be forked when 90 | ; new requests will connect. The following parameter are used: 91 | ; pm.max_children - the maximum number of children that 92 | ; can be alive at the same time. 93 | ; pm.process_idle_timeout - The number of seconds after which 94 | ; an idle process will be killed. 95 | ; Note: This value is mandatory. 96 | pm = dynamic 97 | 98 | ; The number of child processes to be created when pm is set to 'static' and the 99 | ; maximum number of child processes when pm is set to 'dynamic' or 'ondemand'. 100 | ; This value sets the limit on the number of simultaneous requests that will be 101 | ; served. Equivalent to the ApacheMaxClients directive with mpm_prefork. 102 | ; Equivalent to the PHP_FCGI_CHILDREN environment variable in the original PHP 103 | ; CGI. The below defaults are based on a server without much resources. Don't 104 | ; forget to tweak pm.* to fit your needs. 105 | ; Note: Used when pm is set to 'static', 'dynamic' or 'ondemand' 106 | ; Note: This value is mandatory. 107 | pm.max_children = 5 108 | 109 | ; The number of child processes created on startup. 110 | ; Note: Used only when pm is set to 'dynamic' 111 | ; Default Value: min_spare_servers + (max_spare_servers - min_spare_servers) / 2 112 | pm.start_servers = 2 113 | 114 | ; The desired minimum number of idle server processes. 115 | ; Note: Used only when pm is set to 'dynamic' 116 | ; Note: Mandatory when pm is set to 'dynamic' 117 | pm.min_spare_servers = 1 118 | 119 | ; The desired maximum number of idle server processes. 120 | ; Note: Used only when pm is set to 'dynamic' 121 | ; Note: Mandatory when pm is set to 'dynamic' 122 | pm.max_spare_servers = 3 123 | 124 | ; The number of seconds after which an idle process will be killed. 125 | ; Note: Used only when pm is set to 'ondemand' 126 | ; Default Value: 10s 127 | ;pm.process_idle_timeout = 10s; 128 | 129 | ; The number of requests each child process should execute before respawning. 130 | ; This can be useful to work around memory leaks in 3rd party libraries. For 131 | ; endless request processing specify '0'. Equivalent to PHP_FCGI_MAX_REQUESTS. 132 | ; Default Value: 0 133 | ;pm.max_requests = 500 134 | 135 | ; The URI to view the FPM status page. If this value is not set, no URI will be 136 | ; recognized as a status page. It shows the following informations: 137 | ; pool - the name of the pool; 138 | ; process manager - static, dynamic or ondemand; 139 | ; start time - the date and time FPM has started; 140 | ; start since - number of seconds since FPM has started; 141 | ; accepted conn - the number of request accepted by the pool; 142 | ; listen queue - the number of request in the queue of pending 143 | ; connections (see backlog in listen(2)); 144 | ; max listen queue - the maximum number of requests in the queue 145 | ; of pending connections since FPM has started; 146 | ; listen queue len - the size of the socket queue of pending connections; 147 | ; idle processes - the number of idle processes; 148 | ; active processes - the number of active processes; 149 | ; total processes - the number of idle + active processes; 150 | ; max active processes - the maximum number of active processes since FPM 151 | ; has started; 152 | ; max children reached - number of times, the process limit has been reached, 153 | ; when pm tries to start more children (works only for 154 | ; pm 'dynamic' and 'ondemand'); 155 | ; Value are updated in real time. 156 | ; Example output: 157 | ; pool: www 158 | ; process manager: static 159 | ; start time: 01/Jul/2011:17:53:49 +0200 160 | ; start since: 62636 161 | ; accepted conn: 190460 162 | ; listen queue: 0 163 | ; max listen queue: 1 164 | ; listen queue len: 42 165 | ; idle processes: 4 166 | ; active processes: 11 167 | ; total processes: 15 168 | ; max active processes: 12 169 | ; max children reached: 0 170 | ; 171 | ; By default the status page output is formatted as text/plain. Passing either 172 | ; 'html', 'xml' or 'json' in the query string will return the corresponding 173 | ; output syntax. Example: 174 | ; http://www.foo.bar/status 175 | ; http://www.foo.bar/status?json 176 | ; http://www.foo.bar/status?html 177 | ; http://www.foo.bar/status?xml 178 | ; 179 | ; By default the status page only outputs short status. Passing 'full' in the 180 | ; query string will also return status for each pool process. 181 | ; Example: 182 | ; http://www.foo.bar/status?full 183 | ; http://www.foo.bar/status?json&full 184 | ; http://www.foo.bar/status?html&full 185 | ; http://www.foo.bar/status?xml&full 186 | ; The Full status returns for each process: 187 | ; pid - the PID of the process; 188 | ; state - the state of the process (Idle, Running, ...); 189 | ; start time - the date and time the process has started; 190 | ; start since - the number of seconds since the process has started; 191 | ; requests - the number of requests the process has served; 192 | ; request duration - the duration in µs of the requests; 193 | ; request method - the request method (GET, POST, ...); 194 | ; request URI - the request URI with the query string; 195 | ; content length - the content length of the request (only with POST); 196 | ; user - the user (PHP_AUTH_USER) (or '-' if not set); 197 | ; script - the main script called (or '-' if not set); 198 | ; last request cpu - the %cpu the last request consumed 199 | ; it's always 0 if the process is not in Idle state 200 | ; because CPU calculation is done when the request 201 | ; processing has terminated; 202 | ; last request memory - the max amount of memory the last request consumed 203 | ; it's always 0 if the process is not in Idle state 204 | ; because memory calculation is done when the request 205 | ; processing has terminated; 206 | ; If the process is in Idle state, then informations are related to the 207 | ; last request the process has served. Otherwise informations are related to 208 | ; the current request being served. 209 | ; Example output: 210 | ; ************************ 211 | ; pid: 31330 212 | ; state: Running 213 | ; start time: 01/Jul/2011:17:53:49 +0200 214 | ; start since: 63087 215 | ; requests: 12808 216 | ; request duration: 1250261 217 | ; request method: GET 218 | ; request URI: /test_mem.php?N=10000 219 | ; content length: 0 220 | ; user: - 221 | ; script: /home/fat/web/docs/php/test_mem.php 222 | ; last request cpu: 0.00 223 | ; last request memory: 0 224 | ; 225 | ; Note: There is a real-time FPM status monitoring sample web page available 226 | ; It's available in: /usr/share/php/7.1/fpm/status.html 227 | ; 228 | ; Note: The value must start with a leading slash (/). The value can be 229 | ; anything, but it may not be a good idea to use the .php extension or it 230 | ; may conflict with a real PHP file. 231 | ; Default Value: not set 232 | ;pm.status_path = /status 233 | 234 | ; The ping URI to call the monitoring page of FPM. If this value is not set, no 235 | ; URI will be recognized as a ping page. This could be used to test from outside 236 | ; that FPM is alive and responding, or to 237 | ; - create a graph of FPM availability (rrd or such); 238 | ; - remove a server from a group if it is not responding (load balancing); 239 | ; - trigger alerts for the operating team (24/7). 240 | ; Note: The value must start with a leading slash (/). The value can be 241 | ; anything, but it may not be a good idea to use the .php extension or it 242 | ; may conflict with a real PHP file. 243 | ; Default Value: not set 244 | ;ping.path = /ping 245 | 246 | ; This directive may be used to customize the response of a ping request. The 247 | ; response is formatted as text/plain with a 200 response code. 248 | ; Default Value: pong 249 | ;ping.response = pong 250 | 251 | ; The access log file 252 | ; Default: not set 253 | ;access.log = log/$pool.access.log 254 | 255 | ; The access log format. 256 | ; The following syntax is allowed 257 | ; %%: the '%' character 258 | ; %C: %CPU used by the request 259 | ; it can accept the following format: 260 | ; - %{user}C for user CPU only 261 | ; - %{system}C for system CPU only 262 | ; - %{total}C for user + system CPU (default) 263 | ; %d: time taken to serve the request 264 | ; it can accept the following format: 265 | ; - %{seconds}d (default) 266 | ; - %{miliseconds}d 267 | ; - %{mili}d 268 | ; - %{microseconds}d 269 | ; - %{micro}d 270 | ; %e: an environment variable (same as $_ENV or $_SERVER) 271 | ; it must be associated with embraces to specify the name of the env 272 | ; variable. Some exemples: 273 | ; - server specifics like: %{REQUEST_METHOD}e or %{SERVER_PROTOCOL}e 274 | ; - HTTP headers like: %{HTTP_HOST}e or %{HTTP_USER_AGENT}e 275 | ; %f: script filename 276 | ; %l: content-length of the request (for POST request only) 277 | ; %m: request method 278 | ; %M: peak of memory allocated by PHP 279 | ; it can accept the following format: 280 | ; - %{bytes}M (default) 281 | ; - %{kilobytes}M 282 | ; - %{kilo}M 283 | ; - %{megabytes}M 284 | ; - %{mega}M 285 | ; %n: pool name 286 | ; %o: output header 287 | ; it must be associated with embraces to specify the name of the header: 288 | ; - %{Content-Type}o 289 | ; - %{X-Powered-By}o 290 | ; - %{Transfert-Encoding}o 291 | ; - .... 292 | ; %p: PID of the child that serviced the request 293 | ; %P: PID of the parent of the child that serviced the request 294 | ; %q: the query string 295 | ; %Q: the '?' character if query string exists 296 | ; %r: the request URI (without the query string, see %q and %Q) 297 | ; %R: remote IP address 298 | ; %s: status (response code) 299 | ; %t: server time the request was received 300 | ; it can accept a strftime(3) format: 301 | ; %d/%b/%Y:%H:%M:%S %z (default) 302 | ; The strftime(3) format must be encapsuled in a %{}t tag 303 | ; e.g. for a ISO8601 formatted timestring, use: %{%Y-%m-%dT%H:%M:%S%z}t 304 | ; %T: time the log has been written (the request has finished) 305 | ; it can accept a strftime(3) format: 306 | ; %d/%b/%Y:%H:%M:%S %z (default) 307 | ; The strftime(3) format must be encapsuled in a %{}t tag 308 | ; e.g. for a ISO8601 formatted timestring, use: %{%Y-%m-%dT%H:%M:%S%z}t 309 | ; %u: remote user 310 | ; 311 | ; Default: "%R - %u %t \"%m %r\" %s" 312 | ;access.format = "%R - %u %t \"%m %r%Q%q\" %s %f %{mili}d %{kilo}M %C%%" 313 | 314 | ; The log file for slow requests 315 | ; Default Value: not set 316 | ; Note: slowlog is mandatory if request_slowlog_timeout is set 317 | ;slowlog = log/$pool.log.slow 318 | 319 | ; The timeout for serving a single request after which a PHP backtrace will be 320 | ; dumped to the 'slowlog' file. A value of '0s' means 'off'. 321 | ; Available units: s(econds)(default), m(inutes), h(ours), or d(ays) 322 | ; Default Value: 0 323 | ;request_slowlog_timeout = 0 324 | 325 | ; The timeout for serving a single request after which the worker process will 326 | ; be killed. This option should be used when the 'max_execution_time' ini option 327 | ; does not stop script execution for some reason. A value of '0' means 'off'. 328 | ; Available units: s(econds)(default), m(inutes), h(ours), or d(ays) 329 | ; Default Value: 0 330 | ;request_terminate_timeout = 0 331 | 332 | ; Set open file descriptor rlimit. 333 | ; Default Value: system defined value 334 | ;rlimit_files = 1024 335 | 336 | ; Set max core size rlimit. 337 | ; Possible Values: 'unlimited' or an integer greater or equal to 0 338 | ; Default Value: system defined value 339 | ;rlimit_core = 0 340 | 341 | ; Chroot to this directory at the start. This value must be defined as an 342 | ; absolute path. When this value is not set, chroot is not used. 343 | ; Note: you can prefix with '$prefix' to chroot to the pool prefix or one 344 | ; of its subdirectories. If the pool prefix is not set, the global prefix 345 | ; will be used instead. 346 | ; Note: chrooting is a great security feature and should be used whenever 347 | ; possible. However, all PHP paths will be relative to the chroot 348 | ; (error_log, sessions.save_path, ...). 349 | ; Default Value: not set 350 | ;chroot = 351 | 352 | ; Chdir to this directory at the start. 353 | ; Note: relative path can be used. 354 | ; Default Value: current directory or / when chroot 355 | ;chdir = /var/www 356 | 357 | ; Redirect worker stdout and stderr into main error log. If not set, stdout and 358 | ; stderr will be redirected to /dev/null according to FastCGI specs. 359 | ; Note: on highloaded environement, this can cause some delay in the page 360 | ; process time (several ms). 361 | ; Default Value: no 362 | ;catch_workers_output = yes 363 | 364 | ; Clear environment in FPM workers 365 | ; Prevents arbitrary environment variables from reaching FPM worker processes 366 | ; by clearing the environment in workers before env vars specified in this 367 | ; pool configuration are added. 368 | ; Setting to "no" will make all environment variables available to PHP code 369 | ; via getenv(), $_ENV and $_SERVER. 370 | ; Default Value: yes 371 | clear_env = no 372 | 373 | ; Limits the extensions of the main script FPM will allow to parse. This can 374 | ; prevent configuration mistakes on the web server side. You should only limit 375 | ; FPM to .php extensions to prevent malicious users to use other extensions to 376 | ; execute php code. 377 | ; Note: set an empty value to allow all extensions. 378 | ; Default Value: .php 379 | ;security.limit_extensions = .php .php3 .php4 .php5 .php7 380 | 381 | ; Pass environment variables like LD_LIBRARY_PATH. All $VARIABLEs are taken from 382 | ; the current environment. 383 | ; Default Value: clean env 384 | ;env[HOSTNAME] = $HOSTNAME 385 | ;env[PATH] = /usr/local/bin:/usr/bin:/bin 386 | ;env[TMP] = /tmp 387 | ;env[TMPDIR] = /tmp 388 | ;env[TEMP] = /tmp 389 | 390 | ; Additional php.ini defines, specific to this pool of workers. These settings 391 | ; overwrite the values previously defined in the php.ini. The directives are the 392 | ; same as the PHP SAPI: 393 | ; php_value/php_flag - you can set classic ini defines which can 394 | ; be overwritten from PHP call 'ini_set'. 395 | ; php_admin_value/php_admin_flag - these directives won't be overwritten by 396 | ; PHP call 'ini_set' 397 | ; For php_*flag, valid values are on, off, 1, 0, true, false, yes or no. 398 | 399 | ; Defining 'extension' will load the corresponding shared extension from 400 | ; extension_dir. Defining 'disable_functions' or 'disable_classes' will not 401 | ; overwrite previously defined php.ini values, but will append the new value 402 | ; instead. 403 | 404 | ; Note: path INI options can be relative and will be expanded with the prefix 405 | ; (pool, global or /usr) 406 | 407 | ; Default Value: nothing is defined by default except the values in php.ini and 408 | ; specified at startup with the -d argument 409 | ;php_admin_value[sendmail_path] = /usr/sbin/sendmail -t -i -f www@my.domain.com 410 | ;php_flag[display_errors] = off 411 | ;php_admin_value[error_log] = /var/log/fpm-php.www.log 412 | ;php_admin_flag[log_errors] = on 413 | ;php_admin_value[memory_limit] = 32M 414 | --------------------------------------------------------------------------------