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

##重啟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

[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 */


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM