# nginx **Repository Path**: andrew-2020/Nginx ## Basic Information - **Project Name**: nginx - **Description**: http://www.cnblogs.com/saysmy/p/6609796.html - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2019-05-20 - **Last Updated**: 2020-12-19 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README http://www.cnblogs.com/saysmy/p/6609796.html 二. 修改配置文件 nginx配置文件在 nginx-1.8.0\conf\nginx.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系统自带命令行工具运行