Nginx start stop php 5.3.18 in PHP-FPM boot shutdown configured as service startup
From the beginning of the php5.3.3 source to include PHP-FPM, do not have to hit the patch, just to unlock the source code directly configure,
The compilation parameters about PHP-FPM have –enable-fpm–with-fpm-user=www–with-fpm-group=www–with-libevent-dir=libevent locations.
This php-fpm no longer supports commands such as the/USR/LOCAL/PHP/SBIN/PHP-FPM (start|stop|reload) of the PHP-FPM patch and requires the use of signal control:
The master process can understand the following signals
SIGINT, SIGTERM immediately terminate.
Sigquit Smooth Termination
SIGUSR1 Reopen log file
SIGUSR2 smoothly overloads all worker processes and reloads the configuration and binary modules
Example:
PHP-FPM off:
Kill-sigint ' Cat/usr/local/php/var/run/php-fpm.pid '
PHP-FPM Restart:
KILL-SIGUSR2 ' Cat/usr/local/php/var/run/php-fpm.pid '
Second, the configuration file is no longer used in the XML format, changed to INI, but the configuration parameters almost as before, can be referenced in the format of XML format configuration.
—————-supplemental content in PHP 5.3.6 php-fpm configured as a service startup —————-
Cp-f/TOOLS/PHP-5.3.6/SAPI/FPM/INIT.D.PHP-FPM/ETC/INIT.D/PHP-FPM
PHP-FPM Start-up:
# #vim/usr/local/webserver/php/etc/php-fpm.conf
The Php-fpm.pid directory must be:/usr/local/webserver/php/var/run/php-fpm.pid
chmod 755/etc/init.d/php-fpm
/ETC/INIT.D/PHP-FPM start
/sbin/chkconfig--add php-fpm (Add to boot Service list)
/sbin/chkconfig PHP-FPM on
PHP-FPM start, stop, and restart:
/ETC/INIT.D/PHP-FPM start
/ETC/INIT.D/PHP-FPM stop
/ETC/INIT.D/PHP-FPM Reload
The start effect is as follows:
Hai_isd_7_9_cent56_64:/usr/local/webserver/php/etc#service php-fpm Start
Starting php-fpm Done
Hai_isd_7_9_cent56_64:/usr/local/webserver/php/etc#service php-fpm Stop
Gracefully shutting down php-fpm. Done
Hai_isd_7_9_cent56_64:/usr/local/webserver/php/etc#service php-fpm Start
Starting php-fpm Done
Hai_isd_7_9_cent56_64:/usr/local/webserver/php/etc#service PHP-FPM Reload
Reload Service PHP-FPM Done
The path involved in Nginx is best to use absolute path
1. Nginx Startup (the nginx.conf file is basically located in the Conf directory in the Nginx home directory)
Nginx-c nginx.conf
2. Nginx Stop (the Nginx.pid file is basically located in the logs directory in the Nginx home directory)
Ps-ef | grep Nginx, can find a number of nginx process, which is marked master process, the other is a child process, the main stop Nginx is the main process of signal control.
1). Calmly stop
Kill-quit ' Cat nginx.pid '
2). Quick Stop
Kill-term ' Cat nginx.pid '
Or
Kill-int ' Cat nginx.pid '
3). Force stop
Kill-9 ' Cat nginx.pid '
3. Smooth restart of Nginx
First, verify that the new configuration file is correct: nginc-t-C nginx.conf, sending the HUP signal to the main process after success: Kill-hup ' Cat nginx.pid '
4. Nginx's Smooth Upgrade
1) Back up the old executable file and replace the old version with the new version
2) KILL-USR2 The old version of the main process PID to smooth upgrade, at this time the new and old version coexistence
3) Kill-winch Old master process PID to gradually shut down the work process of the old main process
4) When the worker process generated by the old master process is closed, you can decide whether to use the new version or the old version. (You need to use the KILL command to kill the new or old master process)
#!/bin/sh
Base_dir= '/usr/local/'
${base_dir}nginx/sbin/nginx-t-C ${base_dir}nginx/conf/nginx.conf >& ${base_dir}nginx/logs/nginx.start
Info= ' Cat ${base_dir}nginx/logs/nginx.start '
If [' Echo $info | grep-c "syntax is OK" '-eq 1]; Then
If [' PS aux|grep ' nginx "|grep-c" "master" ' = = 1]; Then
Kill-hup ' Cat ${base_dir}nginx/logs/nginx.pid '
echo "OK"
Else
Killall-9 Nginx
Sleep 1
${base_dir}nginx/sbin/nginx
Fi
Else
echo "######## Error: ########"
Cat ${base_dir}nginx/logs/nginx.start
Fi