nginx笔记(view:728)

1.win下启动
.\nginx

2.停止

.\nginx            #启动
.\nginx -v         #查看版本
nginx -s stop      #关闭
nginx -s reload    #重新加载配置
start nginx            #启动
nginx -t               #语法检测
nginx.exe -s stop      #停止
nginx.exe -s quit      #退出
nginx.exe -s reload    #重新载入

Windows Server 2016

start nginx
nginx -t
nginx -s quit

3.error.log等日志文件删除后,需要reload才会自动生成新的对应文件

4.不同二级域名绑定不同目录
分别创建web.site.com.conf和admin.site.com.conf配置文件,以及web和admin页面目录,在nginx.conf中引入,并将server的配置放入两个子文件中

include 'web.site.com.conf';
include 'admin.site.com.conf';

子文件web.site.com.conf,设置对应server_name和root

listen       80;
server_name  web.site.com;
location / {
  root   html/web;
  index  index.html index.htm;
}

子文件admin.site.com.conf,设置对应server_name和root

listen       80;
server_name  admin.site.com;
location / {
  root   html/admin;
  index  index.html index.htm;
}

本地环境可以编辑/etc/hosts

127.0.0.1    web.site.com
127.0.0.1    admin.site.com