#!/bin/bash #停止php-fpm sudo php -v ps -ef | grep php-fpm | sed ‘$d‘ echo "..............................." ps -ef | grep nginx | sed ‘$d‘ echo ".............................." if [ -f /home/php/var/run/php-fpm.pid ] then pid=`cat /home/php/var/run/php-fpm.pid` echo "PHP-FPM ID:${pid}进程正在关闭....." sudo kill -INT $pid else echo "关闭PHP-FPM失败;该服务没有启动...." fi #停止nginx if [ -f /home/nginx/conf/nginx.pid ] then #sudo nginx -s stop pid=`cat /home/nginx/conf/nginx.pid` echo "Nginx ID:${pid}进程正在关闭......" sudo kill -INT $pid else echo "Nginx关闭失败;该服务还未启动......" fi
启动服务:
#!/bin/bash #启动php-fpm sudo php -v ps -ef | grep php-fpm | sed ‘$d‘ echo "..............................." ps -ef | grep nginx | sed ‘$d‘ echo ".............................." #启动进程 showpro(){ if [ -f /home/php/var/run/php-fpm.pid ] then pid=`cat /home/php/var/run/php-fpm.pid` echo "PHP-FPM ID:${pid}进程已经启动....." else sudo php-fpm echo "启动PHP-FPM进程..................." fi #启动nginx if [ -f /home/nginx/conf/nginx.pid ] then #sudo nginx -s stop pid=`cat /home/nginx/conf/nginx.pid` echo "Nginx ID:${pid}进程已经启动......" else sudo nginx echo "启动Nginx进程....................." fi } showpro #再次执行运行 showpro