php-fpm启动,重启,退出
首先确保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
[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
命令查看,详细信息参见 。
[root@izj6c0ct64t9oyhoeow593z php7.3.10]# kill -l 1) sighup 2) sigint 3) sigquit 4) sigill 5) sigtrap 6) sigabrt 7) sigbus 8) sigfpe 9) sigkill 10) sigusr1 11) sigsegv 12) sigusr2 13) sigpipe 14) sigalrm 15) sigterm 16) sigstkflt 17) sigchld 18) sigcont 19) sigstop 20) sigtstp 21) sigttin 22) sigttou 23) sigurg 24) sigxcpu 25) sigxfsz 26) sigvtalrm 27) sigprof 28) sigwinch 29) sigio 30) sigpwr 31) sigsys 34) sigrtmin 35) sigrtmin+1 36) sigrtmin+2 37) sigrtmin+3 38) sigrtmin+4 39) sigrtmin+5 40) sigrtmin+6 41) sigrtmin+7 42) sigrtmin+8 43) sigrtmin+9 44) sigrtmin+10 45) sigrtmin+11 46) sigrtmin+12 47) sigrtmin+13 48) sigrtmin+14 49) sigrtmin+15 50) sigrtmax-14 51) sigrtmax-13 52) sigrtmax-12 53) sigrtmax-11 54) sigrtmax-10 55) sigrtmax-9 56) sigrtmax-8 57) sigrtmax-7 58) sigrtmax-6 59) sigrtmax-5 60) sigrtmax-4 61) sigrtmax-3 62) sigrtmax-2 63) sigrtmax-1 64) sigrtmax [root@izj6c0ct64t9oyhoeow593z php7.3.10]# cat /usr/include/asm/signal.h #ifndef _asm_x86_signal_h #define _asm_x86_signal_h #ifndef __assembly__ #include <linux/types.h> #include <linux/time.h> /* avoid too many header ordering problems. */ struct siginfo; /* here we must cater to libcs that poke about in kernel headers. */ #define nsig 32 typedef unsigned long sigset_t; #endif /* __assembly__ */ #define sighup 1 #define sigint 2 #define sigquit 3 #define sigill 4 #define sigtrap 5 #define sigabrt 6 #define sigiot 6 #define sigbus 7 #define sigfpe 8 #define sigkill 9 #define sigusr1 10 #define sigsegv 11 #define sigusr2 12 #define sigpipe 13 #define sigalrm 14 #define sigterm 15 #define sigstkflt 16 #define sigchld 17 #define sigcont 18 #define sigstop 19 #define sigtstp 20 #define sigttin 21 #define sigttou 22 #define sigurg 23 #define sigxcpu 24 #define sigxfsz 25 #define sigvtalrm 26 #define sigprof 27 #define sigwinch 28 #define sigio 29 #define sigpoll sigio /* #define siglost 29 */ #define sigpwr 30 #define sigsys 31 #define sigunused 31 /* these should not be considered constants from userland. */ #define sigrtmin 32 #define sigrtmax _nsig /* * sa_flags values: * * sa_onstack indicates that a registered stack_t will be used. * sa_restart flag to get restarting signals (which were the default long ago) * sa_nocldstop flag to turn off sigchld when children stop. * sa_resethand clears the handler when the signal is delivered. * sa_nocldwait flag on sigchld to inhibit zombies. * sa_nodefer prevents the current signal from being masked in the handler. * * sa_oneshot and sa_nomask are the historical linux names for the single * unix names resethand and nodefer respectively. */ #define sa_nocldstop 0x00000001u #define sa_nocldwait 0x00000002u #define sa_siginfo 0x00000004u #define sa_onstack 0x08000000u #define sa_restart 0x10000000u #define sa_nodefer 0x40000000u #define sa_resethand 0x80000000u #define sa_nomask sa_nodefer #define sa_oneshot sa_resethand #define sa_restorer 0x04000000 #define minsigstksz 2048 #define sigstksz 8192 #include <asm-generic/signal-defs.h> #ifndef __assembly__ /* here we must cater to libcs that poke about in kernel headers. */ #ifdef __i386__ struct sigaction { union { __sighandler_t _sa_handler; void (*_sa_sigaction)(int, struct siginfo *, void *); } _u; sigset_t sa_mask; unsigned long sa_flags; void (*sa_restorer)(void); }; #define sa_handler _u._sa_handler #define sa_sigaction _u._sa_sigaction #else /* __i386__ */ struct sigaction { __sighandler_t sa_handler; unsigned long sa_flags; __sigrestore_t sa_restorer; sigset_t sa_mask; /* mask last for extensibility */ }; #endif /* !__i386__ */ typedef struct sigaltstack { void *ss_sp; int ss_flags; size_t ss_size; } stack_t; #endif /* __assembly__ */ #endif /* _asm_x86_signal_h */