啟動
將配置文件設置好,然后執行相應的文件,啟動程序。
- windows
直接執行可執行文件
- 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是否運行。