CentOS7.0 安裝 tomcat-9.0

一、解壓web

#  tar -zxvf apache-tomcat-9.0.0.M4.tar.gz  -C  /opt/usr/localapache

改個名字好之後操做:
tomcat

#   mv    apache-tomcat-9.0.0.M4.tar.gz    tomcattcp

二、啓動&中止ui

#  /opt/usr/local/tomcat/bin/startup.sh this

/opt/usr/local/tomcat/bin/shutdown.shspa

三、配置防火牆放行8080端口並作80端口映射

在/etc/firewalld/services/目錄下新建一個名爲tomcat.xml的文件,內容以下:.net

<?xml version="1.0" encoding="utf-8"?>  
<service>  
  <short>Tomcat Webserver</short>  
  <description>HTTPS is a modified HTTP used to serve Web pages when security is important. Examples are sites that require logins like stores or web mail. This option is not required for viewing pages locally or developing Web pages. You need the httpd package installed for this option to be useful.</description>  
  <port protocol="tcp" port="8080"/>  
</service>

而後把此服務加入防火牆規則中code

 firewall-cmd --reload
 firewall-cmd --add-service=tomcat
 firewall-cmd --permanent --add-service=tomcat

 

因爲非root用戶不能偵聽1023如下端口,因此這裏採用一個變通的方法,就是利用firewalld在數據包路由以前進行端口轉發,把全部發往80的tcp包轉發到8080便可。orm

firewall-cmd --add-forward-port=port=80:proto=tcp:toport=8080
firewall-cmd --permanent --add-forward-port=port=80:proto=tcp:toport=8080

此後tomcat就至關於同時偵聽80和8080兩個端口了。


對於 Firewall 的配置我參考的:http://blog.csdn.net/smstong/article/details/39958675

相關文章
相關標籤/搜索