> CentOS > CentOS教程 >

centos中安装tomcat6

在centos中安装tomcat6
 
1)通过yum自动安装tomcat和dependences
root@Centos_AAA ~]# yum install tomcat6
[root@Centos_AAA ~]# service tomcat6 start
[root@Centos_AAA ~]# chkconfig tomcat6 on
[root@Centos_AAA ~]# yum install tomcat6-webapps
[root@Centos_AAA webapps]# yum install tomcat6-admin-webapps
 
如果访问http://192.168.0.120:8080/访问不了那大多是防火墙经用了8080端口,解决方法如下:
iptables -A INPUT -p tcp --dport 8080 -j ACCEPT
iptables -A OUTPUT -p tcp --sport 8080 -j ACCEPT
 
如果安装正确的话,可以在browser中看到tomcat的默认的page。
 
2) 配置tomcat
配置文件:/etc/tomcat6/tomcat6.conf + /etc/sysconfig/tomcat6
tomcat home目录: /usr/share/tomcat6
 
配置tomcat为admin和manager用户:
修改文件/usr/share/tomcat6/conf/tomcat-users.xml
<!-- The host manager webapp is restricted to users with role "admin" -->
<!--<user name="tomcat" password="password" roles="admin" />-->
<!-- The manager webapp is restricted to users with role "manager" -->
<user name="tomcat" password="password" roles="manager,admin" />
</tomcat-users>
 
此时可以访问http://192.168.0.120:8080/manager/html和http://192.168.0.120:8080/host-manager/html来管理tomcat server和host。
 
 
参考:
https://www.centos.org/forums/viewtopic.php?f=34&t=40474
http://www.davidghedini.com/pg/entry/install_tomcat_6_on_centos
http://www.cnoswiki.com/2012/11/centos-yum-install-tomcat6.html



 
(责任编辑:IT)