概述
#!/bin/bash
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
export PATH#Check if user is root
if [ $(id -u) != "0"]; thenprintf "Error: You must be root to run this script!n"
exit 1fiprintf "=========================================================================n"
printf "Manager for LNMP V0.8 , Written by Licess n"
printf "=========================================================================n"
printf "LNMP is a tool to auto-compile & install Nginx+MySQL+PHP on Linux n"
printf "This script is a tool to Manage status of lnmp n"
printf "For more information please visit http://www.lnmp.org n"
printf "n"
printf "Usage: /root/lnmp {start|stop|reload|restart|kill|status}n"
printf "=========================================================================n"NGINXNAME=nginx
NGINXCONFIGFILE=/usr/local/nginx/conf/$NGINXNAME.conf
NGINXPIDFILE=/usr/local/nginx/logs/$NGINXNAME.pid
NGINXDAEMON=/usr/local/nginx/sbin/$NGINXNAMEPHPFPMNAME=php-fpm
PHPFPMCONFIGFILE=/usr/local/php/etc/$PHPFPMNAME.conf
PHPFPMPIDFILE=/usr/local/php/logs/$PHPFPMNAME.pid
PHPFPMDAEMON=/usr/local/php/sbin/$PHPFPMNAMEHOSTNAME=`hostname`
MYSQLPIDFILE=/usr/local/mysql/var/$HOSTNAME.pid
function_start()
{printf "Starting LNMP...n"
if [ -f $NGINXPIDFILE]; thenprintf "Nginx is runing!n"
exit 1
else
$NGINXDAEMON -c $NGINXCONFIGFILE
printf "Nginx start successfully!n"fiif [ -f $PHPFPMPIDFILE]; thenprintf "php-fpm is runing!n"
else
$PHPFPMDAEMONstartprintf "PHP-FPM start successfully!n"fiif [ -f $MYSQLPIDFILE]; thenprintf "MySQL is runing!n"
else
/etc/init.d/mysqlstartprintf "MySQL start successfully!n"fi
}
function_stop()
{printf "Stoping LNMP...n"
if [ -f $NGINXPIDFILE]; then
kill `cat$NGINXPIDFILE`printf "Nginx program is stopn"
else
printf "Nginx program is not runing!n"fiif [ -f $PHPFPMPIDFILE]; then$PHPFPMDAEMONstopprintf "PHP-FPM program is stopn"
else
printf "PHP-FPM program is not runing!n"fiif [ -f $MYSQLPIDFILE]; then/etc/init.d/mysqlstopprintf "MySQL program is stopn"
else
printf "MySQL program is not runing!n"fi
}
function_reload()
{printf "Reload LNMP...n"
printf "Reload Nginx configure...n"
$NGINXDAEMON -t$NGINXDAEMON -s reloadprintf "Nginx program is reloding!n"
/etc/init.d/mysqlreload$PHPFPMDAEMONreload
}
function_restart()
{printf "Reload LNMP...n"
printf "Reload Nginx configure...n"
$NGINXDAEMON -t
kill `cat$NGINXPIDFILE`$NGINXDAEMON -c $NGINXCONFIGFILE
printf "Nginx program is restarting!n"
/etc/init.d/mysqlrestart$PHPFPMDAEMONrestart
}
function_kill()
{
kill `cat$NGINXPIDFILE`
kill `cat$PHPFPMPIDFILE`
kill `cat$MYSQLPIDFILE`
}
function_status()
{if [ -f $NGINXPIDFILE]; thenprintf "Nginx is runing!n"
else
printf "Nginx is stop!n"fiif [ -f $PHPFPMPIDFILE]; thenprintf "php-fpm is runing!n"
else
printf "php-fpm is stop!n"fi/etc/init.d/mysqlstatus
}case "$1"in
start)
function_start
;;
stop)
function_stop
;;
restart)
function_stop
function_start
;;
reload)
function_reload
;;
kill)
function_kill
;;
status)
function_status
;;*)printf "Usage: /root/lnmp {start|stop|reload|restart|kill|status}n"esacexit
最后
以上就是呆萌黑夜为你收集整理的lnmp mysql自动启动脚本_lnmp启动脚本的全部内容,希望文章能够帮你解决lnmp mysql自动启动脚本_lnmp启动脚本所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
发表评论 取消回复