Tomcat 8.5 apr 模式配置

tomcat APR模式配置

1、環境

操做系統:Ubutnu 14html

ubuntu@ubuntu:~$ uname -a
Linux ubuntu 4.4.0-31-generic #50~14.04.1-Ubuntu SMP Wed Jul 13 01:07:32 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux

JDK 1.8java

ubuntu@ubuntu:~$ java -version
java version "1.8.0_141"
Java(TM) SE Runtime Environment (build 1.8.0_141-b15)
Java HotSpot(TM) 64-Bit Server VM (build 25.141-b15, mixed mode)
ubuntu@ubuntu:~$ whereis java
java: /usr/local/java /usr/share/java

Tomcat 8.5.35web

root@ubuntu:~# /var/www/demo/bin/version.sh
Using CATALINA_BASE:   /var/www/demo
Using CATALINA_HOME:   /var/www/demo
Using CATALINA_TMPDIR: /var/www/demo/temp
Using JRE_HOME:        /usr/local/java/jre
Using CLASSPATH:       /var/www/demo/bin/bootstrap.jar:/var/www/demo/bin/tomcat-juli.jar
Server version: Apache Tomcat/8.5.35
Server built:   Nov 3 2018 17:39:20 UTC
Server number:  8.5.35.0
OS Name:        Linux
OS Version:     4.4.0-31-generic
Architecture:   amd64
JVM Version:    1.8.0_141-b15
JVM Vendor:     Oracle Corporation

2、安裝

 1. 安裝編譯須要的環境

$ sudo apt install gcc make

2. 安裝 native 編譯所須要的依賴包

# apache apr
$ sudo apt install libapr1-dev
# openssl,自帶的 openssl版本較低,須要編譯安裝
$ wget https://www.openssl.org/source/openssl-1.1.1a.tar.gz
$ sudo mkdir /usr/local/openssl
$ tar zxf openssl-1.1.1a.tar.gz
$ ./config --prefix=/usr/local/openssl
$ make
$ sudo make install

3.下載安裝native

$ wget http://mirrors.hust.edu.cn/apache/tomcat/tomcat-connectors/native/1.2.19/source/tomcat-native-1.2.19-src.tar.gz
$ cd tomcat-native-1.2.19-src/native/
$ ./configure  --with-ssl=/usr/local/openssl
$ make
$ sudo make install

3、配置Tomcat

root@ubuntu:/var/www/demo# cat bin/setenv.sh 
export JAVA_OPTS="$JAVA_OPTS -Djava.library.path=/usr/local/apr/lib"
<Connector port="8080" 
               protocol="org.apache.coyote.http11.Http11AprProtocol"
               connectionTimeout="20000"
               redirectPort="8443" />
    ...
    <!--<Connector port="8009" protocol="AJP/1.3" redirectPort="8443" /> -->

4、啓動Tomcat

root@ubuntu:/var/www/demo# bin/catalina.sh run
.....
28-Jan-2019 15:55:09.140 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory [/var/www/demo/webapps/docs] has finished in [13] ms
28-Jan-2019 15:55:09.153 INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["http-apr-8080"]
28-Jan-2019 15:55:09.172 INFO [main] org.apache.catalina.startup.Catalina.start Server startup in 803 ms

附:編譯方式安裝apr

1. 安裝編譯須要的環境

$ sudo apt install -y gcc make  libtool  libexpat1-dev

2. 安裝Apache Portable Runtime (apr)

官方地址:https://apr.apache.org/compiling_unix.html
編譯安裝aprapache

wget http://mirrors.shu.edu.cn/apache//apr/apr-1.6.5.tar.gz
tar zxf apr-1.6.5.tar.gz
cd apr-1.6.5/
./configure --prefix=/usr/local/apache-apr
make
sudo make install

編譯安裝apr-iconvbootstrap

wget http://mirrors.shu.edu.cn/apache//apr/apr-iconv-1.2.2.tar.gz
tar zxf apr-iconv-1.2.2.tar.gz
cd apr-iconv-1.2.2/
./configure --prefix=/usr/local/apache-apr-iconv --with-apr=/usr/local/apache-apr
make
sudo make install

編譯安裝apr-utilubuntu

wget http://mirrors.shu.edu.cn/apache//apr/apr-util-1.6.1.tar.gz
ubuntu@ubuntu:~/apr-util-1.6.1$ ./configure --prefix=/usr/local/apache-apr-util --with-apr=/usr/local/apache-apr --with-apr-iconv=/usr/local/apache-apr-iconv/bin/apriconv
tar zxf apr-util-1.6.1.tar.gz
cd apr-util-1.6.1/
make
sudo make install

3. 編譯安裝openssl

wget https://www.openssl.org/source/openssl-1.1.1a.tar.gz
$ sudo mkdir /usr/local/openssl
$ tar zxf openssl-1.1.1a.tar.gz
$ ./config --prefix=/usr/local/openssl
cd openssl-1.1.1a
$ make
$ sudo make install

4. 編譯安裝native

wget http://mirrors.hust.edu.cn/apache/tomcat/tomcat-connectors/native/1.2.19/source/tomcat-native-1.2.19-src.tar.gz
tar zxf tomcat-native-1.2.19-src.tar.gz
$ cd tomcat-native-1.2.19-src/native/
$ ./configure --prefix=/usr/local/native --with-ssl=/usr/local/openssl --with-apr=/usr/local/apache-apr/bin/apr-1-config
$ make
$ sudo make install
相關文章
相關標籤/搜索