I'm using docker-compose
to setup a minimal nginx
+ php-fpm
application but for some reason there is no php.ini file on the docker container (I know because phpinfo()
says Loaded Configuration File: (none)
).
Here's my docker-compose.yml
file:
web:
image: nginx
ports:
- "8080:80"
volumes:
- ./site.conf:/etc/nginx/conf.d/site.conf
links:
- php
php:
image: php:5-fpm
volumes:
- .root:/var/www/html:ro
command: bash -c "apt-get update && apt-get install -y php5-mysql && php-fpm"
site.conf
is pretty straightforward as well:
server {
index index.php;
server_name local.myspicesage.com;
error_log /var/log/nginx/error.log;
access_log /var/log/nginx/access.log;
root /var/www/html;
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass php:9000;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
}
}
And finally I have the most basic index.php
possible:
<?php
echo phpinfo();
I really don't want to start from scratch if I don't have to. Is there supposed to be a php.ini file included with the php:5-fpm
docker image? If not, is there a generic file I could use to start with?
Best Answer
The container also has
/usr/local/etc/php/conf.d
and will read and parse every configuration file in that directory.Notice that it will still say
Loaded Configuration File => (none)
, but that it will also sayAdditional .ini files parsed
and there you will see it walking through that directory ... and the various files that the container puts there:docker-php-ext-XXX.ini
. (So it's rather misleading for it to say(none)
...)It's useful to do things like this:
... which in this case will very quickly show you only the lines in PHP's voluminous output that contain (in upper or lower case) the string
conf
.