How to separate static and dynamic state by combining Apache with Tomcat

How to separate static and dynamic state by combining Apache with Tomcat

Experimental environment

  • Apache and Tomcat are both installed on the host with IP address 192.168.153.136
  • The host operating system is centos7
  • Before the experiment, turn off the firewall, command: systemctl stop firewalld
  • Disable seliunx, command: setenforce 0
  • The experimental result is that Apache processes html static resources and Tomcat processes jsp dynamic resources

1. Install and start Apache

1.1 Installation

 yum -y install httpd

1.2 Startup

systemctl start httpd

2. Install and start tomcat

2.1 Install JDK

rpm -ivh jdk-8u131-linux-x64_.rpm

2.2 Verify that JDK is installed successfully

[root@host-136 ~]# java -version
java version "1.8.0_131"
Java(TM) SE Runtime Environment (build 1.8.0_131-b11)
Java HotSpot(TM) 64-Bit Server VM (build 25.131-b11, mixed mode)

2.3 Unzip the Tomcat installation package and move it to the /opt directory

2.3.1 Decompression

tar xzf apache-tomcat-8.5.35.tar.gz

2.3.2 Mobile name change

mv apache-tomcat-8.5.35 /opt/tomcat

2.4 Start the service

/opt/tomcat/bin/startup.sh

3. Install the connector tomcat-connectors source code

3.1 Installation Required Environment

yum -y install httpd-devel gcc gcc-c++

3.2 Decompression

tar zxf tomcat-connectors-1.2.48-src.tar.gz

3.3 Detect environment and configure

cd tomcat-connectors-1.2.48-src/native
./configure --with-apxs=/usr/bin/apxs

3.3 Compile and install

make && make install

3.4 Verify installation is successful

[root@host-136 native]# ll /etc/httpd/modules/mod_jk.so
-rwxr-xr-x. 1 root root 1565864 Jan 6 09:32 /etc/httpd/modules/mod_jk.so

4. Create a test page

4.1 Static Pages

vim /var/www/html/index.html

<h1>static_page_from_apache</h1>

4.2 Dynamic Pages

vim /opt/tomcat/webapps/ROOT/test.jsp

<h1>dynamic_page_from_tomcat</h1>

5. Configure the jk module to integrate Apache with tomcat

5.1 Copy the configuration file

cd tomcat-connectors-1.2.48-src/conf/
cp httpd-jk.conf /etc/httpd/conf.d/
cp workers.properties /etc/httpd/conf/

5.2 Modify the workers.properties configuration file

vim /etc/httpd/conf/workers.properties

5.2.1 Change port to 8009

Note: The Connector AJP Port is used to listen for requests on the AJP (Apache JServ Protocol) protocol. It is usually used to integrate other HTTP servers such as Apache Server. The default value is 8009.

insert image description here

5.2.2 Comment or delete the lines 86 87 88 89 96

insert image description here

5.3 Modify the httpd-jk.conf configuration file

vim /etc/httpd/conf.d/httpd-jk.conf

Remove the comments from line 94 and modify it as follows

insert image description here

6. Restart Apache service

systemctl restart httpd

7. Access page test

7.1 Enter ip/index.html in the browser to test the static page

insert image description here

7.2 Enter ip/test.jsp in the browser to test the dynamic page

insert image description here

This is the end of this article about combining Apache with Tomcat to achieve dynamic and static separation. For more relevant content about combining Apache with Tomcat to achieve dynamic and static separation, please search for previous articles on 123WORDPRESS.COM or continue to browse the following related articles. I hope you will support 123WORDPRESS.COM in the future!

You may also be interested in:
  • Basic configuration example of Nginx with Apache or Tomcat for dynamic and static separation
  • How to install Apache Tomcat on Ubuntu 16.04
  • A detailed introduction to the differences, connections, and integration between Apache and Tomcat servers
  • Jsp and PHP share port 80 to integrate Apache and Tomcat (no need to add port number when accessing)
  • Apache 2.2 and above versions integrated with Tomcat and implemented load balancing
  • Apache tomcat How to implement multiple domain names for one website

<<:  Some tips on deep optimization to improve website access speed

>>:  Reflection and Proxy in Front-end JavaScript

Recommend

Six-step example code for JDBC connection (connecting to MySQL)

Six steps of JDBC: 1. Register the driver 2. Get ...

Font Treasure House 50 exquisite free English font resources Part 1

Designers have their own font library, which allo...

How to use Docker Compose to implement nginx load balancing

Implement Nginx load balancing based on Docker ne...

Summary of common problems and solutions in Vue (recommended)

There are some issues that are not limited to Vue...

HTML table tag tutorial (44): table header tag

<br />In order to clearly distinguish the ta...

React implements dynamic pop-up window component

When we write some UI components, if we don't...

A comprehensive understanding of Vue.js functional components

Table of contents Preface React Functional Compon...

Detailed explanation of data sharing between Vue components

Table of contents 1. In project development, the ...

Detailed explanation of the process of zabbix monitoring sqlserver

Let's take a look at zabbix monitoring sqlser...

How to introduce scss into react project

First download the dependencies yarn add sass-loa...

Difference between src and href attributes

There is a difference between src and href, and t...

CSS inheritance method

Given a div with the following background image: ...