FastCGI is a way of having server scripts execute time-consuming code just once instead of every time the script is loaded, reducing overhead.
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.
5.6 (available for compatibility, no longer officially supported)
7.0 (available for compatibility, no longer officially supported)
7.2 (available for compatibility, no longer officially supported)
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:
max_execution_time = 900
Changeable via PHP_MAX_EXECUTION_TIME.
realpath_cache_size = 256k
For handling big PHP projects.
memory_limit = 400M
For big PHP projects (changeable via PHP_MEMORY_LIMIT).
opcache.memory_consumption = 265
For big PHP projects.
opcache.enable_file_override = 1 and opcache.huge_code_pages = 1
For faster PHP.
display_errors = Off and display_startup_errors = Off
For sensible production values (changeable via PHP_DISPLAY_ERRORS and PHP_DISPLAY_STARTUP_ERRORS).
upload_max_filesize = 2048M
For big file uploads.
apc.shm_size = 32m and apc.enabled = 1
Changeable via PHP_APC_SHM_SIZE and PHP_APC_ENABLED.
Also, php-fpm error logging happens in stderr.
💡 If you don't like any of these configs, you have three possibilities:
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 PHP_INI_SYSTEM changeable mode 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 (php-fpm.d/www.conf) that creates an fpm-pool and listens on port 9000. 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).
catch_workers_output = yes to see PHP errors.
clear_env = no to be able to inject PHP environment variables via regular Docker environment variables.
Environment variables are meant to contain common information for the PHP container.
Enable NewRelic performance monitoring, needs NEWRELIC_LICENSE be configured.
NewRelic license to be used, Important: NEWRELIC_ENABLED needs to be set totrue in order for NewRelic to be enabled.