.bp-config/
`php
` and `httpd
`.httpd
`, create a folder called `extra
`.php
`, create a directory called `fpm.d
`..bp-config/httpd/extr
`, create a file named `httpd-php.conf
`. It needs to have that exact name. In this file add the following:
DirectoryIndex index.php index.html index.htm Define fcgi-listener fcgi://#{PHP_FPM_LISTEN}${HOME}/#{WEBDIR} <Proxy "${fcgi-listener}"> # Noop ProxySet directive, disablereuse=On is the default value. # If we don't have a ProxySet, this <Proxy> isn't handled # correctly and everything breaks. # NOTE: Setting retry to avoid cached HTTP 503 (See https://www.pivotaltracker.com/story/show/103840940) ProxySet disablereuse=On retry=0 </Proxy> <Directory "${HOME}/#{WEBDIR}"> <Files *.php> <If "-f %{REQUEST_FILENAME}"> # make sure the file exists so that if not, Apache will show its 404 page and not FPM SetHandler proxy:fcgi://#{PHP_FPM_LISTEN} </If> </Files> </Directory> ProxyPass "/status" "fcgi://#{PHP_FPM_LISTEN}/status" ProxyPassReverse "/status" "fcgi://#{PHP_FPM_LISTEN}/status" <Proxy "fcgi://#{PHP_FPM_LISTEN}/status"> Require ip <your-ip> </Proxy>
This adds the default configuration (lines 1-21), and our custom config (lines 22-27). You need the default configuration because the file above will completely override the default file used by the buildpack. You want to enable the default configuration plus our additional configuration.
The additional configuration is used to proxy requests for `/status
` to PHP-FPM. The first argument to ProxyPass
and ProxyPassReverse
is the path you will access to view the status info. You can change this path to something else if you'd like to obscure the path and try to make it something harder to guess. The second argument to ProxyPass
and ProxyPassReverse
is the proxy path. Use the value above unless you know exactly what you are doing.
For reference, `#{PHP_FPM_LISTEN}
` is replaced by the buildpack with the information needed to locate PHP-FPM. The `/status
` path on the end of the URL is the path that you'll configure in PHP-FPM in the next step. There's not much reason to change this, but you could as long as it matches what's configured in the next section.
To add some security, we also add the `<Proxy>
` block. This will restrict who has access based on IP, but you could replace it with other restrictions, such as basic authentication. This sample configuration restricts by a single IP address. If you insert your IP address into the config, then only this IP will be allowed to access the`/status
` page. Accessing from any other IP will result in a 403 Forbidden response. The `require ip
` config supports multiple IPs (space separated list), partial IPs, and subnets if you'd like to have a more complicated list of allowed IPs. See the documentation here for more details.
.bp-config/php/fpm.d
` directory, create a file called `status.conf
` .conf
`. ; These are specific to the `www` pool [www] ; The URI to view the FPM status page. If this value is not set, no URI will be ; recognized as a status page. It shows the following informations: ; pool - the name of the pool; ; process manager - static, dynamic or ondemand; ; start time - the date and time FPM has started; ; start since - number of seconds since FPM has started; ; accepted conn - the number of request accepted by the pool; ; listen queue - the number of request in the queue of pending ; connections (see backlog in listen(2)); ; max listen queue - the maximum number of requests in the queue ; of pending connections since FPM has started; ; listen queue len - the size of the socket queue of pending connections; ; idle processes - the number of idle processes; ; active processes - the number of active processes; ; total processes - the number of idle + active processes; ; max active processes - the maximum number of active processes since FPM ; has started; ; max children reached - number of times, the process limit has been reached, ; when pm tries to start more children (works only for ; pm 'dynamic' and 'ondemand'); ; Value are updated in real time. ; Example output: ; pool: www ; process manager: static ; start time: 01/Jul/2011:17:53:49 +0200 ; start since: 62636 ; accepted conn: 190460 ; listen queue: 0 ; max listen queue: 1 ; listen queue len: 42 ; idle processes: 4 ; active processes: 11 ; total processes: 15 ; max active processes: 12 ; max children reached: 0 ; ; By default the status page output is formatted as text/plain. Passing either ; 'html', 'xml' or 'json' in the query string will return the corresponding ; output syntax. Example: ; http://www.foo.bar/status ; http://www.foo.bar/status?json ; http://www.foo.bar/status?html ; http://www.foo.bar/status?xml ; ; By default the status page only outputs short status. Passing 'full' in the ; query string will also return status for each pool process. ; Example: ; http://www.foo.bar/status?full ; http://www.foo.bar/status?json&full ; http://www.foo.bar/status?html&full ; http://www.foo.bar/status?xml&full ; The Full status returns for each process: ; pid - the PID of the process; ; state - the state of the process (Idle, Running, ...); ; start time - the date and time the process has started; ; start since - the number of seconds since the process has started; ; requests - the number of requests the process has served; ; request duration - the duration in µs of the requests; ; request method - the request method (GET, POST, ...); ; request URI - the request URI with the query string; ; content length - the content length of the request (only with POST); ; user - the user (PHP_AUTH_USER) (or '-' if not set); ; script - the main script called (or '-' if not set); ; last request cpu - the %cpu the last request consumed ; it's always 0 if the process is not in Idle state ; because CPU calculation is done when the request ; processing has terminated; ; last request memory - the max amount of memory the last request consumed ; it's always 0 if the process is not in Idle state ; because memory calculation is done when the request ; processing has terminated; ; If the process is in Idle state, then informations are related to the ; last request the process has served. Otherwise informations are related to ; the current request being served. ; Example output: ; ************************ ; pid: 31330 ; state: Running ; start time: 01/Jul/2011:17:53:49 +0200 ; start since: 63087 ; requests: 12808 ; request duration: 1250261 ; request method: GET ; request URI: /test_mem.php?N=10000 ; content length: 0 ; user: - ; script: /home/fat/web/docs/php/test_mem.php ; last request cpu: 0.00 ; last request memory: 0 ; ; Note: There is a real-time FPM status monitoring sample web page available ; It's available in: ${prefix}/share/fpm/status.html ; ; Note: The value must start with a leading slash (/). The value can be ; anything, but it may not be a good idea to use the .php extension or it ; may conflict with a real PHP file. ; Default Value: not set pm.status_path = /statusNote: Most of this config is comments (anything starting with `;` ) which are included as a reference. However, feel free to strip those out of your actual configuration.
[www]
` which dictates the pool name and `pm.status_path = /status
`, which tells PHP-FPM the path on which it should listen for status requests. The path here needs to match the path mentioned from the previous section and the path from your Apache Web Server proxy config.
cf push
` your application. When the application starts, you should be able to access the status page by going to https
:
//<your-app>
.
<your-apps-domain>/status
(or whatever path you exposed in the Apache Web Server config). You will see output similar to the following:
pool: www process manager: dynamic start time: 25/Apr/2019:13:02:17 +0000 start since: 2228 accepted conn: 23 listen queue: 0 max listen queue: 0 listen queue len: 128 idle processes: 1 active processes: 1 total processes: 2 max active processes: 1 max children reached: 0 slow requests: 0
<Proxy>`
block of your Apache Web Server configuration. Review that section of configuration and try again.