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

Nginx Agent tomcat

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

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

To run a JAVA application, you need a JVM (JAVA virtual machine)

JVM-- > JDK

Official JDK download address: https://www.oracle.com/technetwork/java/javase/downloads/index.html

Here is the jdk-12.0.2_linux-x64_bin.tar.gz installed by the binary package.

Tar zxvf jdk-12.0.2_linux-x64_bin.tar.gz

Mv jdk-12.0.2 / usr/local/jdk12/

Install openjdk on yum on CentOS7

Yum install-y java-1.8.0-openjdk

Tomcat official website:

Http://tomcat.apache.org/

Tomcat version:

7.0 8.5 9.0

Download address:

Https://tomcat.apache.org/download-90.cgi

Install Tomcat

Tar zxf apache-tomcat-9.0.24.tar.gz

Mv apache-tomcat-9.0.24 / usr/local/tomcat

Start

/ usr/local/tomcat/bin/startup.sh

View Port

Netstat-lntp | grep java

8080 is the WEB port

8005 shutdown (management port)

8009 AJP port (third-party applications connect to this interface, combined with Tomcat)

View the process

Ps aux | grep java; ps aux | grep tomcat

Zrlog blog system

Official website: https://www.zrlog.com/

Download:

Wget 'http://dl.zrlog.com/release/zrlog-2.1.0-3617b2e-release.war?attname=ROOT.war&ref=index'

Mv zrlog-2.1.0-3617b2e-release.war\? attname\ = ROOT.war\ & ref\ = index zrlog-2.1.0.war

Installation:

Mv zrlog-2.1.0.war / usr/local/tomcat/webapps/

Cd! $

Mv ROOT ROOT.bak

Mv zrlog-2.1.0 ROOT

Browser access:

Add firewall rule: firewall-cmd-- add-port=8080/tcp-- permanent

Firewall-cmd-reload

Http://ip:8080/ installation begins

Database operations:

Mysql-uroot-paming-linux-e "create database zrlog"

Mysql-uroot-paming-linux-e "grant all on zrlog.* to 'zrlog'@'127.0.0.1' identified by' zrlog-pass'"

Why configure a reverse proxy for Tomcat? 1) if the same machine has both Nginx and Tomcat, port conflicts will occur. 2) We need to change port 8080 to port 80. 3) Nginx is better than Tomcat,Tomcat in static request speed and is not good at static file request processing with high concurrency.

How to configure it?

Server {

Server_name zrlog.ruichao.cc

Location /

{

Proxy_pass http://127.0.0.1:8080;

Proxy_set_header Host $host

Proxy_set_header X-Real-IP $remote_addr

Proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for

}

}

Method 1: configuration file:

/ usr/local/tomcat/conf/server.xml

Restart:

When / usr/local/tomcat/bin/shutdown.sh # closes / usr/local/tomcat/bin/startup.sh # and then starts, port 8005 is very slow because tomcat invokes a random character device of the system at startup

Method 2:

Copy a tomcat directory and modify the three ports in the server.xml (of which 8009 can be deleted, 8080 changed to 8081 centre8005 to 8006)

Common sense:

Random numbers are generated by java.security.SecureRandom, and the random number algorithm uses "SHA1PRNG". The provider of this algorithm relies on random data provided by the operating system at the bottom, and on linux, it is related to / dev/random and / dev/urandom.

The / dev/random device returns random bytes less than the total number of entropy pool noise. / dev/random can generate a highly random public key or one-time codebook. If the entropy pool is empty, reads to / dev/random will be blocked until enough ambient noise is collected, and / dev/urandom is a non-blocking generator. It is a copy of / dev/random that reuses the data in the entropy pool to produce pseudorandom data. This means that the read operation on / dev/urandom will not block, but the entropy of its output may be less than / dev/random.

In short, port 8005 starts slowly because JVM calls the system's / dev/random device to generate random numbers, and / dev/random is block when generating random numbers, which naturally leads to slow start on port 8005. The solution is not to use / dev/random, but to use / dev/urandom. The specific steps are as follows:

Vim $JAVA_HOME/jre/lib/security/java.security

/ / change securerandom.source=file:/dev/random to securerandom.source=file:/dev/urandom

Where is $JAVA_HOME?

If it is openjdk (installed by yum), at / usr/lib/jvm/

If it is a downloaded binary package, it is the home directory of jdk (such as / usr/local/jdk_1.8)

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