Mine is an Ubuntu16.04 host from Alibaba Cloud. The nginx installation was successful. When accessing the IP (for example: 0.0.0.0), the nginx welcome page is displayed, but when I access 0.0.0.0/index.html
Displays 404, enter curl 127.0.0.1/index.html
on the host to open the 404 page file. In other words, all files in the root directory have no routing. How to solve this problem?
PHP中文网2017-05-27 17:47:02
/etc/nginx/conf.d/nginx.conf
Default configuration
/etc/nginx/sites-available/default
Default localhost configuration
/var/www/html/
Default working directory
http://localhost/index.nginx-debian.html
Default welcome page full url
So you need to edit the /etc/nginx/sites-available/default
root
line and change the directory to your own directory.
滿天的星座2017-05-27 17:47:02
The conf/nginx.conf configuration in the nginx installation directory is as follows:
server {
listen 80;
server_name localhost;
location / {
root html;
index index.html index.htm;
}
}
The root
attribute specifies the root directory where the accessed file is located, the index
attribute specifies the default access page, and location /
means matching all requests.
The page reports 404, then you go to the directory specified by root
to check whether there is an index.html file