• 特别注意


    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
    <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>
    
    
    
    
    
    6、8084端口不能用;端口不用冲突
  • 相关阅读:
    Linux_9/ RAID & LVM
    Linux_8/ fdisk, xfs_quota, edquota
    Linux_7/(chattr, lsattr), (setfacl, getfacl),su
    Linux_6/ Vim, Shell(下),(at, crond), (SUID, SGID, SBIT)
    Linux_5/ Vim, Shell(上)
    Linux_4/ |, (>, 2>, &>, >>, 2>>)
    Map集合的遍历
    List集合三种遍历方法
    MySQL安装
    排序法
  • 原文地址:https://www.cnblogs.com/effortsing/p/10012457.html
Copyright © 2020-2023  润新知