建立自启动脚本:
vim /etc/init.d/lamp
输入如下内容:
#!/bin/bash## mysql startup script for the lamp server## chkconfig: 2345 90 10# description: start the lamp with mysql deamon## Source function library. /etc/rc.d/init.d/functions #脚本名称prog=lamp#redis安装目录LAMP_HOME=/opt/lampstackexport LAMP_HOMEcase "$1" in start) echo "Starting lampstack with mysql..." $LAMP_HOME/ctlscript.sh start ;; stop) echo "Stopping lampstack with mysql..." $LAMP_HOME/ctlscript.sh stop ;; restart) echo "Restarting lampstack with mysql..." $LAMP_HOME/ctlscript.sh restart ;; *) echo "Usage: $prog {start|stop|restart}" ;;esacexit 0
修改文件为可运行文件:
chmod a+x lamp
查看lamp开机启动情况:
chkconfig --list
如没有,则添加到系统启动队列中:
chkconfig --add lamp
重新检查lamp开机启动情况,若成功,则应显示如下内容:
lamp 0:off 1:off 2:on 3:on 4:on 5:on 6:off
使用下列命令对lamp进行重启、停止、启动:
service lamp restart/stop/start