经验首页 前端设计 程序设计 Java相关 移动开发 数据库/运维 软件/图像 大数据/云计算 其他经验
当前位置:技术经验 » 程序设计 » PHP » 查看文章
php-fpm启动,重启,退出
来源:cnblogs  作者:自由TK  时间:2019/10/8 9:31:49  对本文有异议

首先确保php-fpm正常安装,运行命令php-fpm -t输出查看:

 

##确定php-fpm配置正常
[root@iz2vcf47jzvf8dxrapolf7z php7.3.10]# /usr/local/php7.3.10/sbin/php-fpm -t
[02-Oct-201916:54:19] NOTICE: configuration file /usr/local/php7.3.10/etc/php-fpm.conf test is successful

##启动php-fpm
[root@izj6c0ct64t9oyhoeow593z php7.3.10]# ps -ef|grep php
root 1621 1603 0 09:31 pts/0 00:00:00 grep --color=auto php
[root@izj6c0ct64t9oyhoeow593z php7.3.10]# /usr/local/php7.3.10/sbin/php-fpm
[root@izj6c0ct64t9oyhoeow593z php7.3.10]# ps -ef|grep php|grep -v 'grep'
root 1626 1 0 09:32 ? 00:00:00 php-fpm: master process (/usr/local/php7.3.10/etc/php-fpm.conf)
www 1627 1626 0 09:32 ? 00:00:00 php-fpm: pool www
www 1628 1626 0 09:32 ? 00:00:00 php-fpm: pool www

##重启php-fpm(进程ID已改变)
[root@izj6c0ct64t9oyhoeow593z php7.3.10]# kill -SIGUSR2 `cat /usr/local/php7.3.10/var/run/php-fpm.pid`
[root@izj6c0ct64t9oyhoeow593z php7.3.10]# ps -ef|grep php|grep -v 'grep'
root 1651 1 0 09:36 ? 00:00:00 php-fpm: master process (/usr/local/php7.3.10/etc/php-fpm.conf)
www 1652 1651 0 09:36 ? 00:00:00 php-fpm: pool www
www 1653 1651 0 09:36 ? 00:00:00 php-fpm: pool www

##关闭php-fpm进程
[root@izj6c0ct64t9oyhoeow593z php7.3.10]# kill -SIGINT `cat /usr/local/php7.3.10/var/run/php-fpm.pid` && ps -ef|grep php|grep -v 'grep'
[root@izj6c0ct64t9oyhoeow593z php7.3.10]# ps -ef|grep fpm
root 1682 1603 0 09:41 pts/0 00:00:00 grep --color=auto fpm

      可以把上面命令配置到~/.bashrc文件或/etc/bashrc文件,以快捷方式执行命令。(注意cat两端特殊字符是`不是单引号')      

      上面SIGUASR2和SIGINT是linux信号常量,而信号是进程在运行过程中,由自身产生或由进程外部发过来的消息(事件)。
      信号是硬件中断的软件模拟(软中断)。每个信号用一个整型常量宏表示,以SIG开头,比如SIGCHLD( 子进程结束向父进程发送的一个信号 )、SIGINT(Ctrl+c)等,它们在系统头文件<signal.h>中定义,也可以通过在shell下键入kill –l查看信号列表,或者键入man 7 signal查看更详细的说明。
      信号是系统响应某些条件而产生的一个事件,接收到该信的进程做出相应的处理。通常信是由错误产生的,如段错误(SIGSEGV)。 但信还可以作为进程间通信的一种方式,由一个进程发送给另一个进程。

 

       另外有种更便捷友好地操作方式,这里用的是centos7,可以使用systemctl

[root@izj6c0ct64t9oyhoeow593z php7.3.10]# vim /usr/lib/systemd/system/php-fpm.service

Description=php-fpm
After=syslog.target network.target

[Service]
Type=forking
PIDFile=/usr/local/php7.3.10/var/run/php-fpm.pid
ExecStart=/usr/local/php7.3.10/sbin/php-fpm
ExecReload=/bin/kill -SIGUSR2 MAINPID
ExecStop=/bin/kill −SIGINT MAINPID
PrivateTmp=true

[Install]
WantedBy=multi-user.target
##让服务可用配置
[root@izj6c0ct64t9oyhoeow593z php7.3.10]# systemctl enable php-fpm
Created symlink from /etc/systemd/system/multi-user.target.wants/php-fpm.service to /usr/lib/systemd/system/php-fpm.service.

##重载system服务配置,使新增的php-pfm配置生效
[root@izj6c0ct64t9oyhoeow593z php7.3.10]# systemctl daemon-reload
##重启fpm报错
[root@izj6c0ct64t9oyhoeow593z php7.3.10]# systemctl reload php-fpm
Job for php-fpm.service invalid.
##查看错误原因,php-fpm还没启动
[root@izj6c0ct64t9oyhoeow593z php7.3.10]# systemctl status php-fpm
● php-fpm.service - php-fpm
Loaded: loaded (/usr/lib/systemd/system/php-fpm.service; disabled; vendor preset: disabled)
Active: inactive (dead)
10月 07 10:32:02 izj6c0ct64t9oyhoeow593z systemd[1]: Unit php-fpm.service cannot be reloaded because it is inactive.

##启动,没有提示(一般linux下没有输出就是正常的,就是好消息)
[root@izj6c0ct64t9oyhoeow593z php7.3.10]# systemctl start php-fpm
[root@izj6c0ct64t9oyhoeow593z php7.3.10]#

     
      信号定义在/usr/include/asm/signal.h文件中,以 SIG 作为开头,也可用 kill -l 命令查看,详细信息参见 man 7 signal

  1. [root@izj6c0ct64t9oyhoeow593z php7.3.10]# kill -l
  2. 1) SIGHUP 2) SIGINT 3) SIGQUIT 4) SIGILL 5) SIGTRAP
  3. 6) SIGABRT 7) SIGBUS 8) SIGFPE 9) SIGKILL 10) SIGUSR1
  4. 11) SIGSEGV 12) SIGUSR2 13) SIGPIPE 14) SIGALRM 15) SIGTERM
  5. 16) SIGSTKFLT 17) SIGCHLD 18) SIGCONT 19) SIGSTOP 20) SIGTSTP
  6. 21) SIGTTIN 22) SIGTTOU 23) SIGURG 24) SIGXCPU 25) SIGXFSZ
  7. 26) SIGVTALRM 27) SIGPROF 28) SIGWINCH 29) SIGIO 30) SIGPWR
  8. 31) SIGSYS 34) SIGRTMIN 35) SIGRTMIN+1 36) SIGRTMIN+2 37) SIGRTMIN+3
  9. 38) SIGRTMIN+4 39) SIGRTMIN+5 40) SIGRTMIN+6 41) SIGRTMIN+7 42) SIGRTMIN+8
  10. 43) SIGRTMIN+9 44) SIGRTMIN+10 45) SIGRTMIN+11 46) SIGRTMIN+12 47) SIGRTMIN+13
  11. 48) SIGRTMIN+14 49) SIGRTMIN+15 50) SIGRTMAX-14 51) SIGRTMAX-13 52) SIGRTMAX-12
  12. 53) SIGRTMAX-11 54) SIGRTMAX-10 55) SIGRTMAX-9 56) SIGRTMAX-8 57) SIGRTMAX-7
  13. 58) SIGRTMAX-6 59) SIGRTMAX-5 60) SIGRTMAX-4 61) SIGRTMAX-3 62) SIGRTMAX-2
  14. 63) SIGRTMAX-1 64) SIGRTMAX
  15. [root@izj6c0ct64t9oyhoeow593z php7.3.10]# cat /usr/include/asm/signal.h
  16. #ifndef _ASM_X86_SIGNAL_H
  17. #define _ASM_X86_SIGNAL_H
  18. #ifndef __ASSEMBLY__
  19. #include <linux/types.h>
  20. #include <linux/time.h>
  21. /* Avoid too many header ordering problems. */
  22. struct siginfo;
  23. /* Here we must cater to libcs that poke about in kernel headers. */
  24. #define NSIG 32
  25. typedef unsigned long sigset_t;
  26. #endif /* __ASSEMBLY__ */
  27. #define SIGHUP 1
  28. #define SIGINT 2
  29. #define SIGQUIT 3
  30. #define SIGILL 4
  31. #define SIGTRAP 5
  32. #define SIGABRT 6
  33. #define SIGIOT 6
  34. #define SIGBUS 7
  35. #define SIGFPE 8
  36. #define SIGKILL 9
  37. #define SIGUSR1 10
  38. #define SIGSEGV 11
  39. #define SIGUSR2 12
  40. #define SIGPIPE 13
  41. #define SIGALRM 14
  42. #define SIGTERM 15
  43. #define SIGSTKFLT 16
  44. #define SIGCHLD 17
  45. #define SIGCONT 18
  46. #define SIGSTOP 19
  47. #define SIGTSTP 20
  48. #define SIGTTIN 21
  49. #define SIGTTOU 22
  50. #define SIGURG 23
  51. #define SIGXCPU 24
  52. #define SIGXFSZ 25
  53. #define SIGVTALRM 26
  54. #define SIGPROF 27
  55. #define SIGWINCH 28
  56. #define SIGIO 29
  57. #define SIGPOLL SIGIO
  58. /*
  59. #define SIGLOST 29
  60. */
  61. #define SIGPWR 30
  62. #define SIGSYS 31
  63. #define SIGUNUSED 31
  64. /* These should not be considered constants from userland. */
  65. #define SIGRTMIN 32
  66. #define SIGRTMAX _NSIG
  67. /*
  68. * SA_FLAGS values:
  69. *
  70. * SA_ONSTACK indicates that a registered stack_t will be used.
  71. * SA_RESTART flag to get restarting signals (which were the default long ago)
  72. * SA_NOCLDSTOP flag to turn off SIGCHLD when children stop.
  73. * SA_RESETHAND clears the handler when the signal is delivered.
  74. * SA_NOCLDWAIT flag on SIGCHLD to inhibit zombies.
  75. * SA_NODEFER prevents the current signal from being masked in the handler.
  76. *
  77. * SA_ONESHOT and SA_NOMASK are the historical Linux names for the Single
  78. * Unix names RESETHAND and NODEFER respectively.
  79. */
  80. #define SA_NOCLDSTOP 0x00000001u
  81. #define SA_NOCLDWAIT 0x00000002u
  82. #define SA_SIGINFO 0x00000004u
  83. #define SA_ONSTACK 0x08000000u
  84. #define SA_RESTART 0x10000000u
  85. #define SA_NODEFER 0x40000000u
  86. #define SA_RESETHAND 0x80000000u
  87. #define SA_NOMASK SA_NODEFER
  88. #define SA_ONESHOT SA_RESETHAND
  89. #define SA_RESTORER 0x04000000
  90. #define MINSIGSTKSZ 2048
  91. #define SIGSTKSZ 8192
  92. #include <asm-generic/signal-defs.h>
  93. #ifndef __ASSEMBLY__
  94. /* Here we must cater to libcs that poke about in kernel headers. */
  95. #ifdef __i386__
  96. struct sigaction {
  97. union {
  98. __sighandler_t _sa_handler;
  99. void (*_sa_sigaction)(int, struct siginfo *, void *);
  100. } _u;
  101. sigset_t sa_mask;
  102. unsigned long sa_flags;
  103. void (*sa_restorer)(void);
  104. };
  105. #define sa_handler _u._sa_handler
  106. #define sa_sigaction _u._sa_sigaction
  107. #else /* __i386__ */
  108. struct sigaction {
  109. __sighandler_t sa_handler;
  110. unsigned long sa_flags;
  111. __sigrestore_t sa_restorer;
  112. sigset_t sa_mask; /* mask last for extensibility */
  113. };
  114. #endif /* !__i386__ */
  115. typedef struct sigaltstack {
  116. void *ss_sp;
  117. int ss_flags;
  118. size_t ss_size;
  119. } stack_t;
  120. #endif /* __ASSEMBLY__ */
  121. #endif /* _ASM_X86_SIGNAL_H */

原文链接:http://www.cnblogs.com/wscsq789/p/11617756.html

 友情链接:直通硅谷  点职佳  北美留学生论坛

本站QQ群:前端 618073944 | Java 606181507 | Python 626812652 | C/C++ 612253063 | 微信 634508462 | 苹果 692586424 | C#/.net 182808419 | PHP 305140648 | 运维 608723728

W3xue 的所有内容仅供测试,对任何法律问题及风险不承担任何责任。通过使用本站内容随之而来的风险与本站无关。
关于我们  |  意见建议  |  捐助我们  |  报错有奖  |  广告合作、友情链接(目前9元/月)请联系QQ:27243702 沸活量
皖ICP备17017327号-2 皖公网安备34020702000426号