PHP FPM start, restart, exit


First, make sure that PHP FPM is installed normally. Run the command PHP FPM – t to see the output:


##Make sure PHP FPM configuration is normal
[[email protected] 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

##Start PHP FPM
[[email protected] php7.3.10]# ps -ef|grep php
root 1621 1603 0 09:31 pts/0 00:00:00 grep –color=auto php
[[email protected] php7.3.10]# /usr/local/php7.3.10/sbin/php-fpm
[[email protected] 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

##Restart PHP FPM (process ID changed)
[[email protected] php7.3.10]# kill -SIGUSR2 `cat /usr/local/php7.3.10/var/run/`
[[email protected] 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

##Shut down the PHP FPM process
[[email protected] php7.3.10]# kill -SIGINT `cat /usr/local/php7.3.10/var/run/` && ps -ef|grep php|grep -v ‘grep’
[[email protected] php7.3.10]# ps -ef|grep fpm
root 1682 1603 0 09:41 pts/0 00:00:00 grep –color=auto fpm

You can configure the above command to ~ /. Bashrc file or / etc / bashrc file to execute the command in a shortcut. (note that the special characters at both ends of cat are ‘not single quotation marks’)

Siguasr2 and SIGINT are Linux signal constants, while signals are messages (events) generated by the process itself or sent from outside the process during the process.
Signal is software simulation of hardware interrupt(soft interrupt)) Each signal is represented by an integer constant macro, withSIG start, such asSigchld (a signal sent by the child process to the parent process)SIGINT (Ctrl + C), etc. in the system header fileDefinition in, or by using theTyping under shellkill –lView the list of signals, or typeman 7 signalSee more detailed instructions.
Signal is an event generated by the system in response to certain conditions, and the process receiving the signal makes corresponding processing. Usually a letter is generated by an error, such as a paragraph error(SIGSEGV) But a letter can also be sent from one process to another as a way of inter process communication.


In addition, there is a more convenient and friendly operation mode. Here, CentOS 7 is used, and system CTL can be used

[[email protected] php7.3.10]# vim /usr/lib/systemd/system/php-fpm.service


ExecReload=/bin/kill -SIGUSR2 MAINPID
ExecStop=/bin/kill −SIGINT MAINPID

##Make the service available
[[email protected] php7.3.10]# systemctl enable php-fpm
Created symlink from /etc/systemd/system/ to /usr/lib/systemd/system/php-fpm.service.

##Reload the system service configuration to make the new PHP PFM configuration effective
[[email protected] php7.3.10]# systemctl daemon-reload
##Restart FPM error
[[email protected] php7.3.10]# systemctl reload php-fpm
Job for php-fpm.service invalid.
##Check the cause of the error. PHP FPM has not been started yet
[[email protected] 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)
October 07 10:32:02 izj6c0ct64t9oyhoeow593z system d [1]: unit PHP fpm.service cannot be reloaded because it is inactive

##Start without prompt (it is normal if there is no output under Linux, which is good news)
[[email protected] php7.3.10]# systemctl start php-fpm
[[email protected] php7.3.10]#

The signal is defined in / usr / include / ASM / signal. HIn the file, toSIGAs a beginning, it can also be usedkill -lSee man 7 signal for details.

[[email protected] 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
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
[[email protected] php7.3.10]# cat /usr/include/asm/signal.h
#ifndef _ASM_X86_SIGNAL_H
#define _ASM_X86_SIGNAL_H

#ifndef __ASSEMBLY__

/* 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_RESTORER    0x04000000

#define MINSIGSTKSZ    2048
#define SIGSTKSZ    8192


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

Recommended Today

Building grpc service with golang

This tutorial provides a basic tutorial for go to use grpc In the tutorial you will learn how to: stay.protoA service is defined in the file. Use the protocol buffer compiler to generate client and server code. Use grpc’s go API to write a client and server for your service. Before you continue, make sure […]