首页 技术 正文
技术 2022年11月9日
0 收藏 495 点赞 2,164 浏览 1865 个字

1、下载tomcat安装包

从tomcat官方网站http://tomcat.apache.org下载安装包,然后解压到某个目录,比如: ~/opt/apache-tomcat-7.0.63
官方文档中建议不要使用各个Linux发行版中已经打好的安装包,因为各个发行版中的安装包将tomcat安装到不同的位置,所以建议不要使用源里的tomcat。
$tar xzvf apache-tomcat-7.0.63.tar.gz -C ~/opt

2、监听80端口

修改tomcat安装目录下conf目录下的server.xml
$cd ~/opt/apache-tomcat-7.0.63/conf
$vim server.xml

<Connector port=”80″…>

3、增加用户

修改tomcat7安装目录下conf目录下的tomcat-users.xml文件
$cd ~/opt/apache-tomcat-7.0.63/conf
$vim tomcat-user.xml

<role rolename=”admin-gui”/>
<role rolename=”manager-gui”/>
<user username=”admin” password=”1234″ roles=”admin-gui”/>
<user username=”manager” password=”1234″ roles=”manager-gui”/>

4、设置工作目录

Tomcat下的web程序默认目录为$TOMCAT_INSTALL_DIR/webapps,只要将自己的web程序目录放置到该目录下就可,但用户通常需要设置自己的工作目录。两种方法:

1)通过Context的docBase变量设置
$vim $TOMCAT_INSTALL_DIR/conf/Catalina/localhost/mywebapp.xml
<Context path=”/mywebapp” docBase=”~/working/project/program/webapps/mywebapp” reloadable=”true”/>
注意:web应用程序如果是在默认目录下,则会被tomcat自动加载,因此不需要使用Context的docBase属性来指定web程序的根目录;tomcat 5.5以后的版本,path变量可以不用设置,tomcat根据文件名来确定路径,例如:文件名为mywebapp.xml, 则路径为/mywebapp

2)软链接
$cd $TOMCAT_INSTALL_DIR/webapps
$ln -s ~/working/project/program/webapps/mywebapp mywebapp

5、安装Tomcat为随系统启动的服务

1) 在$TOMCAT_INSTALL_DIR/bin/setenv.sh脚本中设置JAVA_HOME环境变量
$vim $TOMCAT_INSTALL_DIR/bin/setenv.sh

#!/bin/sh

JAVA_HOME=/usr/lib/jvm/java-7-openjdk-i386

2)拷贝$TOMCAT_INSTALL_DIR/bin/catalina.sh到/etc/init.d目录下,并在脚本开头加入LSB的设置信息、tomcat安装位置环境变量设置:
$sudo cp catalina.sh /etc/init.d/tomcat
$sudo vim /etc/init.d/tomcat

### BEGIN INIT INFO
# Provides: apache-tomcat
# Required-Start: $all
# Required-Stop:
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Run /etc/rc.local if it exist
### END INIT INFO

CATALINA_HOME=”/home/cb/opt/apache-tomcat-7.0.63″
cd $CATALINA_HOME/bin

3)安装服务
$sudo update-rc.d -f tomcat defaults

4)启动/停止服务
$sudo service tomcat start
$sudo service tomcat stop

6、测试

$sudo service tomcat start

然后,打开浏览器,输入: http://localhost

以上在Ubuntu Kylin 14.04下测试通过。

=-=-=-=-=
Powered by Blogilo

相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:9,116
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,588
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,433
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,204
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:7,840
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:4,925