zoukankan      html  css  js  c++  java
  • windows下nginx的安装

    一. 下载

    http://nginx.org/    (下载后解压)

    二. 修改配置文件

    nginx配置文件在 nginx-1.8.0conf ginx.conf

    复制代码
    http {
         gzip  on;
    
        #静态文件
        server {
            listen       80;
            server_name  static.cnblog.com;
    
            location / {
                root   G:/source/static_cnblog_com;
            }
        }
    
        #html文件
        server {
            listen       80;
            server_name  127.0.0.1 localhost;
    
            location / {
                root   G:/source/html/mobile/dist;
                index  index.html index.htm;
            }
        }
    }
    复制代码

    如上图可以配置多个server,这样访问localhost即访问到了  G:/source/html/mobile/dist  目录, 还可以开启gzip,压缩html

    三. 启动

     注意不要直接双击nginx.exe,这样会导致修改配置后重启、停止nginx无效,需要手动关闭任务管理器内的所有nginx进程
     
    在nginx.exe目录,打开命令行工具,用命令 启动/关闭/重启nginx 
     
    start nginx : 启动nginx
    nginx -s reload  :修改配置后重新加载生效
    nginx -s reopen  :重新打开日志文件
    nginx -t -c /path/to/nginx.conf 测试nginx配置文件是否正确

    关闭nginx:
    nginx -s stop  :快速停止nginx
    nginx -s quit  :完整有序的停止nginx


    如果遇到报错:

    bash: nginx: command not found

    有可能是你再linux命令行环境下运行了windows命令,

    如果你之前是允许 nginx -s reload报错, 试下 ./nginx -s reload

    或者 用windows系统自带命令行工具运行

     
  • 相关阅读:
    CS224d lecture 16札记
    CS224d lecture 15札记
    CS224d lecture 14札记
    CS224d lecture 13札记
    将博客搬至CSDN
    三张图理解JavaScript原型链
    三道题理解软件流水
    网络安全密码学课程笔记
    “wuliao“(无聊)聊天软件
    大二小学期C#资产管理大作业小记
  • 原文地址:https://www.cnblogs.com/ahmm/p/8995844.html
Copyright © 2011-2022 走看看