Nginx 服务器问题
NGinx Server Issue
所以我使用的是 Digital Ocean Server,我起诉了 LEMP 构建。
当我导航到 /var/www/html 目录时,我看到构建附带的两个标准文件 'index.html' 和 'index.php'。
现在我的问题是,我的 Web 应用程序的结构使得 "index.html" 文件位于另一个子目录 "dist" 下。 (/var/www/html/距离/)
如何配置 Nginx 以显示此文件?
更新:
server {
listen 80 default_server;
listen [::]:80 default_server ipv6only=on;
root /var/www/html;
index index.php index.html index.htm;
# Make site accessible from http://localhost/
servername ***.**.**.**;
location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ =404;
# Uncomment to enable naxsi on this location
# include /etc/nginx/naxsi.rules
}
error_page 404 /404.html;
error_page 500 502 503 504 /50x.html;
更改配置中的这一行
root /var/www/html;
然后放这个
root /var/www/html/dist;
编辑:
如果您使用基于 Debian 的服务器(例如 Ubuntu),请在控制台上执行 sudo service nginx reload
。如果不起作用,请尝试 sudo service nginx restart
所以我使用的是 Digital Ocean Server,我起诉了 LEMP 构建。
当我导航到 /var/www/html 目录时,我看到构建附带的两个标准文件 'index.html' 和 'index.php'。
现在我的问题是,我的 Web 应用程序的结构使得 "index.html" 文件位于另一个子目录 "dist" 下。 (/var/www/html/距离/)
如何配置 Nginx 以显示此文件?
更新:
server {
listen 80 default_server;
listen [::]:80 default_server ipv6only=on;
root /var/www/html;
index index.php index.html index.htm;
# Make site accessible from http://localhost/
servername ***.**.**.**;
location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ =404;
# Uncomment to enable naxsi on this location
# include /etc/nginx/naxsi.rules
}
error_page 404 /404.html;
error_page 500 502 503 504 /50x.html;
更改配置中的这一行
root /var/www/html;
然后放这个
root /var/www/html/dist;
编辑:
如果您使用基于 Debian 的服务器(例如 Ubuntu),请在控制台上执行 sudo service nginx reload
。如果不起作用,请尝试 sudo service nginx restart