1. 首页>
  2. 技术文章>
  3. nginx常用命令

nginx常用命令

3/22/22 11:44:22 AM 浏览 973 评论 0

nginx

1、启动:start nginx 默认是根据nginx.conf来启动的。

2、关闭:nginx -s stop 快速关闭nginx服务。

3、nginx -s reload 重新加载配置文件

4、alias与root的区别

root    实际访问文件路径会拼接URL中的路径

alias   实际访问文件路径不会拼接URL中的路径

示例如下:

location ^~ /sta/ {  
   alias /usr/local/nginx/html/static/;  
}

请求:http://test.com/sta/sta1.html,实际访问:/usr/local/nginx/html/static/sta1.html 文件

location ^~ /tea/ {  
   root /usr/local/nginx/html/;  
}

请求:http://test.com/tea/tea1.html,实际访问:/usr/local/nginx/html/tea/tea1.html 文件

5、测试nginx配置文件

nginx -t


网友讨论