1、其他目录下的。网页文件 必须写成 index.html 不能写成 sina.html,更不能写成test.index.html 否则报错,这是格式2、配置域名必须要写到host里面;和通过百度访问域名是另一回事;通过 curl+ 域名访问只能对应80端口,不能写成8083其他端口 ,如下server {listen 80; 注意:写 8083其他端口,就不能通过curl +域名来访问。 想从百度里面访问域名必须注册备案域名server_name www.test1.com;access_log logs/baidu.access.log ;location / {root /web/test1;index index.html index.htm;}}3、没有注册域名最后不要用域名, 容易出错, 全都写成ip+端口 模式 , 例如下面[root@host-10-1-1-161 conf.d]# pwd
/etc/nginx/conf.d
[root@host-10-1-1-161 conf.d]# cat test1.conf
server {
listen 8083;
server_name 127.0.0.1:8083;
location / {
root /web/sing/;
index index.html index.htm;
}
}4、重要:修改配置文件使用虚拟机,否则怎么配置都不生效,添加如下用户[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;5、其他目录下的 html文件,必须写成 xxx.index.html 否则无法访问 必须要带index.html 否则无法访问[root@host-10-1-1-161 ~]# curl http://127.0.0.1:8080
<head>head>
"white">
403 Forbidden
[root&#64;host-10-1-1-161 ~]# mv /web/sing/sina.html /web/sing/index.html
[root&#64;host-10-1-1-161 ~]#
[root&#64;host-10-1-1-161 ~]# curl http://127.0.0.1:8080
this is my nginx
6、8084端口不能用&#xff1b;端口不用冲突