原文出处:http://wiki.ubuntu.org.cn/ApacheTomcat5
原文作者:UbuntuWiki
授权许可:
翻译人员:keke
校对人员:purewind
贡献者:
适用版本:Ubuntu 6.06
文章状态: 完成
This is to help people setup and install Apache Tomcat 5.
这篇文章是帮助人们配置和安装Apache Tomcat 5的。
Jakarta Tomcat, a Java servlet container is now part of the Apache family under the name of Apache Tomcat. It can be installed in Ubuntu 6.06 (Dapper Drake) following the steps below.
Jakarta Tomcat(雅加达雄猫)是一个Java servlet容器,现在它叫Apache Tomcat是Apache家族的一部分。按照以下步骤我们可以将它安装在Ubuntu 6.06 (Dapper Drake)上。
Java virtual machine Follow this link paying attention to download the JDK and not the SDK.
Java虚拟机 参考这个连接 ,注意是下载JDK不是SDK 。
Enable the universe and multiverse repositories
启用 universe 和 multiverse 软件仓库
In Ubuntu 6.06, do:
在Ubuntu 6.06中,这样做:
sudo apt-get install sun-java5-jdk
Set Java environment variables
设置Java环境变量
$ export JAVA_HOME="path of your java home" $ export PATH=$PATH:$JAVA_HOME/bin
In Ubuntu 6.06,do:
在 Ubuntu 6.06 里这样做:
export JAVA_HOME=/usr/lib/jvm/java-1.5.0-sun-1.5.0.06
You may have to change the numbers for updated versions.
您可能需要改变一下版本号来获得最新的版本。
(其实,编辑 ~/.bashrc,增加上述语句,以后每次打开不必每次都去export JAVA_HOME了)
$ sudo aptitude install tomcat5 tomcat5-admin tomcat5-webapps
Use the following command to run Apache Tomcat:
使用以下命令运行Apache Tomcat:
$ sudo /etc/init.d/tomcat5 start
To stop it, use :
停止服务器,使用:
$ sudo /etc/init.d/tomcat5 stop
Finally, to restart it, run :
最后,重启服务器,执行:
$ sudo /etc/init.d/tomcat5 restart
You can find tomcat up and running (if you have followed the previous steps) at the following ip: 127.0.0.1:8180
您会发现 tomcat 在以下ip地址上运行(如果您按照前面的步骤操作的话): 127.0.0.1:8180
译者注:就Windows下安装使用的经验来看,一般默认在8080端口工作。但是由于Linux下可能默认就装有Apache,可能已经占用了8080,因此默认是8180
If you have installed also the admin package as listed before you will be able to enter in the administation window only if you edit the file
如果您同时安装了admin包,那么在您进入管理窗口之前您需要编辑文件
$ /usr/share/tomcat5/conf/tomcat-users.xml
and add the following lines for creating new users with admin and manager privilegies as described in Tomcat's main page
根据Tomcat主页上的描述,加入下面的几行以创建一个拥有管理权限的新用户
<role rolename="manager"/> <role rolename="admin"/> <user username="YOUR USERNAME " password="YOUR PASSWORD" roles="admin,manager"/>
Obviously if you want only one kind of role you've to delete the one you are not interested in. Example only admin
很显然,如果您只想有一种角色,那么就删除那些您不感兴趣的角色,比如只有管理员角色
<role rolename="admin"/> <user username="YOUR USERNAME " password="YOUR PASSWORD" roles="admin"/>
Using the Tomcat manager included in the installed packages you'll be able to to control your servlet/jsp properly.
使用安装包中自带的Tomcat manager程序您可以很好的控制您的servlet/jsp
file://YOUR SERVLET or JSP PAGE DIRECTORY
Usually servlet/jsp pages are located in the directory /usr/share/tomcat5/webapps .
通常servlet/jsp页面都在/usr/share/tomcat5/webapps 目录下