上QQ阅读APP看书,第一时间看更新
Configuring php-fpm
In order to configure php-fpm, follow these steps:
- Inside the php-fpm folder, create a file called Dockerfile and add the following lines:
FROM phpdockerio/php72-fpm:latest
WORKDIR "/application"
# Install selected extensions and other stuff
RUN apt-get update \
&& apt-get -y --no-install-recommends install php7.2-mysql
libmcrypt-dev \
&& apt-get clean; rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
/usr/share/doc/*
Now, it is time to create our override php.ini file, which is the PHP.ini where we can manually override PHP settings that run on the server.
In the case of Apache servers, it only runs once when the server is started, in our case, as we use nginx with php-fpm. In regards to this, we are using a fastCgi environment, and this file is read with every server invocation.
Some advantages to using fastCgi environment rather than the traditional Apache evironment are as follows:
- Adaptive process growth
- Basic statistics (similar to Apache mod_status)
- Advanced process management with graceful start/stop
- The ability to start workers with different uid, gid, chroot, environment, and php.ini (replaces safe_mode)
- It creates logs for stdout and stderr
- Emergency restart in case of accidental code destruction (cache)
- Supports accelerated upload
- Several improvements to your facet FastCGI
Other ways to use PHP on servers are as follows:
- Apache module (mod_php)
- CGI
- FastCGI
- PHP – FastCGI Process Manager (FPM )
- Command lines (CLI)
- Inside the php-fpm folder, create a new file called php-ini-overrides.ini and add the following code:
upload_max_filesize = 300M
post_max_size = 308M
[Xdebug]
zend_extension=/usr/local/lib/php/extensions/no-debug-non-zts-20151012/xdebug.so
xdebug.remote_enable=1
xdebug.remote_autostart=1
xdebug.remote_host=111.111.11.1 # you must use your own IP address here
xdebug.remote_port=9009
Note that we are only setting up Xdebug here, which is a PHP extension to debug PHP applications.