2013年(6)
分类: LINUX
2013-03-21 12:06:33
原文地址:Linux Tomcat7安装配置注册服务 作者:likeilinux
[root@demo tomcat7]# pwd
/opt/tomcat7
[root@demo tomcat7]# ls
bin lib logs RELEASE-NOTES temp work
conf LICENSE NOTICE RUNNING.txt webapps
[root@demo jdk1.7.0_17]# ls
bin lib src.zip
COPYRIGHT LICENSE THIRDPARTYLICENSEREADME-JAVAFX.txt
db man THIRDPARTYLICENSEREADME.txt
include README.html
jre release
[root@demo jdk1.7.0_17]# pwd
/opt/jdk1.7.0_17
全局环境变量:
vi /etc/profile在最后添加
[root@demo etc]# tail -n 4 /etc/profile
export JAVA_HOME=/opt/jdk1.7.0_17
export CLASSPATH=.:$CLASSPATH:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export PATH=$PATH:$JAVA_HOME/bin:/opt/tomcat7/bin
export JRE_HOME=$JAVA_HOME/jre
只更改root环境变量
[root@demo ~]# vi .bash_profile
# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
# User specific environment and startup programs
PATH=$PATH:$HOME/bin
export JAVA_HOME=/opt/jdk1.7.0_17
export CLASSPATH=.:$CLASSPATH:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export PATH=$PATH:$JAVA_HOME/bin:/opt/tomcat7/bin
export JRE_HOME=$JAVA_HOME/jre
添加临时环境变量,关闭当前bash后,环境变量无效
[root@demo bin]# export JAVA_HOME=/opt/jdk1.7.0_17
[root@demo bin]# export CLASSPATH=.:$CLASSPATH:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
[root@demo bin]# export PATH=$PATH:$JAVA_HOME/bin:/opt/tomcat7/bin
[root@demo bin]# export JRE_HOME=$JAVA_HOME/jre
[root@Test init.d]# vi /etc/init.d/tomcat7
内容文末附有
[root@Test init.d]# chkconfig --add tomcat7
[root@Test init.d]# chkconfig --list |grep tomcat7
tomcat7 0:off 1:off 2:on 3:on 4:on 5:on 6:off
[root@Test init.d]# service tomcat7 restart
tomcat ( pid 9106 9144 ) is running...
Shutting down Tomcat: Using CATALINA_BASE: /opt/tomcat7
Using CATALINA_HOME: /opt/tomcat7
Using CATALINA_TMPDIR: /opt/tomcat7/temp
Using JRE_HOME: /usr
Using CLASSPATH: /opt/tomcat7/bin/bootstrap.jar:/opt/tomcat7/bin/tomcat-juli.jar
Starting Tomcat: Using CATALINA_BASE: /opt/tomcat7 [ OK ]
Using CATALINA_HOME: /opt/tomcat7
Using CATALINA_TMPDIR: /opt/tomcat7/temp
Using JRE_HOME: /usr
Using CLASSPATH: /opt/tomcat7/bin/bootstrap.jar:/opt/tomcat7/bin/tomcat-juli.jar
[ OK ]
[root@Test init.d]# service tomcat7 stop
tomcat ( pid 9192 9224 ) is running...
Shutting down Tomcat: Using CATALINA_BASE: /opt/tomcat7
Using CATALINA_HOME: /opt/tomcat7
Using CATALINA_TMPDIR: /opt/tomcat7/temp
Using JRE_HOME: /usr
Using CLASSPATH: /opt/tomcat7/bin/bootstrap.jar:/opt/tomcat7/bin/tomcat-juli.jar
[root@Test init.d]# service tomcat7 restart [ OK ]
Tomcat is stopped
Starting Tomcat: Using CATALINA_BASE: /opt/tomcat7
Using CATALINA_HOME: /opt/tomcat7
Using CATALINA_TMPDIR: /opt/tomcat7/temp
Using JRE_HOME: /usr
Using CLASSPATH: /opt/tomcat7/bin/bootstrap.jar:/opt/tomcat7/bin/tomcat-juli.jar
[ OK ]
[root@Test init.d]# service tomcat7 start
Starting Tomcat: Using CATALINA_BASE: /opt/tomcat7
Using CATALINA_HOME: /opt/tomcat7
Using CATALINA_TMPDIR: /opt/tomcat7/temp
Using JRE_HOME: /usr
Using CLASSPATH: /opt/tomcat7/bin/bootstrap.jar:/opt/tomcat7/bin/tomcat-juli.jar
[ OK ]
[root@Test init.d]#
点击(此处)折叠或打开