Understanding Nginx Installation Directories and Compilation Parameters

Nginx Installation Directory Structure

To view all files installed by the Nginx package, execute the following command:

rpm -ql nginx

The output includes configuration files, log files, and executable binaries.

/etc/logrotate.d/nginx

  • Type: Configuration file
  • Purpose: Configures log rotation for Nginx using the logrotate service, enabling automatic log file management (e.g., daily rotation).

/etc/nginx/ and related files (/etc/nginx/nginx.conf, /etc/nginx/conf.d/, /etc/nginx/conf.d/default.conf)

  • Type: Directory and configuration files
  • Purpose: Contains the primary Nginx configuration. The main configuration file is /etc/nginx/nginx.conf. Upon startup, Nginx first reads this file. If no specific directives are overridden, it subsequently loads /etc/nginx/conf.d/default.conf (the default site configuration).

/etc/nginx/fastcgi_params, /etc/nginx/uwsgi_params, /etc/nginx/scgi_params

  • Type: Configuration files
  • Purpose: Define parameters for CGI, FastCGI, uWSGI, and SCGI protocol interfaces.

/etc/nginx/koi-utf, /etc/nginx/koi-win, /etc/nginx/win-utf

  • Type: Configuration files
  • Purpose: Character set mapping files used for encoding conversion.

/etc/nginx/mime.types

  • Type: Configuration file
  • Purpose: Maps file extensions to HTTP Content-Type headers, allowing Nginx to correctly identify and serve various file types.

/usr/lib/systemd/system/nginx.service, /usr/lib/systemd/system/nginx-debug.service, /etc/sysconfig/nginx, /etc/sysconfig/nginx-debug

  • Type: Configuration files
  • Purpose: Systemd service unit files and environment configuration for managing Nginx as a system daemon.

/usr/lib64/nginx/, /etc/nginx/modules/

  • Type: Directories
  • Purpose: Storage locations for Nginx dynamic modules.

/usr/sbin/nginx, /usr/sbin/nginx-debug

  • Type: Executable commmands
  • Purpose: The main Nginx binary and its debug version for starting and managing the service.

/usr/share/doc/nginx-*/, /usr/share/man/man8/nginx.8.gz

  • Type: Directories and files
  • Purpose: Documentation, license files, and the manual page for Nginx.

/var/cache/nginx/

  • Type: Directory
  • Purpose: Cache directory used by Nginx for proxy and FastCGI caching features.

/var/log/nginx/

  • Type: Directory
  • Purpose: Default directory for Nginx log files, including access.log and error.log.

Compilation Parameters and Build Options

To inspect the compilation parameters used to build your Nginx binary, run:

nginx -V

The output includes several key configuration options:

Installation Path Options:

  • --prefix=/etc/nginx
  • --sbin-path=/usr/sbin/nginx
  • --modules-path=/usr/lib64/nginx/modules
  • --conf-path=/etc/nginx/nginx.conf
  • --error-log-path=/var/log/nginx/error.log
  • --http-log-path=/var/log/nginx/access.log
  • --pid-path=/var/run/nginx.pid (Stores the main process ID)
  • --lock-path=/var/run/nginx.lock
  • Purpose: These options define the target installation directories for binaries, configuration, logs, and runtime files.

Temporary File Path Options:

  • --http-client-body-temp-path=/var/cache/nginx/client_temp
  • --http-proxy-temp-path=/var/cache/nginx/proxy_temp
  • --http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp
  • --http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp
  • --http-scgi-temp-path=/var/cache/nginx/scgi_temp
  • Purpose: Specify directories for temporary files generated during request processing for different modules (e.g., client request bodies, proxy responses).

Process User/Group Options:

  • --user=nginx
  • --group=nginx
  • Purpose: Define the system user and group under which the Nginx worker processes run. Although the master process is typically started by root, worker processes drop privileges to this user for anhanced security.

Compiler and Linker Options:

  • --with-cc-opt=parameters
  • Purpose: Adds custom parameters to the C compiler flags (CFLAGS). This can be used for performance tuning or enabling specific features, such as adjusting file descriptor limits for certain I/O models.
  • --with-ld-opt=parameters
  • Purpose: Provides additional parameters to the linker, often used to link against specific system libraries or set linker flags.

Tags: nginx installation configuration compilation system-administration

Posted on Sun, 10 May 2026 22:26:22 +0000 by canadian_angel