Linux下nginx重启命令

发布时间:2019-10-12编辑:脚本学堂
分享下linux系统下nginx启动与重启的方法,有需要的朋友参考下。

linux系统中,nginx启动命令:
 

复制代码 代码示例:
/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf

说明:
-c制定配置文件的路径,不加-nginx会自动加载默认路径的配置文件。

对于有以下命令的nginx可以使用,没有以下命令的nginx,可以上面的方法。
nginx命令中的-s参数可对nginx服务进行管理:
 

复制代码 代码示例:
# /usr/local/nginx/sbin/nginx -h
nginx version: nginx/0.7.63
Usage: nginx [-?hvVt] [-s signal] [-c filename] [-p prefix] [-g directives]
Options:
-?,-h : this help
-v : show version and exit
-V : show version and configure options then exit
-t : test configuration and exit
-s signal : send signal to a master process: stop, quit, reopen, reload
-p prefix : set prefix path (default: /usr/local/nginx/)
-c filename : set configuration file (default: conf/nginx.conf)
-g directives : set global directives out of configuration file

于是执行:
# /usr/local/nginx/sbin/nginx -s  reload
nginx重启成功,此类重启中重新读取并加载配置文件,也是一次重启。