码迷,mamicode.com
首页 > 系统相关 > 详细

linux nginx 基本用法

时间:2017-09-16 00:30:50      阅读:165      评论:0      收藏:0      [点我收藏+]

标签:基本用法   分享   pid   路径   启动命令   例子   配置文件   文件   roc   

nginx -s reload -p <nginx环境目录> -c <指定的配置文件>

其中-p -c 为可选,不写为默认路径和配置

在执行命令之前可通过

nginx -t -p<> -c<>

检查自定义的配置文件是否正确

另外nginx停止命令为

ps -ef | grep nginx

技术分享

kill -QUIT 30439<pid>

30439为图中的例子,为nginx master process的pid

再次启动命令

nginx -p<> -c<>

其中有个坑为reload命令仅支持改动配置文件,不支持更改文件,比如上图中目前运行的配置文件为nginx.conf,然后我修改这个文件再重启没问题

nginx -s reload -c conf/nginx.conf

但是如果我想换成conf/nginx.other.conf

nginx -s reload -c conf/nginx.other.conf

这是不生效的,他还是重新读取原来文件的配置

所以有多个配置文件需要切换的话,我的办法是重命名配置文件,将需要的配置文件名修改为nginx.conf

mv nginx.other.conf nginx.conf

实际中是为了蓝绿切换

切换脚本如下

case $1 in
    blue)
        if [ -f "nginx.blue.conf.bak" ]
        then
           mv nginx.conf nginx.green.conf.bak
           mv nginx.blue.conf.bak nginx.conf
           nginx -s reload -p /weblogic/nginx -c conf/nginx.conf
           echo 切换到蓝
        else
           echo 配置不存在
        fi
        ;; 
    green)
        if [ -f "nginx.green.conf.bak" ]
        then
           mv nginx.conf nginx.blue.conf.bak
           mv nginx.green.conf.bak nginx.conf
           nginx -s reload -p /weblogic/nginx -c conf/nginx.conf
           echo 切换到绿组
        else
           echo 配置不存在
        fi
        ;;
esac

切换命令为

sh cbd.sh blue/green

 

linux nginx 基本用法

标签:基本用法   分享   pid   路径   启动命令   例子   配置文件   文件   roc   

原文地址:http://www.cnblogs.com/wish5714/p/7529185.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!