nginx 服务器重启命令,关闭

  1. nginx -s reload :修改配置后重新加载生效
  2. nginx -s reopen :重新打开日志文件
  3. nginx -t -c /path/to/nginx.conf 测试nginx配置文件是否正确
  4.  
  5. 关闭nginx
  6. nginx -s stop :快速停止nginx
  7. quit :完整有序的停止nginx
  8.  
  9. 其他的停止nginx 方式:
  10. ps -ef | grep nginx
  11.  
  12. kill -QUIT 主进程号 :从容停止Nginx
  13. kill -TERM 主进程号 :快速停止Nginx
  14. pkill -9 nginx :强制停止Nginx
  15.  
  16. 启动nginx:
  17. nginx -c /path/to/nginx.conf
  18.  
  19. 平滑重启nginx
  20. kill -HUP 主进程号

nginx加入系统服务:

  1. #!/bin/sh
  2. #
  3. # nginx - this script starts and stops the nginx daemon
  4. #
  5. # chkconfig: - 85 15
  6. # description: Nginx is an HTTP(S) server, HTTP(S) reverse \
  7. # proxy and IMAP/POP3 proxy server
  8. # processname: nginx
  9. # config: /etc/nginx/nginx.conf
  10. # config: /etc/sysconfig/nginx
  11. # pidfile: /var/run/nginx.pid
  12.  
  13. # Source function library.
  14. . /etc/rc.d/init.d/functions
  15.  
  16. # Source networking configuration.
  17. . /etc/sysconfig/network
  18.  
  19. # Check that networking is up.
  20. [ "$NETWORKING" = "no" ] && exit 0
  21.  
  22. nginx="/usr/local/nginx/sbin/nginx"
  23. prog=$(basename $nginx)
  24.  
  25. NGINX_CONF_FILE="/usr/local/nginx/conf/nginx.conf"
  26.  
  27. [ -f /etc/sysconfig/nginx ] && . /etc/sysconfig/nginx
  28.  
  29. lockfile=/var/lock/subsys/nginx
  30.  
  31. start() {
  32. [ -x $nginx ] || exit 5
  33. [ -f $NGINX_CONF_FILE ] || exit 6
  34. echo -n $"Starting $prog: "
  35. daemon $nginx -c $NGINX_CONF_FILE
  36. retval=$?
  37. echo
  38. [ $retval -eq 0 ] && touch $lockfile
  39. return $retval
  40. }
  41.  
  42. stop() {
  43. echo -n $"Stopping $prog: "
  44. killproc $prog -QUIT
  45. retval=$?
  46. echo
  47. [ $retval -eq 0 ] && rm -f $lockfile
  48. return $retval
  49. killall -9 nginx
  50. }
  51.  
  52. restart() {
  53. configtest || return $?
  54. stop
  55. sleep 1
  56. start
  57. }
  58.  
  59. reload() {
  60. configtest || return $?
  61. echo -n $"Reloading $prog: "
  62. killproc $nginx -HUP
  63. RETVAL=$?
  64. echo
  65. }
  66.  
  67. force_reload() {
  68. restart
  69. }
  70.  
  71. configtest() {
  72. $nginx -t -c $NGINX_CONF_FILE
  73. }
  74.  
  75. rh_status() {
  76. status $prog
  77. }
  78.  
  79. rh_status_q() {
  80. rh_status >/dev/null 2>&1
  81. }
  82.  
  83. case "$1" in
  84. start)
  85. rh_status_q && exit 0
  86. $1
  87. ;;
  88. stop)
  89. rh_status_q || exit 0
  90. $1
  91. ;;
  92. restart|configtest)
  93. $1
  94. ;;
  95. reload)
  96. rh_status_q || exit 7
  97. $1
  98. ;;
  99. force-reload)
  100. force_reload
  101. ;;
  102. status)
  103. rh_status
  104. ;;
  105. condrestart|try-restart)
  106. rh_status_q || exit 0
  107. ;;
  108. *)
  109. echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload|configtest}"
  110. exit 2
  111. esac

nginx

[root@example ~]# cp nginx /etc/init.d/
[root@example ~]# chmod 755 /etc/init.d/nginx
[root@example ~]# chkconfig --add nginx

nginx启动、停止、无间断服务重启:

service nginx start

service nginx stop

service nginx reload

Nginx常用命令(加入系统服务)的更多相关文章

  1. 【Linux】nginx常用命令

    相关内容链接 Centos之安装Nginx及注意事项 [nginx]详细配置说明 nginx常用命令 [重新加载配置]sudo nginx -s reload [打开nginx配置]sudo vim ...

  2. Nginx系列一:正向代理和反向代理、Nginx工作原理、Nginx常用命令和升级、搭建Nginx负载均衡

    转自https://www.cnblogs.com/leeSmall/p/9351343.html 仅供个人学习 一.什么是正向代理.什么是反向代理 1. 正向代理,意思是一个位于客户端和原始服务器( ...

  3. nginx常用命令及简单配置

    nginx常用命令 nginx -c /usr/local/nginx/conf/nginx.conf 启动nginx(windows下start nginx); nginx -s quit 停止ng ...

  4. nginx常用命令汇总

    nginx基础命令: sudo nginx // 开启nginx服务器 sudo nginx -s reload // 重启nginx服务器 sudo nginx -s stop // 关闭nginx ...

  5. 记录Nginx常用命令

    在此记录下Nginx服务器常用命令(CentOS7.2.Nginx1.14.2环境) 启动Nginx:./usr/sbin/nginx Nginx检查语法:nginx -tc /etc/nginx/n ...

  6. nginx常用命令参数

    命令行参数: 常用命令: -c filename:设置配置文件. -t :不运行,而仅仅测试配置文件.nginx 将检查配置文件的语法的正确性,并尝试打开配置文件中所引用到的文件. -s :传递一个信 ...

  7. webpack、npm、nginx常用命令

    webpack命令:webpack --watch 监听变动并自动打包,简写-wwebpack -p --progress --color 压缩混淆脚本webpack -d  生成映射文件,告知那些模 ...

  8. Nginx常用命令,解决你日常运维的烦恼

    前面,跟大家简单地介绍了负载均衡和Nginx的一些基础配置(Nginx负载均衡配置实例),接下来,跟大家介绍一下Nginx的常用命令,便于日常的运维. 查看原文 停止Nginx的方法 通过之前的学习, ...

  9. linux常用命令-nginx常用命令

    1.ctrl+alt+f2切换到命令界面 2.ifconfig查看IP 或者IP ADDR(en33 inter) 3.使用putty终端进行交互式操作 4.shell:提供用户输入的命令解释器 常用 ...

  10. nginx常用命令和配置

    1.常用命令 查看版本号: ./nginx -v   启动nginx:在/usr/local/nginx/sbin 目录下执行  ./nginx   关闭nginx:在/usr/local/nginx ...

随机推荐

  1. 解决Eclipse的dropins中svn插件不能加载的问题

    在eclipse的dropins中我们将svn的插件放到里边重启我们的ecplise就能正常加载svn插件了,如下图 但是有时候我们删除了svn的项目之后有可能我们的eclipse就不能正常加载svn ...

  2. ThreadLocal使用方法

      创建一个Bean,通过不同的线程对象设置Bean属性,保证各个线程Bean对象的独立性.   /**  * Created by IntelliJ IDEA.  * User: leizhimin ...

  3. Redis 过期时间

    http://www.redis.cn/commands/expire.html 附录: Redis 过期时间 Keys的过期时间 通常Redis keys创建时没有设置相关过期时间.他们会一直存在, ...

  4. eclipse中使用jetty启动项目

    eclipse里修改 Goals值 Tomcat -Dmaven.tomcat.port=8080 tomcat:run Jetty -Djetty.port=8081 jetty:run

  5. js或jquery实现页面打印(局部打印)

    首先定义css样式:  复制代码代码如下: @media print { .noprint { display: none;color:green } }  对于不想打印的内容只用在标签中加上 cla ...

  6. php对gzip文件或者字符串解压实例参考

    要采集一个网站,目标站采用了gzip压缩传输网页,本来应该只要发送一个http头 Accept-Encoding: identity或者干脆不发送这个头等,就可以使目标站返回没有经过gzip压缩的页面 ...

  7. iframe定位获取

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  8. 用于ARM上的FFT与IFFT源代码-C语言

    /********************************************************************************* 程序名称:快速傅里叶变换(FFT) ...

  9. 在MathType中输入罗马数字的方法

    MathType作为数学公式编辑器的编辑功能非常的强大,其中包含了许许多多各种各样的数学符号,甚至标记符号也很全面.编辑公式时有时为了让公式看起来会更有条理,会进行一定的序号设置,当然也可以对公式进行 ...

  10. es6 async与await实战

    在使用js的时候,我们经常会遇到一个问题,就是我们需要等待请求返回再做下一步处理,之前的处理方式是通过ajax的success或者callback之类的方法,不过一层一层真的恶心,而且只是针对单个页面 ...