admin 管理员组文章数量: 887021
2024年1月22日发(作者:新闻类网站宣传h5模板)
Linux下安装配置tomcat
1、 安装
Tomcat版本:6.0.29
Linux版本:Radhat Enterprise 5.5
Jdk版本:1.6.0_20
解压缩tomcat
#tar –
安装jdk
#rpm –
创建用户和组并设置目录权限
[root@centos data]#useradd tomcat
[root@centos data]# groupadd tomcat
[root@centos data]# chown -R tomcat:tomcat apache-tomcat-6.0.32
2、 设置
1)、设置路经
使用命令编辑vi /etc/profile,在文件中加入如下几行
JAVA_HOME=/usr/java/jdk1.6.0_20
CLASS_PATH=$JAVA_HOME/lib:$JAVA_HOME/jre/lib:$JAVA_HOME/lib/:$CLASS_PATH
PATH=$JAVA_HOME/bin:$PATH
TOMCAT_HOME=/opt/apache-tomcat-6.0.32
CATALINA_HOME=$TOMCAT_HOME
PATH=$TOMCAT_HOME/bin:$PATH
export PATH USER LOGNAME MAIL HOSTNAME HISTSIZE INPUTRC CLASS_PATH
JAVA_HOME TOMCAT_HOME CATALINA_HOME
到/opt/apache-tomcat-6.0.32/conf下,把以下几句加入和两个文件
JAVA_HOME=/usr/java/jdk1.6.0_20
CLASS_PATH=$JAVA_HOME/lib:$JAVA_HOME/jre/lib:$JAVA_HOME/lib/:$CLASS_PATH
PATH=$JAVA_HOME/bin:$PATH
TOMCAT_HOME=/opt/apache-tomcat-6.0.32
CATALINA_HOME=$TOMCAT_HOME
PATH=$TOMCAT_HOME/bin:$PATH
export PATH USER LOGNAME MAIL HOSTNAME HISTSIZE INPUTRC CLASS_PATH
JAVA_HOME TOMCAT_HOME CATALINA_HOME
2)、设置IP和Port
Tomcat缺省的Port number是8080.打开文件tomcat/conf/,找到如下的字段:
“ 然后把8080改成80即可. connectionTimeout="20000" redirectPort="8443" address="192.168.89.15" /> 3)、设置Tomcat管理用户 [root@linux5 conf]# vi 3、 启动tomcat 重启电脑后启动tomcat: [root@linux5 bin]# pwd /opt/apache-tomcat-6.0.32/bin [root@linux5 bin]# ./ Using CATALINA_BASE: /opt/apache-tomcat-6.0.32 Using CATALINA_HOME: /opt/apache-tomcat-6.0.32 Using CATALINA_TMPDIR: /opt/apache-tomcat-6.0.32/temp Using JRE_HOME: /usr Using CLASSPATH: /opt/apache-tomcat-6.0.32/bin/ 关闭tomcat: [root@linux5 bin]# ./ Using CATALINA_BASE: /opt/apache-tomcat-6.0.32 Using CATALINA_HOME: /opt/apache-tomcat-6.0.32 Using CATALINA_TMPDIR: /opt/apache-tomcat-6.0.32/temp Using JRE_HOME: /usr/java/jdk1.6.0_20 Using CLASSPATH: /opt/apache-tomcat-6.0.32/bin/ [root@linux5 ~]#cd /etc/rc.d/init.d/ [root@linux5 init.d]# vi tomcat 以下为启动脚本内容 4、 开机自动启动tomcat设置 # !/bin/sh # chkconfig: 345 90 11 # description: Starts and stops Tomcat (running as root) TOMCAT_BIN=/data/apache-tomcat-6.0.32/bin TOMCAT_USER=root RETVAL=0 start() { stop su - $TOMCAT_USER -c $TOMCAT_BIN/ sleep 10 ifnetstat -an | grep -w 80 >/dev/null then echo "Tomcat is running" return 0 else return 1 fi } stop() { ifnetstat -an | grep -w 80 | grep LISTEN >/dev/null then # try to shutdown the server first echo "Now Shutdown " su - $TOMCAT_USER -c $TOMCAT_BIN/ else echo "Tomcat is not running" return 0 fi ifnetstat -an | grep -w 80 | grep LISTEN then sleep 10 echo "Now kill it" ps -ef | grep java | grep $TOMCAT_USER | awk '{print "kill -9 ", $2;}' | sh fi ifnetstat -an | grep -w 80 | grep LISTEN >/dev/null then return 1 # still alive else echo "Tomcat is stopped" return 0 fi } case "$1" in start) start ;; stop) stop ;; restart) start ;; status) ifnetstat -an |grep -w 80|grep LISTEN >/dev/null then echo "Tomcat is Running" else echo "Tomcat is Not Running" fi ;; *) echo $"Usage: $0 {start|stop|restart|status}" exit 1 esac exit $RETVAL [root@linux5 init.d]#chmod 755 tomcat [root@linux5 init.d]# chkconfig --add tomcat [root@linux5 init.d]# chkconfig --level 345 tomcat on 5、 日常启动关闭 启动: [root@centos ~]#tomcat start Tomcat is not running Using CATALINA_BASE: /data/apache-tomcat-6.0.32 Using CATALINA_HOME: /data/apache-tomcat-6.0.32 Using CATALINA_TMPDIR: /data/apache-tomcat-6.0.32/temp Using JRE_HOME: /usr/java/jdk1.6.0_22 Using CLASSPATH: /data/apache-tomcat-6.0.32/bin/ Tomcat is running 关闭: [root@centos ~]# tomcat stop Now Shutdown Using CATALINA_BASE: /data/apache-tomcat-6.0.32 Using CATALINA_HOME: /data/apache-tomcat-6.0.32 Using CATALINA_TMPDIR: /data/apache-tomcat-6.0.32/temp Using JRE_HOME: /usr/java/jdk1.6.0_22 Using CLASSPATH: /data/apache-tomcat-6.0.32/bin/ tcp 0 0 :::80 LISTEN Now kill it 查看状态: [root@centos ~]# tomcat status Tomcat is Running :::*
版权声明:本文标题:Linux下安装配置tomcat 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.freenas.com.cn/free/1705916289h493683.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论