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?
Ubuntu apt install nginx default configuration
/etc/nginx/conf.d/nginx.conf
Default configuration/etc/nginx/sites-available/default
Default localhost configuration/var/www/html/
Default working directoryhttp://localhost/index.nginx-debian.html
Default welcome page full urlSo you need to edit the
/etc/nginx/sites-available/default
root
line and change the directory to your own directory.The conf/nginx.conf configuration in the nginx installation directory is as follows:
The
root
attribute specifies the root directory where the accessed file is located, theindex
attribute specifies the default access page, andlocation /
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