自己手工安装的lamp,所以需要有个脚本来控制服务器的停止与启动。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91
| #!/bin/bash PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin export PATH
if [ $(id -u) != "0" ]; then printf "Error: You must be root to run this script!\n" exit 1 fi
HOSTNAME=`hostname` MYSQLPIDFILE=/usr/local/mysql/data/$HOSTNAME.pid APACHENAME=httpd APACHEPIDFILE=/usr/local/apache/logs/$APACHENAME.pid
function_start() { printf "Starting LAMP...\n"
/etc/init.d/httpd start
if [ -f $MYSQLPIDFILE ]; then printf "MySQL is runing!\n" else /etc/init.d/mysqld start printf "MySQL start successfully!\n" fi }
function_stop() { printf "Stoping LAMP...\n"
/etc/init.d/httpd stop
if [ -f $MYSQLPIDFILE ]; then /etc/init.d/mysqld stop printf "MySQL program is stop\n" else printf "MySQL program is not runing!\n" fi }
function_reload() { printf "Reload LAMP...\n" /etc/init.d/mysqld reload /etc/init.d/httpd restart }
function_restart() { printf "Restart LAMP...\n" /etc/init.d/mysqld restart /etc/init.d/httpd restart } function_kill() { kill `cat $APACHEPIDFILE` kill `cat $MYSQLPIDFILE` } function_status() { /etc/init.d/httpd status /etc/init.d/mysqld status }
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/lamp {start|stop|reload|restart|kill|status}\n" esac exit
|