Docker nginx / php notes


Docker nginx / php notes

nginx executable

I had some trouble getting nginx with php-fpm to operate. So I tried to get working a simple setup to nut-out the nuances. I got it working using php-fpm socket with Apline Linux on 2 Docker instances, one running Nginx and the other php-fpm. Next try would be a second Nginx in separate Docker and then trying IP TCP connectivity instead of socket file.

To run and control nginx.

  • nginx to run.
  • nginx -h to get all help / options
  • nginx -s signal, where signal maybe:
    • stop for fast shutdown
    • quit for graceful shutdown
    • reload to reload the configuration files
    • reopen to reopen the log files
  • nginx -t to test configuration
  • nginx -c config_file to start nginx with a non default config file. Default config file is /etc/nginx/nginx.conf.

Alpine nginx standard configuration (v3.20.0, 2024-05-22)











This directory is empty.


This directory does not exist. This is a concern as the default nginx configuration nginx.conf references this directory. Of course the /etc/nginx/conf.d is a default override directory, so it can be created on use.






There is following empty subdirectory structure: /var/www/localhost/htdocs

basic static site from base setup

Unless otherwise configured nginx reads the default configuration file at /etc/nginx/nginx.conf. I replaced the default nginx.conf user directive to match that in the /etc/php/php-fpm.d/www.conf for the socket listen.owner and directives. I do not change the www.conf user and group directives, which are default nobody This file has dynamic module overrides and root code snippet updates. The main virtual host configuration files are located in sub-directory /etc/nginx/http.d

static web page

Place this at following location; /var/www/test/index.html

basic static html test page

Basic Static Content

The directory /etc/nginx/http.d/ should already exit. Create test.conf.


The existing default.conf return 404 error and will conflict with the new simple configuration and need to be removed.

nginx logging

nginx seems to have the following log levels # [ debug | info | notice | warn | error | crit ]. Hence when developing and creating a html server use of info or notice is probably used whereas warn or error level logging would probably be used for a normal running html server.

s6-rc nginx

In order to run nginx in the foreground us echo “daemon off;” » /etc/nginx/nginx.conf. I tried nginx -g 'daemon off;', but that did not work.


There are 2 php executables, php a cli version (/usr/bin/php82) and php-fpm for fpm-fcgi (/usr/sbin/php-fpm82). We are interested in the fpm type and it can be run in foreground using flag -F or --nodaemonize. The php-fpm modules are stored here /usr/lib/php82/modules. There is /etc/php82 that has the configuration files.

php82 config files




nginx fastcgi setup




/app/www/public/data/pages/docker_notes/nginx-php-notes.txt · Last modified: 2024-06-01 Sat wk22 20:23
CC Attribution-Share Alike 4.0 International Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Share Alike 4.0 International