本文将tomcat安装到了/alidata/server/目录下,当然也可以安装到其他目录。

1. 下载tomcat:
#wget http://apache.fayea.com/tomcat/tomcat-7/v7.0.54/bin/apache-tomcat-7.0.54.tar.gz

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

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" />

重启Tomcat,打开浏览器访问:
阿里云Linux系统安装配置Tomcat方法-LMLPHP

05-13 10:34