Tomcat安裝配置(Linux)
發(fā)布日期: 2019年08月23日 SHOP++
一、系統(tǒng)環(huán)境
Ubuntu 14.04 64位
JDK 7u80 64位
Tomcat 7.0.64
二、安裝配置
1、新建目錄
sudo mkdir /usr/shopxx
sudo mkdir /usr/shopxx/soft
2、下載apache-tomcat-7.0.64.tar.gz、apr-1.5.2.tar.gz至/usr/shopxx/soft
sudo wget -P /usr/shopxx/soft http://storage.shopxx.net/file/apache-tomcat-7.0.64.tar.gz
sudo wget -P /usr/shopxx/soft http://storage.shopxx.net/file/apr-1.5.2.tar.gz
3、解壓/usr/shopxx/soft/apache-tomcat-7.0.64.tar.gz至/usr/shopxx
sudo tar -zxvf /usr/shopxx/soft/apache-tomcat-7.0.64.tar.gz -C /usr/shopxx
4、重命名/usr/shopxx/apache-tomcat-7.0.64為/usr/shopxx/tomcat7.0
sudo mv /usr/shopxx/apache-tomcat-7.0.64 /usr/shopxx/tomcat7.0
5、創(chuàng)建用戶組tomcat
sudo groupadd tomcat
6、創(chuàng)建用戶tomcat
sudo useradd -s /usr/sbin/nologin -r -g tomcat tomcat
7、修改/usr/shopxx/tomcat7.0所有者為tomcat
sudo chown -R tomcat:tomcat /usr/shopxx/tomcat7.0
8、更新軟件源
sudo apt-get update
9、安裝libssl-dev
sudo apt-get install libssl-dev
10、安裝JSVC
sudo tar -zxvf /usr/shopxx/tomcat7.0/bin/commons-daemon-native.tar.gz -C /usr/shopxx/tomcat7.0
cd /usr/shopxx/tomcat7.0/commons-daemon-1.0.15-native-src/unix
sudo ./configure --with-java=/usr/shopxx/jdk1.7
sudo make
sudo cp /usr/shopxx/tomcat7.0/commons-daemon-1.0.15-native-src/unix/jsvc /usr/shopxx/tomcat7.0/bin/jsvc
cd /usr/shopxx
sudo rm -rf /usr/shopxx/tomcat7.0/commons-daemon-1.0.15-native-src
11、安裝APR
sudo tar -zxvf /usr/shopxx/soft/apr-1.5.2.tar.gz -C /usr/shopxx/tomcat7.0
cd /usr/shopxx/tomcat7.0/apr-1.5.2
sudo ./configure --prefix=/usr/shopxx/tomcat7.0/apr
sudo make
sudo make install
cd /usr/shopxx
sudo rm -rf /usr/shopxx/tomcat7.0/apr-1.5.2
12、安裝Native
sudo tar -zxvf /usr/shopxx/tomcat7.0/bin/tomcat-native.tar.gz -C /usr/shopxx/tomcat7.0
cd /usr/shopxx/tomcat7.0/tomcat-native-1.1.33-src/jni/native
sudo ./configure --prefix=/usr/shopxx/tomcat7.0/native --with-apr=/usr/shopxx/tomcat7.0/apr --with-java-home=/usr/shopxx/jdk1.7 --with-ssl=yes
sudo make
sudo make install
cd /usr/shopxx
sudo rm -rf /usr/shopxx/tomcat7.0/tomcat-native-1.1.33-src
13、新建配置文件/usr/shopxx/tomcat7.0/bin/setenv.sh,添加如下內(nèi)容
# JDK路徑
JAVA_HOME=/usr/shopxx/jdk1.7
# Tomcat啟動(dòng)用戶
TOMCAT_USER=tomcat
# Jsvc參數(shù)
JSVC_OPTS="-jvm server"
# Java參數(shù)
JAVA_OPTS="-server -Xms512m -Xmx512m -XX:PermSize=64m -XX:MaxPermSize=128m -Dfile.encoding=UTF-8"
# Native庫路徑
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/shopxx/tomcat7.0/native/lib
export LD_LIBRARY_PATH
14、修改配置文件/usr/shopxx/tomcat7.0/conf/server.xml,修改如下內(nèi)容
<!-- port: 端口 -->
<!-- URIEncoding: 字符集編碼 -->
<!-- compression: 開啟GZIP -->
<!-- compressableMimeType: GZIP類型 -->
<Connector port="80" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" URIEncoding="UTF-8" compression="on" compressableMimeType="text/html,text/css,text/javascript" />
<!-- URIEncoding: 字符集編碼 -->
<Connector port="8009" protocol="AJP/1.3" redirectPort="8443" URIEncoding="UTF-8" />
15、添加/usr/shopxx/tomcat7.0/bin/daemon.sh可執(zhí)行權(quán)限
sudo chmod +x /usr/shopxx/tomcat7.0/bin/daemon.sh
16、創(chuàng)建鏈接
sudo ln -s /usr/shopxx/tomcat7.0/bin/daemon.sh /etc/init.d/tomcat
17、配置Tomcat自動(dòng)啟動(dòng)
sudo update-rc.d tomcat defaults
18、啟動(dòng)Tomcat
sudo /etc/init.d/tomcat start
19、停止Tomcat
sudo /etc/init.d/tomcat stop
三、相關(guān)文件
apache-tomcat-7.0.64.tar.gz apr-1.5.2.tar.gz setenv.sh server.xml
本文鏈接: http://www.520frw.com/news/detail/5d5fc3a208813b0001c3536b