zoukankan      html  css  js  c++  java
  • NGINX相关命令

    相关目录

    # 主目录
    /usr/local/nginx
    
    # 配置文件路径
    /usr/local/nginx/conf/nginx.conf # linux
    安装目录conf
    ginx.conf # Windows
    
    # 静态文件路径
    /usr/local/nginx/html/

    启动

    /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
    
    # 看到如下显示说明启动成功
    '''
    nginx.conf syntax is ok
    nginx.conf test is successful
    '''

    重启

    /usr/local/nginx/sbin/nginx -s reload

    查看进程是否启动

    ps -ef|grep nginx

    查看端口号是否占用

    netstat -tunlp|grep 端口号

    强制停止

    pkill -9 nginx

    验证nginx配置文件是否正确

    /usr/local/nginx/sbin/nginx -t
    # 看到如下显示说明配置文件正确
    '''
    nginx.conf syntax is ok
    nginx.conf test is successful
    '''

    Nginx配置基于多域名、端口、IP的虚拟主机

    基于域名的虚拟主机

        通过不同的域名区分不同的虚拟主机,基于域名的虚拟主机是企业应用最广的虚拟主机类型,几乎所有对外提供服务的网站使用的都是基于域名的主机

    配置:修改nginx配置文件配置多域名,重启nginx服务,创建对应的不同站点目录并上传站点文件,也可都使用一个站点目录,通过多域名来访问

    server{
        listen               80;
        server_name    www.aaa.com;
        location / {
            root      html/aaa;
            index    index.html  index.htm;
        }
    }
    
    server{
        listen               80;
        server_name    www.bbb.com;
        location / {
            root      html/bbb;
            index    index.html  index.htm;
        }
    }
    
    server{
        listen               80;
        server_name    www.ccc.com;
        location / {
            root      html/ccc;
            index    index.html  index.htm;
        }
    }
    基于域名

    基于端口的虚拟主机

        通过不同的端口来区分不同的虚拟主机,此类虚拟主机对应的企业应用主要为公司内部的网站,例如:一些不希望直接对外提供用户访问的网站后台等,访问基于端口的虚拟主机,地址里要带有端口号,例如http://www.test.com:81 http://www.test.com:82等

    server{
        listen               80;
        server_name    localhost;
        location / {
            root      html/aaa;
            index    index.html  index.htm;
        }
    }
    
    server{
        listen               81;
        server_name    localhost;
        location / {
            root      html/bbb;
            index    index.html  index.htm;
        }
    }
    
    server{
        listen               82;
        server_name    localhost;
        location / {
            root      html/ccc;
            index    index.html  index.htm;
        }
    }
    基于端口

    基于IP的虚拟主机

        通过不同的IP区分不同的虚拟主机,此类虚拟主机对应的企业应用非常少见,一般不同的业务需要使用多IP的场景都会在负载均衡上进行IP绑定。

    server{
        listen               10.0.0.7:80;
        server_name    www.aaa.com;
        location / {
            root      html/aaa;
            index    index.html  index.htm;
        }
    }
    
    server{
        listen               10.0.0.8:80;
        server_name    www.bbb.com;
        location / {
            root      html/bbb;
            index    index.html  index.htm;
        }
    }
    
    server{
        listen               10.0.0.9:80;
        server_name    www.ccc.com;
        location / {
            root      html/ccc;
            index    index.html  index.htm;
        }
    }
    基于IP

    其他配置

    修改上传文件大小限制

      Nginx 默认是对上传的文件大小有限制的,我们可以修改相应配置来修改对文件大小的限制

    # 在http{}段落增加如下参数
    client_max_body_size 20M; # 20M可以换为任何大小

    参考:https://www.cnblogs.com/ssgeek/p/9220922.html

                        

  • 相关阅读:
    ruby 二进制转十进制 Integer("0b101") = 5
    开始菜单和我的文档的我的图片及我的音乐变成 my pictrues 正常图标了
    ruby watir 莫名其妙的错误
    Excel SaveAS是去掉提示框
    apache && jboss安装
    ruby require include的区别
    ruby控制鼠标
    This error is raised because the column 'type' is reserved for storing the class in case of inheritance
    用正则表达式限制文本框只能输入数字,小数点,英文字母,汉字等各类代码
    ASP.NET 如何动态修改 Header 属性如添加 Meta 标签 keywords description!
  • 原文地址:https://www.cnblogs.com/zhuminghui/p/11416672.html
Copyright © 2011-2022 走看看