zoukankan      html  css  js  c++  java
  • nginx常用命令

    1.测试配置文件:nginx -t

    2.启动命令:nginx

    3.停止命令:nginx -s stop或nginx -s quit

    4.重启命令:nginx -s reload

    5.查看进程命令:ps -ef |grep nginx

    虚拟域名配置及测试验证:

    配置步骤:

    1.编辑nginx.conf

    2.增加include vhost/*.conf

    vhost配置文件解析:

    server { 
        listen 80; 
        autoindex on; 
        server_name tomcat.imooc.com; 
        access_log c:/access.log combined; 
        index index.html index.htm index.jsp index.php; 
        #error_page 404 /404.html; 
        if ( $query_string ~* ".*[;'<>].*" ){ 
            return 404; 
        } 
        location / { 
            proxy_pass http://127.0.0.1:8080; 
            add_header Access-Control-Allow-Origin *; 
        } 
    }

    listen 80:监听80端口

    autoindex on:是否自动创建首页索引目录

    server_name tomcat.imooc.com:二级域名,当nginx接到这种请求,会通过proxy_pass,将这个域名请求转移到http://127.0.0.1:8080这个实际域名

    proxy_pass:转移到的真实域名,这里也可以用root + 本地存放地址目录。

    ngnix本地的注意事项:

    1.可以配置域名转发,但一定要配置host(如果不配置host,用的域名就是真实域名,不会生效),并且使host生效之后才可以,设置完成之后要重启浏览器。

     配置host步骤:

      1)进入C:WindowsSystem32driversetc

      2)用记事本打开hosts文件

      3)添加好对应的域名及ip

  • 相关阅读:
    Solr 配置连接数据库
    最大利润
    分割金条的最小代价
    民居点亮
    一个会议室最多安排几场宣讲
    N皇后问题
    Integer的缓存机制
    Windows快捷键
    二叉树中两个节点的最低公共祖节点
    判断二叉树是不是完全二叉树
  • 原文地址:https://www.cnblogs.com/cing/p/8358775.html
Copyright © 2011-2022 走看看