ubuntu系统不知为何无法访问localhost了,打算重装nginx。将/etc/nginx全部删除,避免配置文件保留。apt安装倒很快,然后启动,发现报错:

Starting nginx: nginx: [emerg] open() "/etc/nginx/nginx.conf" failed (2: No such file or directory)
nginx: configuration file /etc/nginx/nginx.conf test failed

一看/etc/nginx没有创建。

最后搜到国外一个解决方法:

apt-get purge nginx nginx-common nginx-full
apt-get install nginx

然后启动,确实可以访问了。