nginx配置熱更新


啟動

將配置文件設置好,然后執行相應的文件,啟動程序。

  1. windows

直接執行可執行文件

  1. linux的supervisor配置(后台啟動)

/home/nginx/sbin/nginx -g 'daemon off;' -c /home/nginx/conf/nginx.conf -p /home/nginx

-s 命令

To start nginx, run the executable file. Once nginx is started, it can be controlled by invoking the executable with the -s parameter. Use the following syntax:

nginx -s signal

Where signal may be one of the following:

  • stop — fast shutdown
  • quit — graceful shutdown
  • reload — reloading the configuration file
  • reopen — reopening the log files

簡而言之,就是這些信號命令,只能在nginx啟動后才可能執行成功。

配置熱更新

先判斷nginx時候正在運行:

supervisorctl status|grep  nginx|grep RUNNING
if [ $? -eq 0 ];then
    /home/nginx/sbin/nginx -s reload -c /home/nginx/conf/nginx.conf -p /home/nginx
fi

若是nginx未運行,執行配置熱更新命令,會提示:nginx.pid不存在。這個文件中,記錄着nginx的pid。這個也可以用作判斷nginx是否運行。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM