Tomcat设置开机自动启动:
[root@test ~]# vi /etc/rc.d/init.d/tomcat
#!/bin/bash
#
#Startup script for the tomcat
#
# chkconfig: 345 80 15
# description: Tomcat is a Servlet+JSP Engine.
# Source function library.
. /etc/rc.d/init.d/functions
JAVA_HOME=/usr/jdk1.6.0_39
CATALINA_HOME=/usr/local/tomcat
export JAVA_HOME CATALINA_HOME
start(){
if [ -z $(/sbin/pidof java) ]; then
echo "Starting tomcat"
/usr/local/tomcat/bin/startup.sh
touch /var/lock/subsys/tomcat
else
echo "tomcat allready running"
fi
}
stop(){
if [ ! -z $(/sbin/pidof java) ]; then
echo "Shutting down tomcat"
/usr/local/tomcat/bin/shutdown.sh
until [ -z $(/sbin/pidof java) ]; do :; done
rm -f /var/lock/subsys/tomcat
else
echo "tomcat not running"
fi
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
stop
start
;;
status)
/usr/local/tomcat/bin/catalina.sh version
;;
*)
echo "Usage: $0 {start|stop|restart|status}"
esac
exit 0
保存退出!
[root@test ~]# chmod 755 /etc/rc.d/init.d/tomcat ← 将启动脚本属性设置为755(使之可执行)
[root@test ~]# chkconfig --add tomcat ← 将Tomcat加入到chkconfig中
[root@test ~]# chkconfig tomcat on ← 将Tomcat设置为自启动
[root@test ~]# chkconfig --list tomcat ← 确认2~5为on的状态就OK
tomcat 0:off 1:off 2:on 3:on 4:on 5:on 6:off
[root@test ~]# /etc/rc.d/init.d/tomcat start ← 启动Tomcat
apache设为linux服务
cp /usr/local/apache/bin/apachectl /etc/rc.d/init.d/httpd
vi /etc/init.d/httpd
在#!/bin/sh后面加入下面两行
#chkconfig:345 85 15
#description: Start and stops the Apache HTTP Server.
然后
chmod +x /etc/rc.d/init.d/httpd
chkconfig --add httpd
然后可以用setup命令进入服务设置,设置为开机启动
第二种方法:
在/etc/rc.d/rc.local中增加启动apache的命令,例如:/usr/local/httpd/bin/apachectl start
mysql设为linux服务
cp /usr/local/mysql5/share/mysql/mysql.server /etc/init.d/mysqld
chkconfig --add mysqld
chkconfig --level 2345 mysqld on
chown mysql:mysql -R /usr/local/mysql5/
service mysqld start
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/30633998/viewspace-2019680/,如需转载,请注明出处,否则将追究法律责任。