PHP is a popular general-purpose scripting language that is especially suited to web development. Fast, flexible and pragmatic, PHP powers everything from your blog to the most popular websites in the world.
When running docker image as a daemon, the /run/init/start
shell script is executed at startup.
user@host:$ docker run -d -it --name ${my_container_name} -v "${host_path}:/var/www/html" zaioll/php-zts:${php_version}
To share the socket file, create shared volume first:
user@host:$ docker volume create sock
Then, run the container passing the created shared volume.
user@host:$ docker run -d -it -v "sock:/run/php" -v "${host_path}:/var/www/html" --name ${my_container_name} zaioll/php-zts:${php_version}
The
/run/init/hook-start
shell script is called at the end of/run/init/start
running process and before startsupervisord
. Add your custom shell script commands into it to run it.
When running docker image as a iteractive form, the /run/init/start
shell script is not executed. Then, PHP-FPM is not started. It needs manual run.
-
APP_ENV
= ( ^dev* | ^prod* | debug ) Default:dev
-
Main diretive to configure the entire environment. When APP_ENV is configured with "dev" value, the xdebug will be enabled and configured and PHP (and webserver if it's enabled) default timeouts and time limits will be incresead at 8 times. On the other hand, if APP_ENV is configured with "prod" value, the opcache will be enabled and configured. PHP defaults values for timeouts will be decreased to 10% of the default values.
-
Default overwritten prod PHP config:
PHP_INI=" cgi.fix_pathinfo=0 display_startup_errors=Off memory_limit=${memory_limit}M zend.assertions=-1 report_memleaks=Off display_errors=Off log_errors=Off expose_php=Off max_execution_time=${max_execution_time} date.time_zone=America/Manaus session.cookie_secure=On"
-
Default overwritten dev PHP config:
PHP_INI=" cgi.fix_pathinfo=0 display_startup_errors=On implicit_flush=On memory_limit=${memory_limit}M display_errors=On log_errors=On expose_php=On max_execution_time=${max_execution_time} date.time_zone=America/Manaus session.cookie_secure=Off"
-
-
-
PHP_FPM_SOCKET
=( off | on ) Default:on
- To enable PHP-FPM socket, set
ENABLE_FPM_SOCKET
env var toon
to create and communicate through unix socket file /run/php/php7-fpm.sock or set tooff
for communication through tcp/9000 port instead.
- To enable PHP-FPM socket, set
-
WEB_SERVER
=( on | off ) Default:on
-
OPCACHE_CONF
=( off | $config ) Default:$config
when prod environment -
XDEBUG_CONFIG
= ( off | $config ) Default:$config
when dev environment- If Xdebug is enabled, the PHP-FPM expects xdebug
configuration through
XDEBUG_CONFIG
env var.
If
ENABLE_FPM_SOCKET
= "off", xdebug.remote_port will be configured to use 9003 port. - If Xdebug is enabled, the PHP-FPM expects xdebug
configuration through
-
REDIS
=( on | off ) Default:off
-
ENABLE_MEMCACHED
=( on | off ) Default:off
-
ENABLE_PARALLEL
=( on | off ) Default:on
-
ENABLE_MONGODB
=( on | off ) Default:off
-
ENABLE_SWOOLE
=( on | off ) Default:off
-
ENABLE_AMQP
=( on | off ) Default:off
-
ENABLE_SODIUM
=( on | off ) Default:on
-
ENABLE_DECIMAL
=( on | off ) Default:on
The PHP manual is available at php.net/docs.
At every compilation, the last patch version is fetched.
EBNF:
<php_version_installed> ::= <php_version> <separator> <patch>
<php_version> ::= <major> <separator> <minor>
<major> ::= "7"
<separator> ::= "."
<minor> ::= "1" | "2" | "3" | "4"
<patch> ::= ( "0" | [1-9] [0-9]*)
- Composer 2.X for dependency management in PHP.
- Nginx and Apache2 webservers
- PhpBench tool.
- Phive
Inside /info/
directory are compile and info logs files
The benchmarks were generated by the Apache ab, making requests on index.php
script over the PHP built-in web server and plotted with the gnuplot program with configurations inspired in this article.
// /index.php
<?php
for ($i = 0; $i < 50; $i++) {
if ($i % 2 == 0) {
echo ".";
continue;
}
echo "*";
}
[opcache]
zend_extension=${extension_dir}/opcache.so
opcache.enable=1
opcache.enable_cli=0
opcache.validate_timestamps=0
opcache.max_accelerated_files=65406
opcache.memory_consumption=256
opcache.interned_strings_buffer=12
opcache.fast_shutdown=1
opcache.enable_file_override=1
# Tell gnuplot to use tabs as the delimiter instead of spaces (default)
set datafile separator '\t'
# Output to a jpeg file
set terminal jpeg size 1280,720
# Set the aspect ratio of the graph
set size 1, 1
# The file to write to
set output "<connections>_<concurrency>.jpg"
# The graph title
set title "Benchmark testing with opcache enabled and xdebug disabled: ab -n <connections> -c <concurrency> -g out.data http://localhost/"
# Where to place the legend/key
set key left top
# Draw gridlines oriented on the y axis
set grid y
# Specify that the x-series data is time data
set xdata time
# Specify the *input* format of the time data
set timefmt "%s"
# Specify the *output* format for the x-axis tick labels
set format x "%S"
# Label the x-axis
set xlabel 'seconds'
# Label the y-axis
set ylabel "response time (ms)"
# Plot the data
plot "out.data" every ::2 using 2:5 title 'response time' with points
exit
- 300 requests, 80 concurrent connections
- 2000 requests, 800 concurrent connections
- 5000 requests, 800 concurrent connections
- 50000 requests, 1020 concurrent connections
MIT