1、重要:修改配置文件使用虚拟机,否则怎么配置都不生效,添加如下用户
[root@host-10-1-1-161 html]# ll /etc/nginx/nginx.conf
-rw-r--r-- 1 root root 345 Aug 26 10:41 /etc/nginx/nginx.conf
[root@host-10-1-1-161 html]# vi /etc/nginx/nginx.conf
user root root; #说明:这里的user根据 自己的nginx.conf文件所在的目录的属主属性而定
worker_processes 1;
2、其他目录下的 html文件,必须写成 index.html 否则无法访问
[root@host-10-1-1-161 ~]# curl http://127.0.0.1:8080
<html>
<head><title>403 Forbidden</title></head>
<body bgcolor="white">
<center><h1>403 Forbidden</h1></center>
<hr><center>nginx/1.12.2</center>
</body>
</html>
[root@host-10-1-1-161 ~]# mv /web/sing/sina.html /web/sing/index.html
[root@host-10-1-1-161 ~]#
[root@host-10-1-1-161 ~]# curl http://127.0.0.1:8080
<html>
<p>
this is my nginx
</p>
</html>