ECM
ECM
总版主
总版主
  • 社区居民
  • 忠实会员
  • 原创写手
阅读:1523回复:0

Starting Tomcat on Bootup in Ubuntu

楼主#
更多 发布于:2016-09-11 14:48
I’m moving some of my operations to a Linux VPS soon so I can be as crazy with Tomcat and Java as I wanna be. The first thing to do in preparation is to make sure Tomcat fires up on server bootup.


There are two ways to go about it.


Create a tomcat.conf Upstart Script and place it in /etc/init/
Create a process named tomcat and place the script in /etc/init.d/
I started with an Upstart Script but that involves creating a new system user account, assign it to the www-data group and modify the permissions of the entire Tomcat installation to apache-tomcat:www-data. Too many potential gotchas with that, at least for me, so I went with creating a tomcat process.


Creating a process works for me because I simply download the latest Tomcat release, stick it in a utility directory and tomcat-8.x.x/bin/startup.sh to rock-n-roll. Below is my tomcat process script that goes in the Ubuntu/Mint /etc/init.d/ folder. It is based on the script from Developer’s Den. The difference here is we’re using the $CATALINA_HOME environment variable to startup and shutdown Tomcat.




# Tomcat auto-start
#
# description: Auto-starts tomcat
# processname: tomcat
# pidfile: /var/run/tomcat.pid


export JAVA_HOME=/usr/local/java/jdk1.8.0_05
export CATALINA_HOME=/ubuntuland/utils/apache-tomcat-8.0.8


case $1 in
start)
    sh $CATALINA_HOME/bin/startup.sh
    ;;
stop)
    sh $CATALINA_HOME/bin/shutdown.sh
    ;;
restart)
    sh $CATALINA_HOME/bin/shutdown.sh
    sh $CATALINA_HOME/bin/startup.sh
    ;;
esac
exit 0


# Tomcat auto-start
#
# description: Auto-starts tomcat
# processname: tomcat
# pidfile: /var/run/tomcat.pid
 
export JAVA_HOME=/usr/local/java/jdk1.8.0_05
export CATALINA_HOME=/ubuntuland/utils/apache-tomcat-8.0.8
 
case $1 in
start)
    sh $CATALINA_HOME/bin/startup.sh
    ;;
stop)
    sh $CATALINA_HOME/bin/shutdown.sh
    ;;
restart)
    sh $CATALINA_HOME/bin/shutdown.sh
    sh $CATALINA_HOME/bin/startup.sh
    ;;
esac
exit 0
After creating the script, complete the Developer’s Den post instructions on making the tomcat script executable and creating a symbolic link to the startup folders.


sudo chmod 755 /etc/init.d/tomcat
sudo ln -s /etc/init.d/tomcat /etc/rc1.d/K99tomcat
sudo ln -s /etc/init.d/tomcat /etc/rc2.d/S99tomcat


Now you’re ready to go Tomcat and Java crazy on your new VPS Host just like me!

 

 

 

 

 

 

 

异常中心网是一家专门收集整理程序员编程过程中遇到的常见异常(exception)以及各种异常问答中心的网站。异常中心网旨在,减少程序员在编码遇到异常,处理各种异常时间和痛苦,让程序员能更愉快的、快速的定位异常并查找对应的异常解决方案。异常中心网诚心打造最完美的编程社区为程序员用户服务,努力成为最好的程序员乐园程序员社区程序异常中心程序bug中心异常问答中心

 

喜欢0 评分0
游客

返回顶部