- A+
所属分类:Tomcat
1.安装apr
tee -a apr.sh <<-'EOF' #!/bin/bash export PATH # Check if user is root if [ $(id -u) != "0" ]; then echo "Error: You must be root to run this script, please use root to optimization system" exit 1 fi #Install gcc yum install make gcc gcc-c++ wget libtool expat-devel vim -y #Download apr wget http://mirror.bit.edu.cn/apache//apr/apr-1.7.0.tar.gz; wget http://mirror.bit.edu.cn/apache//apr/apr-util-1.6.1.tar.gz; wget http://mirror.bit.edu.cn/apache//apr/apr-iconv-1.2.2.tar.gz; #Install apr tar zxvf apr-1.7.0.tar.gz && cd apr-1.7.0; sed -i 's/$RM "$cfgfile/#$RM "$cfgfile/g' configure; ./configure --prefix=/usr/local/apr && make && make install && cd ..; tar zxvf apr-iconv-1.2.2.tar.gz && cd apr-iconv-1.2.2 && ./configure --prefix=/usr/local/apr-iconv --with-apr=/usr/local/apr make && make install && cd ..; 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 --with-apr-iconv=/usr/local/apr-iconv/bin/apriconv make && make install EOF
2.本机
wget http://mirror.bit.edu.cn/apache/tomcat/tomcat-8/v8.0.53/bin/apache-tomcat-8.0.53.tar.gz && tar zxvf apache-tomcat-8.0.53.tar .gz && tar zxvf apache-tomcat-8.0.53 / bin / tomcat-native.tar.gz && cd tomcat-native-1.2.17-src / native / && ./configure --with-apr = / usr / local / apr --with-java-home = / usr / java / jdk1.8.0_181-amd64 && make &&进行安装
如果configure报错配置:错误:您的OpenSSL版本与此tcnative版本不兼容
wget https://www.openssl.org/source/openssl-1.1.1d.tar.gz&&tar zxvf openssl-1.1.1d.tar.gz && cd openssl-1.1.1d &&。/ config --prefix = / usr / local / openssl -fPIC && make和&make安装
注意这里需要加入 -fPIC参数,否则后面在安装tomcat native 组件会出错
mv / usr / bin / openssl〜; ln -s / usr / local / openssl / bin / openssl / usr / bin / openssl; 在-s /usr/local/openssl/lib/libssl.so.1.1 /usr/lib64/libssl.so.1.1; ln -s /usr/local/openssl/lib/libcrypto.so.1.1 /usr/lib64/libcrypto.so.1.1;
查看版本
openssl版本
最后再configure
./configure --with-apr = / usr / local / apr --with-java-home = / usr / java / jdk1.8.0_181-amd64 --with-ssl = / usr / local / openssl
配置环境变量
tee-a / etc / profile <<-'EOF' 导出LD_LIBRARY_PATH = / usr / local / apr / lib 紧急行动 源/ etc / profile; ln -s /usr/local/apr/lib/libtcnative-1.so /usr/lib64/libtcnative-1.so
3.内存优化JVM
vim apache-tomcat-8.0.53 / bin / catalina.sh
JAVA_OPTS =“-服务器-Xms1024m -Xmx1024m -XX:PermSize = 512M -XX:MaxNewSize = 1024m -XX:MaxPermSize = 512m -XX:MaxDirectMemorySize = 512m -Djava.awt.headless = true -Djava.security.egd = file: /dev/。/urandom” CATALINA_OPTS =“ $ CATALINA_OPTS -Djava.library.path = / usr / local / apr / lib”
4.HTTP请求优化
vim apache-tomcat-8.0.53 / conf / server.xml
<连接器端口=“ 8080” protocol =“ org.apache.coyote.http11.Http11AprProtocol” connectionTimeout =“ 10000” redirectPort =“ 8443” maxThreads =“ 5000” minSpareThreads =“ 20” acceptCount =“ 1000” enableLookups =“ false” URIEncoding =“ UTF-8” useBodyEncodingForURI =“ true” compression =“ on” compressionMinSize =“ 2048” noCompressionUserAgents =“ gozilla,traviata” compressableMimeType =“ text / html,text / xml,application / javascript,text / css,text / plain,image / jpeg,image / gif” />
5.隐藏版本
cd apache-tomcat-8.0.53 / lib /; 解压缩catalina.jar
修改版本信息
该组织/阿帕奇/卡塔利娜/ UTIL / ServerInfo.properties
server.info = lstest server.number = 2017 server.built = 2017
修改后的信息压缩回jar包
jar uvf catalina.jar组织/apache/catalina/util/ServerInfo.properties
重启tomcat