这个很奇怪,因为我没有任何错误信息.
我有一个非常基本的默认文件:
server { #listen 80; ## listen for ipv4; this line is default and implied #listen [::]:80 default ipv6only=on; ## listen for ipv6 root /var/www; index index.html index.htm index.PHP; # Make site accessible from http://localhost/ server_name localhost; access_log /var/log/Nginx/default.access_log; error_log /var/log/Nginx/default.error_log warn; location / { # First attempt to serve request as file,then # as directory,then fall back to index.html try_files $uri $uri/ /index.html; } location /doc { root /usr/share; autoindex on; allow 127.0.0.1; deny all; } location /images { root /usr/share; autoindex off; }
现在,在shell中,
ping localhost
很好.
但是,在任何浏览器中,它都会显示错误.例如,Chrome说:“哎呀!Google Chrome无法找到localhost”.
另一方面,127.0.0.1适用于浏览器.