Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to build Apr Module for tomcat performance Optimization

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

Preface

Tomcat is a widely used java web container, and there are numerous kinds of tuning. Because tomcat mainly runs dynamic pages such as jsp, its design is mainly designed to optimize dynamic pages, but the processing efficiency of static files is not high.

In many cases, engineers prefer to use nginx or apache server to assist tomcat to process static files to improve server efficiency, but in fact, tomcat itself can call the apache method to deal with static files, which greatly improves the processing efficiency.

Three modes of tomcat server: bio (message blocking mode), nio (non-blocking mode), apr (using apache static file processing library to handle static files)

How to deploy tomcat's apr module on a brand new linux?

For machines that have been in stable use, you can directly look at step 3.

1. If you find that the yum source is not suitable before installation

CentOS 5 modifies yum source mode

Wget-O / etc/yum.repos.d/CentOS-Base.repo

Http://mirrors.aliyun.com/repo/Centos-5.repo

Or

Curl-o / etc/yum.repos.d/CentOS-Base.repo

Http://mirrors.aliyun.com/repo/Centos-5.repo

CentOS 6 modifies yum source mode

Wget-O / etc/yum.repos.d/CentOS-Base.repo

Http://mirrors.aliyun.com/repo/Centos-6.repo

Or

Curl-o / etc/yum.repos.d/CentOS-Base.repo

Http://mirrors.aliyun.com/repo/Centos-6.repo

CentOS 7 modifies yum source mode

Wget-O / etc/yum.repos.d/CentOS-Base.repo

Http://mirrors.aliyun.com/repo/Centos-7.repo

Or

Curl-o / etc/yum.repos.d/CentOS-Base.repo

Http://mirrors.aliyun.com/repo/Centos-7.repo

two。 If you parse the URL incorrectly curl: (6) Could not resolve host

The steps to configure dns are as follows

Vim / etc/resolv.conf

# is usually an empty file. Add these two dns configurations to the file

Nameserver 114.114.114.114nameserver 8.8.8.8

3. Install tomcat openssl and apr components

At present, Tomcat 8.x runs in nio mode by default, and the essence of apr is to use jni technology to call the underlying IO interface of the operating system, so you need to install the dependencies needed in advance, first of all, you need to install openssl and apr.

Yum-y install openssl-develyum-y install apr-devel

4. Install native,apr,apr-util components

First, go to the official website of tomcat to download the native,apr,apr-util component. Native can be seen as an intermediate part of the interaction between tomcat and apr. The download address is:

Http://tomcat.apache.org/download-native.cgi

The apr address is on the http://apache.fayea.com//apr browser to take a look, because the apache is updated irregularly. After the fixed writing here, the wget may not be pulled down, so if you don't write regularly, you can download it yourself.

Re-decompress installation

Tar-xvzf apr-1.6.5.tar.gz cd apr-1.6.5. / configure-prefix=/usr/local/apr make & & make install tar-zxvf apr-util-1.6.1.tar.gz cd apr-util-1.6.1. / configure-- prefix=/usr/local/apr-util-- with-apr=/usr/local/apr/

# then there may be a problem with make due to the lack of a compiler library expat-devel

You can use yum install expat-devel-y for installation

(if this doesn't work, you can only find it from the system installation CD), and then

Make & & make install

Reinstall the native module

Tar-xvzf tomcat-native-1.2.10-src.tar.gz cd tomcat-native-1.2.10-src/native/. / configure

Installation may fail at this time, because of the lower version of openssl, go to the official website to check the latest version of the address, https://www.openssl.org/source/ and then wget down

Tar-xvzf openssl-1.1.0e.tar.gzcd openssl-1.1.0e/./config-- prefix=/usr/local/openssl-- openssldir=/usr/local/opensslmake & & make install

After a while, the installation is successful. Now go back to the directory that native just compiled, and re-execute the following command to install:

. / configure-with-ssl=/usr/local/opensslmake & & make installefix=/usr/local/openssl-openssldir=/usr/local/opensslmake & & make install

5. Modify tomcat configuration file

Enter your tomcat destination server directory and edit the configuration file: conf/server.xml

Change the default protocol= "HTTP/1.1" to

Protocol= "org.apache.coyote.http11.Http11AprProtocol"

Save and exit after modification

6. Configure environment variables (in two ways)

Go to the tomcat installation directory

Open the bin/catalina.sh file

Append the corresponding configuration to the original variable JAVA_OPTS, and add a new one:

JAVA_OPTS= "$JAVA_OPTS-Djava.library.path=/usr/local/apr/lib"

Then you can finish the installation after saving and exiting.

Restart your tomcat server and see the log at the end of the catalina.out

Tomcat startup log

It means that tomcat Apr has been configured successfully.

Or

Add the directory of apr to the environment variable so that tomcat can use the system variable to search

Edit / etc/profile add the following two lines at the end:

Export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/apr/libexport LD_RUN_PATH=$LD_RUN_PATH:/usr/local/apr/lib

After saving, execute source / etc/profile to make the configuration effective

Then restart your tomcat server and see the log at the end of the catalina.out

It means that tomcat Apr has been configured successfully.

The above is the whole content of this article, I hope it will be helpful to your study, and I also hope that you will support it.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report