我以前使用过Apache,所以我知道默认的公共web根目录通常是/var/www/。
我最近开始使用nginx,但我似乎找不到默认的公共web根。
我在哪里可以找到nginx的默认公共web根?
我以前使用过Apache,所以我知道默认的公共web根目录通常是/var/www/。
我最近开始使用nginx,但我似乎找不到默认的公共web根。
我在哪里可以找到nginx的默认公共web根?
当前回答
我在Digital Ocean用nginx运行WordPress网站时也遇到了这个问题。
我的解决方案如下:
修改/etc/nginx/nginx.conf文件如下:
server {
root /var/www/html;
}
然后我必须sudo服务nginx重启
nginx -V命令也显示你的nginx配置文件的位置(我的是指向/etc/nginx/nginx.conf)
其他回答
nginx的默认web文件夹取决于你如何安装它,但通常它在这些位置:
/usr/local/nginx/html
/usr/nginx/html
'default public web root'可以在nginx -V output中找到:
nginx -V
nginx version: nginx/1.10.1
built with OpenSSL 1.0.2h 3 May 2016
TLS SNI support enabled
configure arguments: --prefix=/var/lib/nginx --sbin-path=/usr/sbin/nginx --conf-path=/etc/nginx/nginx.conf --pid-path=/run/nginx/nginx.pid --lock-path=/run/nginx/nginx.lock --http-client-body-temp-path=/var/lib/nginx/tmp/client_body --http-proxy-temp-path=/var/lib/nginx/tmp/proxy --http-fastcgi-temp-path=/var/lib/nginx/tmp/fastcgi --http-uwsgi-temp-path=/var/lib/nginx/tmp/uwsgi --http-scgi-temp-path=/var/lib/nginx/tmp/scgi --user=nginx --group=nginx --with-ipv6 --with-file-aio --with-pcre-jit --with-http_dav_module --with-http_ssl_module --with-http_stub_status_module --with-http_gzip_static_module --with-http_v2_module --with-http_auth_request_module --with-mail --with-mail_ssl_module
前缀值是问题的答案。对于上面的示例,根目录是/var/lib/nginx
你可以访问nginx文件配置,你可以看到root /path。在这个 nginx apache的默认地址是/var/www/html
查看nginx配置文件来确定。 这个命令是greps在你的机器上配置的任何东西:
cat /etc/nginx/sites-enabled/default |grep "root"
在我的机器上,它是:root /usr/share/nginx/www;
在Mac上使用brew安装nginx:
/ usr / local / etc / nginx / nginx上。
location / {
root html; # **means /usr/local/Cellar/nginx/1.8.0/html and it soft linked to /usr/local/var/www**
index index.html;
}