了解Nginx在不同操作系统中的文件目录结构
| 目录 / 文件用途 | Alibaba Cloud Linux 3 (DNF) | CentOS / RHEL / Rocky (DNF) | Ubuntu / Debian (APT) | macOS (Homebrew M芯片) | Windows (官方解压包) |
|---|---|---|---|---|---|
| 主配置文件 | /etc/nginx/nginx.conf (自带 .default 原始备份) | /etc/nginx/nginx.conf | /etc/nginx/nginx.conf | /opt/homebrew/etc/nginx/nginx.conf | conf\nginx.conf |
| 子配置目录 | 无默认目录 (需手动创建并 include) | /etc/nginx/conf.d/ /etc/nginx/default.d/ | /etc/nginx/sites-enabled/ /etc/nginx/conf.d/ | /opt/homebrew/etc/nginx/servers/ | 无默认目录 (需手动创建并 include) |
| 默认网站根目录 | /usr/share/nginx/html/ | /usr/share/nginx/html/ | /var/www/html/ | /opt/homebrew/var/www/ | html\ |
| 日志文件目录 | /var/log/nginx/ | /var/log/nginx/ | /var/log/nginx/ | /opt/homebrew/var/log/nginx/ | logs\ |
| 临时缓冲目录 | /var/lib/nginx/tmp/ | /var/lib/nginx/tmp/ | /var/lib/nginx/ | /opt/homebrew/var/run/nginx/ | temp\ |
| 可执行文件 | /usr/sbin/nginx (附带 /usr/bin/nginx-upgrade) | /usr/sbin/nginx | /usr/sbin/nginx | /opt/homebrew/bin/nginx | nginx.exe |
| PID 进程文件 | /run/nginx.pid | /run/nginx.pid | /run/nginx.pid | /opt/homebrew/var/run/nginx.pid | logs\nginx.pid |
这里只了解Ubuntu的即可,可以在终端列出来nginx的文件
shell
1
dpkg -L nginx-common nginx-core