linux nginx的重启及相关参数

重启直接执行 [root@localhost sbin]# /usr/local/nginx/sbin/nginx 就可以了

经常需要重启 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`

猜你喜欢

转载自sinykk.iteye.com/blog/919348
今日推荐