在 Ubuntu 20 系统中通过 apt install nginx-full 安装的 Nginx,其核心文件和配置路径如下:
一、核心目录及文件位置
主程序路径
二进制文件:/usr/sbin/nginx
(用于启动、停止服务等操作)
配置文件目录
主配置目录:/etc/nginx
主配置文件:/etc/nginx/nginx.conf
虚拟主机配置:/etc/nginx/sites-available/ 和 /etc/nginx/sites-enabled/
默认网站根目录
静态文件存储路径:/usr/share/nginx/html/
部分版本可能默认到 /var/www/ 路径
日志文件目录
访问日志和错误日志:/var/log/nginx/
服务管理脚本
系统服务控制文件:/etc/init.d/nginx
Systemd 服务单元(通过 systemctl 管理):/lib/systemd/system/nginx.service
二、验证安装路径
查看版本及编译参数
nginx -V # 输出中包含 `--prefix` 参数(通常显示为默认路径 `/usr`):ml-citation{ref="5" data="citationList"}
检查配置文件路径
sudo nginx -t # 输出中显示配置文件的加载路径(如 `/etc/nginx/nginx.conf`):ml-citation{ref="7" data="citationList"}
三、关键说明
默认模块支持:nginx-full 包含 SSL、Gzip 等常用模块,但需通过 nginx -V 确认具体编译参数 。
服务管理命令:使用 systemctl start/stop/reload nginx 或 service nginx <action> 管理服务 。
如需自定义安装路径或添加第三方模块,需改用源码编译安装方式(参考 )。