(转载)一句简单命令重启nginx

(转载)http://iambin.blogbus.com/logs/62429223.html

经常需要重启nginx,但网上的很多教程都需要繁琐的启动脚本,远不如apache的重启命令那么简单。 
但研究了一下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已经重启成功

Nginx由于没有免费的控制面板支持,所以需要修改 /usr/local/nginx/conf/nginx.conf 这个文件来实现服务器性能、特性的配置。
上传下载配置文件建议使用Winscp这个工具,同样基于SSH协议,比Ftp安全。

在 http://wiki.nginx.org/NginxConfiguration 有很多配置文件的文档和例子。
默认的配置文件也不错,有以下几点需要注意:

    • 每次修改配置文件并上传后,需要测试配置文件是否正确,命令如下:
      /usr/local/nginx/sbin/nginx -t
    • 修改配置后,必须重启Nginx才能生效,Nginx进程无缝重启命令如下:
      kill -HUP `cat /usr/local/nginx/logs/nginx.pid`
原文地址:https://www.cnblogs.com/Robotke1/p/3339904.html