Linux之tomcat服务器基本使用(Linux带着小弟shell去打怪)

说明:此博文为,tomcat服务器复习笔记。此博文分享在复习过程中,实战遇到的问题,具体的细节和术语准确度别纠结。

在这里插入图片描述

author:拈花为何不一笑

===>>>> tomcat服务器安装及管理

tips: jdk1.6开始支持tomcat7, tomcat是java编写的一个软件,它要依赖于JDK。

===>>>> 1 tomcat服务器查询

find / -name *tomcat*	#查询tomcat安装路径
rpm -qa|grep tomcat		#查询是否使用rpm安装了tomcat

说明:whereis 和which 不能完成判断是否安装了某个程序,
	比如tomcat,可以用rpm -qa|grep tomcat来判断
 查询一个程序是否被安装,建议使用yum,rpm 然后再结合whereis ,which等命令来查询,这样会更准确一些。

===>>>> 2 tomcat服务器卸载(低版本卸载或卸载Centos6.0自带的tomcat6)

[root@jtxdsh-129 bin]# rpm -qa|grep tomcat	#查询tomcat是否通过rpm安装过
apache-tomcat-apis-0.1-1.el6.noarch
jakarta-commons-dbcp-tomcat5-1.2.1-13.8.el6.noarch
tomcat6-jsp-2.1-api-6.0.24-15.el6.noarch
tomcat6-servlet-2.5-api-6.0.24-15.el6.noarch
tomcat6-el-2.1-api-6.0.24-15.el6.noarch
tomcat6-lib-6.0.24-15.el6.noarch
jakarta-commons-pool-tomcat5-1.3-12.7.el6.i686
tomcat6-6.0.24-15.el6.noarch
[root@jtxdsh-129 bin]# rpm -e `rpm -qa|grep tomcat`	#卸载tomcat,报错要求依赖性,那么可以使用yum来解决。
error: Failed dependencies:
		apache-tomcat-apis is needed by (installed) hsqldb-1:1.8.0.10-8.el6.i686
		apache-tomcat-apis is needed by (installed) apache-jasper-5.5.28-3.el6.noarch
		apache-tomcat-apis is needed by (installed) geronimo-specs-0:1.0-3.4.M2.el6.noarch
		apache-tomcat-apis is needed by (installed) jetty-eclipse-6.1.21-1.el6.noarch
		apache-tomcat-apis is needed by (installed) eclipse-platform-1:3.5.2-5.el6.i686

[root@jtxdsh-129 bin]# yum remove tomcat6	#yum卸载tomcat6
Loaded plugins: fastestmirror, refresh-packagekit
Setting up Remove Process
Resolving Dependencies
--> Running transaction check
---> Package tomcat6.noarch 0:6.0.24-15.el6 will be erased
--> Finished Dependency Resolution

Dependencies Resolved

========================================================================================================================================================================
 Package                        Arch                          Version                               Repository                                                     Size
========================================================================================================================================================================
Removing:
 tomcat6                        noarch                        6.0.24-15.el6                         @anaconda-centos-201106051823.i386/6.0                        190 k

Transaction Summary
========================================================================================================================================================================
Remove        1 Package(s)

Installed size: 190 k
Is this ok [y/N]: y		#卸载tomcat6还要安装它的依赖,输入y
Downloading Packages:
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Warning: RPMDB altered outside of yum.
** Found 7 pre-existing rpmdb problem(s), 'yum check' output follows:
akonadi-1.2.1-2.el6.i686 has missing requires of mysql-server
akonadi-1.2.1-2.el6.i686 has missing requires of qt4-mysql
2:postfix-2.6.6-2.el6.i686 has missing requires of libmysqlclient.so.16
2:postfix-2.6.6-2.el6.i686 has missing requires of libmysqlclient.so.16(libmysqlclient_16)
2:postfix-2.6.6-2.el6.i686 has missing requires of mysql-libs
redland-1.0.7-11.el6.i686 has missing requires of libmysqlclient.so.16
redland-1.0.7-11.el6.i686 has missing requires of libmysqlclient.so.16(libmysqlclient_16)
  Erasing    : tomcat6-6.0.24-15.el6.noarch                                                                                                                         1/1
  Verifying  : tomcat6-6.0.24-15.el6.noarch                                                                                                                         1/1

Removed:
  tomcat6.noarch 0:6.0.24-15.el6

Complete!	#成功卸载tomcat6
[root@jtxdsh-129 local]# yum remove tomcat6	#卸载成功后,再尝试卸载
Loaded plugins: fastestmirror, refresh-packagekit
Setting up Remove Process
No Match for argument: tomcat6
Loading mirror speeds from cached hostfile
 * base: mirrors.neusoft.edu.cn
 * extras: mirrors.shu.edu.cn
 * updates: mirrors.shu.edu.cn
Package(s) tomcat6 available, but not installed.	#提示tomcat6没有被安装,说明卸载是成功的。
No Packages marked for removal

===>>>> 3 tomcat服务器安装、运行和访问

cd /usr/local	#进入linux系统软件安装目录集

wget http://mirrors.hust.edu.cn/apache/tomcat/tomcat-7/v7.0.92/bin/apache-tomcat-7.0.92.tar.gz	#下载tomcat7

tar -zxvf apache-tomcat-7.0.92.tar.gz	#解压tomcat7,作为tomcat安装目录

 cd apache-tomcat-7.0.92/ 				#进入tomcat7安装目录
 
 ./bin/startup.sh						#启动tomcat服务器
 
 
(A).在linux图形界面,本地打开浏览器,输入http://localhost:8080/ 进入tomcat7主页,显示内容"Apache Tomcat/7.0.92"表示成功。

(B).在windows系统中远程访问linux系统中搭建的tomcat

	service iptables status	#查看防火墙状态

	#测试从当前机器到远程linux(192.168.179.129)服务器的的网络是否可达。
	ping 192.168.179.129 -n 6  //在windows系统的cmd环境中ping linux服务服务器
		或telnet 192.168.179.129 //win7默认是关闭了telnet服务的,手动开启telnet服务,控制面板-->程序-->勾选: "打开或关闭Windows功能"
		
	ping 192.168.179.129 -c 6  //在linux系统命令环境中ping linux服务服务器

	#开墙
	vim /etc/sysconfig/iptables	#编辑配置文件iptables,添加以下语句
	-A INPUT -m state --state NEW -m tcp -p tcp --dport 8080 -j ACCEPT
	service iptables restart	#重启防火墙,使修改的配置生效。
	
	#访问linux系统中搭建的tomcat服务器
	打开浏览器,输入http://localhost:8080/ 进入tomcat7主页,显示内容"Apache Tomcat/7.0.92"表示成功。

===>>>> 4 tomcat服务器管理

进入tomcat7安装目录
	./bin/startup.sh	#开启tomcat服务器
	./bin/shutdown.sh	#关闭tomcat服务器

===>>>> 5 tomcat配置文件管理

1.catalina.properties配置文件
Tomcat的catalina.properties文件位于%CATALINA_HOME%/conf/目录下面,
该文件主要配置tomcat的安全设置、类加载设置、不需要扫描的类设置、字符缓存设置四类。

2.server.xml(mysql服务器端的配置文件)
	两大连接器(Connector)
	(i) a non-SSL HTTP/1.1 Connector
		  The HTTP Connector element represents a Connector component that supports the HTTP/1.1 protocol.
		It enables Catalina to function as a stand-alone web server, in addition to its ability to execute servlets and JSP pages. 
		通常用于tomcat提供Web服务,默认监听8009端口,采用HTTP/1.1协议。
		
	(ii)  AJP 1.3 Connector
		The AJP Connector element represents a Connector component that communicates with a web connector via the AJP protocol. 
		通常用于tomcat与其它HTTP服务器进行集成,默认监听8009端口,采用AJP/1.3协议。
		
3.日志文件
	(1)Tomcat使用的日志配置文件:$CATALINA_BASE/conf/logging.properties
	(2)tomcat访问日志记录,文件名为localhost_access_log.日期.txt
	(3)Cataline引擎的日志文件,文件名catalina.日期.log
	(4)Tomcat下应用程序抛出的日志,文件名localhost.日期.log
	(5)Tomcat下默认manager应用日志,文件名manager.日期.log
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值