http://blog.csdn.net/Baijinwen/article/details/8506433
一:下载最新版的Tomcat
http://tomcat.apache.org/download-70.cgi 下载的是 apache-tomcat-7.0.34.tar.gz
把下载的文件放到VMware共享文件夹Share里面
二:解压缩
转到共享文件夹:#cd /mnt/hgfs/share
解压缩文件:#tar -zxvf apache-tomcat-7.0.34.tar.gz 解压后在默认文件夹/mnt/hgfs/share/apache-tomcat-7.0.34下面
三:拷贝Tomcat文件到目标文件夹
我希望我的Tomcat服务器放在usr/myserver/文件夹下面
转到usr文件夹: cd /usr
如果不存在myserver文件夹,则创建 : sudo mkdir myserver
将/mnt/hgfs/share/apache-tomcat-7.0.34拷贝到usr/myserver/文件夹下:cp -r /mnt/hgfs/share/apache-tomcat-7.0.34 /usr/myserver
转到/usr/myserver : cd /usr/myserver
列举:ls
改名:sudo mv apache-tomcat-7.0.34/ tomcat7
四:安装启动
切换到 usr/myserver/tomcat7/bin: cd /usr/myserver/tomcat7/bin
列举:ls
执行启动命令:./startup.sh 如果执行正常,则出现一下信息:
- Using CATALINA_BASE: /usr/myserver/tomcat7
- Using CATALINA_HOME: /usr/myserver/tomcat7
- Using CATALINA_TMPDIR: /usr/myserver/tomcat7/temp
- Using JRE_HOME: /usr/java/jdk1.7.0_11/jre
- Using CLASSPATH: /usr/myserver/tomcat7/bin/bootstarap.jar:/usr/myserver/tomcat7/bin/tomcat-juli.jar
- Using CATALINA_BASE: /usr/myserver/tomcat7
- Using CATALINA_HOME: /usr/myserver/tomcat7
- Using CATALINA_TMPDIR: /usr/myserver/tomcat7/temp
- Using JRE_HOME: /usr/java/jdk1.7.0_11/jre
- Using CLASSPATH: /usr/myserver/tomcat7/bin/bootstarap.jar:/usr/myserver/tomcat7/bin/tomcat-juli.jar
Using CATALINA_BASE: /usr/myserver/tomcat7
Using CATALINA_HOME: /usr/myserver/tomcat7
Using CATALINA_TMPDIR: /usr/myserver/tomcat7/temp
Using JRE_HOME: /usr/java/jdk1.7.0_11/jre
Using CLASSPATH: /usr/myserver/tomcat7/bin/bootstarap.jar:/usr/myserver/tomcat7/bin/tomcat-juli.jar
五:打开浏览器测试
打开浏览器输入:http://localhost:8080/ 配置成功,如下图:
六:如果想更改Tomcat的端口:
打开teminal终端,进入usr/myserver/tomcat7/conf/目录:cd /usr/myserver/tomcat7/conf/
先备份server.xml : cp -r ./server.xml ./server_bk.xml
编辑server.xml更改端口:gedit ./server.xml
找到如下设置项,修改你的端口:
- <Connector executor="tomcatThreadPool"
- port="8080" protocol="HTTP/1.1"
- connectionTimeout="20000"
- redirectPort="8443"/>
- <Connector executor="tomcatThreadPool"
- port="8080" protocol="HTTP/1.1"
- connectionTimeout="20000"
- redirectPort="8443"/>
<Connector executor="tomcatThreadPool"
port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443"/>
切换到 usr/myserver/tomcat7/bin: cd /usr/myserver/tomcat7/bin
启动命令:./startup.sh
七:关闭tomcat
切换到 usr/myserver/tomcat7/bin: cd /usr/myserver/tomcat7/bin
关闭命令:./shutdown.sh