注意: 安装Tomcat的前提是正确安装JDK.
1.首相使用ftp把Tomcat安装包上传至ftp目录.
2. 把tomcat压缩包拷贝到需要安装的目录.
# cp /home/www/ftpfile/apache-tomcat-6.0.43.zip /software/app/tomcat/
3. 进入复制的目录, 进行解压.
# cd cd /software/app/tomcat/
# unzip ./apache-tomcat-6.0.43.zip
4. 更改名称(此处可省略. 改名是为了方便).
# mv ./apache-tomcat-6.0.43 ./tomcat6
5. 修改执行权限.
# chmod -R +x ./tomcat6
6. 配置环境变量.
# vim /etc/profile
在文件末尾输入以下类容:
# use for Tomcat
export CATALINA_BASE=/software/app/tomcat/tomcat6
export CATALINA_HOME=/software/app/tomcat/tomcat6
export CATALINA_TMPDIR=/software/app/tomcat/tomcat6/temp
export JRE_HOME=$JAVA_HOME
export CLASSPATH=/software/app/tomcat/tomcat6/bin/bootstrap.jar
如图:
7. 将环境变量刷新.
# source /etc/profile
8. 尝试启动Tomcat.
# cd /software/app/tomcat/tomcat6/bin/
# ./startup.sh
启动成功. 会显示如下字样:
Using CATALINA_BASE: /software/app/tomcat/tomcat6
Using CATALINA_HOME: /software/app/tomcat/tomcat6
Using CATALINA_TMPDIR: /software/app/tomcat/tomcat6/temp
Using JRE_HOME: /home/java/jdk1.6.0_45
Using CLASSPATH: /software/app/tomcat/tomcat6/bin/bootstrap.jar
部署项目测试:
1. 把项目上传到FTP. 移动到Tomcat的webapps目录下:
# mv /home/www/ftpfile/TtcAppearance /software/app/tomcat/tomcat6/webapps/
2.配置Server.xml文件:
# vim /software/app/tomcat/tomcat6/conf/server.xml
Host节点配置:
<Host name="localhost" appBase="webapps" unpackWARs="true" autoDeploy="true">
<Context docBase="/alidata/www/19AreaStaticRenderService" path="/19AreaStaticRenderService" reloadable="true" />
<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
prefix="localhost_access_log." suffix=".txt"
pattern="%h %l %u %t "%r" %s %b" />
</Host>
<Host name="www.19area.cn" appBase="webapps" unpackWARs="true" autoDeploy="true">
<Context docBase="/alidata/www/19AreaStaticRenderService" path="/19AreaStaticRenderService" reloadable="true" />
<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
prefix="localhost_access_log." suffix=".txt"
pattern="%h %l %u %t "%r" %s %b" />
</Host>
3. 删除管理页面:
# rm -rf /software/app/tomcat/tomcat6/webapps/host-manager/
# rm -rf /software/app/tomcat/tomcat6/webapps/manager/
4. 启动项目
# ./startup.sh
注意: 如果启动了之后不能访问. 可以使用./catalina.sh run 的方式来启动. 和window的bat启动一样. 可以看启动日志. 停止也是一样.
# ./catalina.sh run
# ./catalina.sh stop
Linux启动 tomcat 慢 问题解决
打开$JAVA_PATH/jre/lib/security/java.security这个文件,找到下面的内容:
securerandom.source=file:/dev/urandom
替换成
securerandom.source=file:/dev/./urandom