1. 程式人生 > >centos6.5下安裝tomcat

centos6.5下安裝tomcat

1、官網下載tomcat(https://tomcat.apache.org/download-80.cgi),放到/opt/wangzonglin目錄下


2、解壓    

解壓                tar -zxvf apache-tomcat-8.0.48.tar.gz

修改檔名      mv apache-tomcat-8.0.48.tar.gz tomcat1


3、修改tomcat埠

cd /opt/wangzonglin/tomcat1/conf

vi server.xml


4、配置資料庫   vi context.xml    

複製程式碼插入檔案---》

<Resource name="jdbc/microCredit" acquireIncrement="1" driverClass="com.mysql.jdbc.Driver" factory="org.apache.naming.factory.BeanFactory" idleConnectionTestPeriod="58" jdbcUrl="jdbc:mysql://ip:埠

/資料庫名?useUnicode=true&amp;characterEncoding=UTF-8&amp;zeroDateTimeBehavior=convertToNull&amp;autoReconnect=true&amp;allowMultiQueries=true" maxIdleTime="50" maxPoolSize="1000" minPoolSize="10" numHelperThreads="3" password="密碼" type="com.mchange.v2.c3p0.ComboPooledDataSource" user="使用者名稱"/>


5、啟動tomcat

cd /opt/wangzonglin/tomcat1/bin

./start.sh


tail -f ../logs/catalina.out


6、設定防火牆

方法一:

#  /sbin/iptables -I INPUT -p tcp --dport 8888 -j ACCEPT

#  service iptables save

#  service iptables restart

方法二:

#  firewall-cmd --permanent--zone=public --add-port=8080/tcp

#  systemctl restartfirewalld.service

7、檢查tomcat是否啟動成功

瀏覽器輸入http://ip:埠,出現如下頁面