Project: Lagoon (App Definition and Development / Application Definition & Image Build)
File: php-fpm.md

The . Based on . PHP-FPM \(FastCGI Process Manager\) is an alternative PHP FastCGI implementation with some additional features useful for sites of any size, especially busier sites. from FastCGI is a way of having server scripts execute time-consuming code just once instead of every time the script is loaded, reducing overhead. !!! Info This Dockerfile is intended to be used as a base for any `PHP` needs within Lagoon. This image itself does not create a web server, rather a `php-fpm` fastcgi listener. You may need to adapt the `php-fpm` pool config. 7.3 \(available for compatibility only, no longer officially supported\) - `uselagoon/php-7.3-fpm` 7.4 \(available for compatibility only, no longer officially supported\) - `uselagoon/php-7.4-fpm` 8.0 \(available for compatibility only, no longer officially supported\) - `uselagoon/php-8.0-fpm` 8.1 (Security Support until November 2024) - `uselagoon/php-8.1-fpm` 8.2 (Security Support until December 2025) - `uselagoon/php-8.2-fpm` 8.3 (Security Support until December 2026) - `uselagoon/php-8.3-fpm` All PHP versions use their own Dockerfiles. !!! Tip We stop updating End of Life \(EOL\) PHP images usually with the Lagoon release that comes after the officially communicated EOL date: . Previous published versions will remain available. This image is prepared to be used on Lagoon. There are therefore some things are already done: Folder permissions are automatically adapted with , so this image will work with a random user. The `/usr/local/etc/php/php.ini` and `/usr/local/etc/php-fpm.conf`, plus all files within `/usr/local/etc/php-fpm.d/` , are parsed through with a container-entrypoint. See the for installed `PHP` extensions. To install further extensions, extend your Dockerfile from this image. Install extensions according to the docs, under the heading The included `PHP` config contains sensible values that will make the creation of `PHP` pools config easier. Here is a list of some of these. Check `/usr/local/etc/php.ini`, `/usr/local/etc/php-fpm.conf` for all of them: | Value | Details | | : | : | | `maxexecutiontime = 900` | Changeable via `PHPMAXEXECUTION_TIME`. | | `realpathcachesize = 256k` | For handling big PHP projects. | | `memorylimit = 400M` | For big PHP projects \(changeable via `PHPMEMORY_LIMIT`\). | | `opcache.memory_consumption = 265` | For big PHP projects. | | `opcache.enablefileoverride = 1` and `opcache.hugecodepages = 1` | For faster PHP. | | `displayerrors = Off` and `displaystartuperrors = Off` | For sensible production values \(changeable via `PHPDISPLAYERRORS` and `PHPDISPLAYSTARTUPERRORS`\). | | `uploadmaxfilesize = 2048M` | For big file uploads. | | `apc.shmsize = 32m` and `apc.enabled = 1` | Changeable via `PHPAPCSHMSIZE` and `PHPAPCENABLED`. | Also, `php-fpm` error logging happens in `stderr`. If you don't like any of these configs, you have three possibilities: If they are changeable via environment variables, use environment variables \(this is the preferred method, see \). Create your own `fpm-pool` config and set via `phpadminvalue` and `phpadminflag`. Learn more about them in . This documentation refers to Apache, but it is also the case for `php-fpm`\). Important: If you want to provide your own `php-fpm` pool, overwrite the file `/usr/local/etc/php-fpm.d/www.conf` with your own config, or rename this file if you want it to have another name. If you don't do that, the provided pool will be started! PHP values with the cannot be changed via an `fpm-pool` config. They need to be changed either via already provided environment variables or: Provide your own `php.ini` or `php-fpm.conf` file \(this is the least preferred method\). This image is shipped with an `fpm-pool` config \(\) that creates an `fpm-pool` and listens on port

This is because we try to provide an image which already covers most needs for PHP, so you don't need to create your own. You are welcome to do so if you like, though! Here a short description of what this file does: Listens on port 9000 via IPv4 and IPv6. Uses the pm `dynamic` and creates between 2-50 children. Re-spawns `php-fpm` pool children after 500 requests to prevent memory leaks. Replies with `pong` when making a fastcgi request to `/ping` \(good for automated testing to check if the pool started\). `catchworkersoutput = yes` to see PHP errors. `clear_env = no` to be able to inject PHP environment variables via regular Docker environment variables. Some options are configurable via [environment variables](../concepts-advanced/environment-variables.md). | Environment Variable | Default | Description | | :-- | :-- | :- | | NEWRELICENABLED | false | Enable NewRelic performance monitoring, needs `NEWRELICLICENSE` be configured. | | NEWRELICLICENSE | (not set) | NewRelic license to be used. Important: `NEWRELICENABLED` needs to be set to`true` in order for NewRelic to be enabled. | | NEWRELICBROWSERMONITORINGENABLED | true | This enables auto-insertion of the JavaScript fragments for NewRelic browser monitoring. Important: `NEWRELICENABLED` needs to be set to`true` in order for NewRelic to be enabled. | | NEWRELICDISTRIBUTEDTRACINGENABLED | false | This enables distributed tracing. Important: `NEWRELICENABLED` needs to be set to`true` in order for NewRelic to be enabled. | | PHPAPCENABLED | 1 | Can be set to `0` to disable . | | PHPAPCSHM_SIZE | 32m | The size of each shared memory segment given. | | PHPDISPLAYERRORS | Off | Configures whether errors are printed or hidden. . | | PHPDISPLAYSTARTUP_ERRORS | Off | Configures whether startup errors are printed or hidden. . | | PHPERRORREPORTING | Production `EALL & ~EDEPRECATED & ~ESTRICT` Development: `EALL & ~EDEPRECATED & ~ESTRICT & ~E_NOTICE` | The desired logging level you'd like PHP to use. . | | PHPFPMPMMAXCHILDREN | 50 | The the maximum number of child processes. . | | PHPFPMPMMAXREQUESTS | 500 | The number of requests each child process should execute before re-spawning. . | | PHPFPMPMMAXSPARE_SERVERS | 2 | The desired maximum number of idle server processes. . | | PHPFPMPMMINSPARE_SERVERS | 2 | The desired minimum number of idle server processes. . | | PHPFPMPMPROCESSIDLE_TIMEOUT | 60s | The number of seconds after which an idle process will be killed. . | | PHPFPMPMSTARTSERVERS | 2 | The number of child processes created on startup. . | | PHPMAXEXECUTION_TIME | 900 | Maximum execution time of each script, in seconds. . | | PHPMAXFILE_UPLOADS | 20 | The maximum number of files allowed to be uploaded simultaneously. . | | PHPMAXINPUT_VARS | 2000 | How many input variables will be accepted. . | | PHPMEMORYLIMIT | 400M | Maximum amount of memory a script may consume. . | | XDEBUG_ENABLE | (not set) | Set to `true` to enable `xdebug` extension. | | BLACKFIRE_ENABLED | (not set) | Set to `true` to enable `blackfire` extension. | | BLACKFIRESERVERID | (not set) | Set to Blackfire Server ID provided by Blackfire.io. Needs `BLACKFIRE_ENABLED` set to `true`. | | BLACKFIRESERVERTOKEN | (not set) | Set to Blackfire Server Token provided by Blackfire.io. Needs `BLACKFIRE_ENABLED` set to `true`. | | BLACKFIRELOGLEVEL | 3 | Change the log level of the blackfire agent. Available values: `log verbosity level (4: debug, 3: info, 2: warning, 1: error)` . |