1. 下载tomcat:
#wget
2. 将tomcat放置到 /alidata/server/ 目录下
#mv apache-tomcat-7.0.54.tar.gz /alidata/server/
3. 解压缩:
tar -xvzf /alidata/server/apache-tomcat-7.0.54.tar.gz
4. 设置tomcat开机自启动,编辑/alidata/server/apache-tomcat-7.0.54/bin/startup.sh
# vi /alidata/server/apache-tomcat-7.0.54/bin/startup.sh
加入如下行:
#chkconfig: 2345 80 90
#description:tomcat auto start
#processname: tomcat
chkconfig是让tomcat以service方式运行,这行表示缺省启动的运行级别以及启动和停止的优先级,如该服务缺省不再任何运行级启动,则以 - 代替运行级别。此例在tomcat中表示脚本在运行级2、3、4、5启动,启动优先权为80,停止优先权为90。
语 法:chkconfig [--add][--del][--list][系统服务] 或 chkconfig [--level <等级代号>][系统服务][on/off/reset]
description行对服务进行描述.
5. 将tomcat加入开机自启动
# vi /etc/rc.d/rc.local
加入如下内容:
/alidata/server/apache-tomcat-7.0.54/bin/startup.sh start
执行# /alidata/server/apache-tomcat-7.0.54/bin/startup.sh 启动tomcat,
执行# /alidata/server/apache-tomcat-7.0.54/bin/shutdown.sh 关闭tomcat
tomcat默认监听8080端口,如果要修改端口,按如下步骤修改:
# vi /alidata/server/apache-tomcat-7.0.54/conf/server.xml
找到
<Connector port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" />
<Connector executor="tomcatThreadPool"
port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" />
修改为:
<Connector port="9080" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" />
<Connector executor="tomcatThreadPool"
port="9080" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" />