Docker nginx / php notes

This is an old revision of the document!


Back  
 

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.

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.18.4, 2023-10-07)

/etc/nginx/

/etc/nginx/fastcgi.conf

/etc/nginx/fastcgi_params

/etc/nginx/mime.types

/etc/nginx/nginx.conf

/etc/nginx/scgi_params

/etc/nginx/uwsgi_params

/etc/nginx/http.d/

/etc/nginx/http.d/default.conf

/etc/nginx/modules/

This directory is empty.

/etc/nginx/conf.d/

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.

/usr/share/nginx/

/usr/share/nginx/http-default_server.conf

/var/lib/nginx/html/

/var/lib/nginx/html/index.html

/var/www/

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 listen.group 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.

/etc/nginx/http.d/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.

php-fpm

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

/etc/php82/php-fpm.conf

/etc/php82/php.ini

/etc/php82/php-fpm.d/www.conf

nginx fastcgi setup

/etc/nginx/http.d/fastcgi_test.conf

/var/www/test/test.php

/var/www/test/phpinfo.php

/app/www/public/data/attic/docker_notes/nginx-php-notes.1697341683.txt.gz · Last modified: 2023-10-15 Sun wk41 11:48
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