很早之前我用brew安装了一个nginx,并部署了一个静态的index.html。今天我在找这个index.html文件时发现找不到了。
首先我的通过
bash
nginx -t
nginx: the configuration file /opt/homebrew/etc/nginx/nginx.conf syntax is ok
nginx: configuration file /opt/homebrew/etc/nginx/nginx.conf test is successful
这里能看出来nginx的配置文件路径
我这里核心配置如下:
bash
server {
listen 8001;
server_name localhost;
#access_log logs/host.access.log main;
location / {
root html;
index index.html index.htm;
}
}
配置是安装后自带的,我应该只是修改了端口。
看到root html; 我就懵了一下,这个路径在哪?
bash
nginx -V 2>&1 | grep prefix
可以通过以上命令查询,我这里有一行这样的输出
configure arguments: --prefix=/opt/homebrew/Cellar/nginx/1.29.8
最终我找到了我的html最终路径
bash
/opt/homebrew/Cellar/nginx/1.29.8/html
这个路径还是一个软链接,最原始的路径应该是:
bash
/opt/homebrew/var/www