引用:http://blog.csdn.net/mengxiangbaidu/article/details/7020484
1.安装JDK,
2.安装,
- apt-get install tomcat7
3.tomcat7的几个目录
- /usr/share/tomcat7
- /var/lib/tomcat7/
- /etc/tomcat7
- root@coder-671T-M:/usr/share/tomcat7# tree
- .
- ├── bin
- │ ├── bootstrap.jar
- │ ├── catalina.sh
- │ ├── catalina-tasks.xml
- │ ├── configtest.sh
- │ ├── digest.sh
- │ ├── setclasspath.sh
- │ ├── shutdown.sh
- │ ├── startup.sh
- │ ├── tomcat-juli.jar -> ../../java/tomcat-juli.jar
- │ ├── tool-wrapper.sh
- │ └── version.sh
- ├── conf -> /etc/tomcat7
- ├── defaults.md5sum
- ├── defaults.template
- ├── lib
- │ ├── annotations-api.jar -> ../../java/tomcat-annotations-api-7.0.21.jar
- │ ├── catalina-ant.jar -> ../../java/catalina-ant-7.0.21.jar
- │ ├── catalina-ha.jar -> ../../java/tomcat-catalina-ha-7.0.21.jar
- │ ├── catalina.jar -> ../../java/tomcat-catalina-7.0.21.jar
- │ ├── catalina-tribes.jar -> ../../java/catalina-tribes-7.0.21.jar
- │ ├── commons-dbcp.jar -> ../../java/commons-dbcp.jar
- │ ├── commons-pool.jar -> ../../java/commons-pool.jar
- │ ├── el-api.jar -> ../../java/tomcat-el-api-2.2.jar
- │ ├── jasper-el.jar -> ../../java/tomcat-jasper-el-7.0.21.jar
- │ ├── jasper.jar -> ../../java/tomcat-jasper-7.0.21.jar
- │ ├── jsp-api.jar -> ../../java/tomcat-jsp-api-2.2.jar
- │ ├── servlet-api.jar -> ../../java/tomcat-servlet-api-3.0.jar
- │ ├── tomcat-api.jar -> ../../java/tomcat-api-7.0.21.jar
- │ ├── tomcat-coyote.jar -> ../../java/tomcat-coyote-7.0.21.jar
- │ ├── tomcat-i18n-es.jar -> ../../java/tomcat-i18n-es-7.0.21.jar
- │ ├── tomcat-i18n-fr.jar -> ../../java/tomcat-i18n-fr-7.0.21.jar
- │ ├── tomcat-i18n-ja.jar -> ../../java/tomcat-i18n-ja-7.0.21.jar
- │ └── tomcat-util.jar -> ../../java/tomcat-util-7.0.21.jar
- ├── logs -> /var/lib/tomcat7
- └── webapps
- 5 directories, 31 files
- root@coder-671T-M:/var/lib/tomcat7# tree
- .
- ├── catalina.2011-11-28.log
- ├── catalina.out
- ├── common
- │ └── classes
- ├── conf -> /etc/tomcat7
- ├── localhost.2011-11-28.log
- ├── localhost_access_log.2011-11-28.txt
- ├── logs -> ../../log/tomcat7
- ├── server
- │ └── classes
- ├── shared
- │ └── classes
- ├── webapps
- │ ├── index.html
- │ └── ROOT
- │ ├── index.html
- │ └── META-INF
- │ └── context.xml
- └── work -> ../../cache/tomcat7
- 12 directories, 7 files
- root@coder-671T-M:/etc/tomcat7# tree
- .
- ├── Catalina
- │ └── localhost
- ├── catalina.properties
- ├── context.xml
- ├── logging.properties
- ├── policy.d
- │ ├── 01system.policy
- │ ├── 02debian.policy
- │ ├── 03catalina.policy
- │ ├── 04webapps.policy
- │ └── 50local.policy
- ├── server.xml
- ├── tomcat-users.xml
- └── web.xml
- 3 directories, 11 files
4. tomcat7的几个命令
- root@coder-671T-M:/var/lib/tomcat7# /etc/init.d/tomcat7 start
- * Starting Tomcat servlet engine tomcat7 [ OK ]
- root@coder-671T-M:/var/lib/tomcat7# /etc/init.d/tomcat7 restart
- * Stopping Tomcat servlet engine tomcat7 [ OK ]
- * Starting Tomcat servlet engine tomcat7 [ OK ]
- root@coder-671T-M:/var/lib/tomcat7# /etc/init.d/tomcat7 stop
- * Stopping Tomcat servlet engine tomcat7 [ OK ]
- root@coder-671T-M:/var/lib/tomcat7# /etc/init.d/tomcat7 start
- * Starting Tomcat servlet engine tomcat7 [ OK ]
- root@coder-671T-M:/var/lib/tomcat7#
- /usr/share/tomcat7# /usr/share/tomcat7/bin/shutdown.sh
- /usr/share/tomcat7# /usr/share/tomcat7/bin/startup.sh
5.tomcat的网站目录,默认是
- root@coder-671T-M:/usr/share/tomcat7-root# ll
- 总用量 20
- drwxr-xr-x 3 root root 4096 2011-11-28 15:35 ./
- drwxr-xr-x 409 root root 12288 2011-11-28 15:35 ../
- drwxr-xr-x 3 root root 4096 2011-11-28 15:35 default_root/
- root@coder-671T-M:/usr/share/tomcat7-root# tree
- .
- └── default_root
- ├── index.html
- └── META-INF
- └── context.xml
- 2 directories, 2 files
- root@coder-671T-M:/usr/share/tomcat7-root#
而不是webapps
6.修改tomcat的访问端口为80
(1)更改/etc/tomcat7/server.xml中的
<Connector port="80" protocol="HTTP/1.1" connectionTimeout="20000" URIEncoding="UTF-8" redirectPort="8443" />
(2)从ubuntu10.04起,默认是关闭1024一下的端口.需要手工打开,可以到编辑/etc/default/tomcat7中的最后一行AUTHBIND=yes来实现
默认是#AUTHBIND=no
具体操作步骤如下:
-、sudo vi /etc/tomcat7/server.xml,修改为port="80"
-、sudo vi /etc/default/tomcat7 ,修改为AUTHBIND=yes
-、sudo /etc/init.d/tomcat7 restart,进行重新启动
-、netstat -ant,查看80端口是否起来