Mission Requirements: Managing/USR/LOCAL/PHP7/SBIN/PHP-FPM-C in the simplest way/usr/local/php7/etc/php.ini This command includes starting a stop restart
Using technology: Shell Scripting Chkconfig Service Management
Implementation process:
1. Create a shell script in the/ETC/INIT.D directory
vim/etc/init.d/php-fpm
2. Write script (write on the blog to manually add a lot of comments very comprehensive all Chinese comment lines deleted is the script content)
#!/bin/bash# Specify run shell# chkconfig:-85 15# Specify Run level-represents default 2345 85 and 15 for start priority and close priority value Smaller priority # processname:php-fpm# specify Service name # Define variable phpfpm=/usr/local/php7/sbin/php-fpmphpini=/usr/local/php7/etc/php.inifpmpid=$ (ps-ef | grep php-fpm | grep-v ' Color ' | Grep-v ' pts ' | awk ' {print $} ') #抓取php the-FPM process excludes rows with color and rows with PTS and fetches the second column gets the multi-column PID number start () { If [-Z ' $fpmpid]; then # If Fpmpid is empty if you determine non-empty with-n $phpfpm-C $phpini #那么就运行这条命令:/usr/local/php7/sbin/php-fpm-c/usr/local/php7/etc /php.ini fi echo ' php-fpm starting ... '}stop () { If [-Z ' $fpmpid]; then #如果fpmpid是空 exit script exit 1 fi kill-9 $fpmpid echo ' php-fpm stop ... '}restart () { stop start echo ' php-fpm Restart '}status () { ps-ef | grep-v ' Color ' | grep-v ' pts ' | grep ' php-fpm ' #查看状态打印出php-fpm ' running process} #判断参数值 based on not The same parameter values go in different branches to perform the corresponding function case "$" instart) start ; Stop) stop ;; Restart) Stop
Start ;; Status) status ; Esac
3. Give execution permission
chmod +x/etc/init.d/php-fpm
4. Join the Service
Chkconfig--add PHP-FPM
5. Final operation
Service php-fpm startservice php-fpm statusservice php-fpm restartservice php-fpm Stop
Shell's most commonly used service script