Tomcat Installation and configuration tutorial for Native APR mode

  • 2020-06-03 08:57:39
  • OfStack

preface

It is well known that APR can significantly improve the performance of tomcat, but I have not done performance comparison tests. The following article focuses on the steps and procedures for installing and configuring the APR pattern for tomcat 7 under CentOS 6.5. Before installation, a brief introduction to 1 related content, let's start learning.

Technical preparation

What is APR? (This is from Wikipedia.)

The Apache portable runtime (Apache Portable Runtime, or APR for short) is the support library for the Apache HTTP server, which provides a set of API maps to the underlying operating system. If the operating system does not support a particular function, APR provides a mock implementation. This allows programmers to use APR to write programs that are truly portable across platforms.

What is a tomcat - native

The tomcat-ES32en library provides a local implementation for Tomcat. tomcat-native relies on three components: APR, OPENSSL, JDK.

General train of thought

The general idea is to use ES43en-ES44en library to make the tomcat runtime call more local API via APR to achieve the purpose of improving performance. Due to dependencies, when installing, install APR, OPENSSL, then ES50en-ES51en, and finally configure the library path that tomcat depends on when it starts.

Configure the installation

The installation steps are actually included with tomcat tomcat-native.tar.gz There is in the file, here is the record of their own installation and configuration process, roughly 1, slightly different. Instead of installing ES59en-ES60en under some tomcat, I installed it independently.

1. Install apr and openssl


yum install apr-devel openssl-devel

2. Install ES69en-ES70en

The ES73en-ES74en installation file already exists in tomcat at $CATALINA_HOME/bin The file tomcat-native.tar.gz . The file tomcat-native.tar.gz Copy out after decompression, configuration, installation.


tar xzcf tomcat-native.tar.gz
cd tomcat-native-1.1.32-src/jni/native
./configure --with-apr=/usr/bin/apr-1-config --with-ssl=yes
make && make install

When the installation is complete, you will see the following prompt that the identity has been installed /usr/local/apr/lib In the.


Libraries have been installed in:
 /usr/local/apr/lib

The above steps are performed by root users, and the following steps are performed by the owner user of tomcat

3. Configure tomcat dependency libraries

in $CATALINA_HOME/bin/setenv.sh Add (or new if there is none)
export CATALINA_OPTS=”$CATALINA_OPTS -Djava.library.path=/usr/local/apr/lib”

4. Configure tomcat server.xml

Open the following configuration


<Listener className="org.apache.catalina.core.AprLifecycleListener" SSLEngine="on" />

Ensure that protocol in the Connector configuration is 1 of the following values.


protocol="HTTP/1.1" 
protocol="org.apache.coyote.http11.Http11AprProtocol"

If specified as HTTP/1.1, tomcat automatically selects the appropriate protocol.

Finally restart Tomcat.

conclusion

The above is the whole content of this article, I hope the content of this article can bring 1 definite help to your study or work, if you have any questions, you can leave a message to communicate.


Related articles: