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

Getting Started with Mysql--sql execution process

Table of contents 1. Process 2. Core Architecture...

Two ways to connect WeChat mini program to Tencent Maps

I've been writing a WeChat applet recently an...

Mysql string interception and obtaining data in the specified string

Preface: I encountered a requirement to extract s...

Detailed explanation of the practical use of HTML table layout

When is the table used? Nowadays, tables are gene...

WeChat applet realizes the nine-square grid effect

This article shares the specific code for the WeC...

MySQL 8.0.3 RC is about to be released. Let’s take a look at the changes

MySQL 8.0.3 is about to be released. Let’s take a...

Vue uses vue meta info to set the title and meta information of each page

title: vue uses vue-meta-info to set the title an...

JavaScript implements password box verification information

This article example shares the specific code of ...

Postman automated interface testing practice

Table of contents Background Description Creating...

Facebook's nearly perfect redesign of all Internet services

<br />Original source: http://www.a-xuan.cn/...

jQuery implements time selector

This article example shares the specific code of ...

Detailed explanation of node.js installation and HbuilderX configuration

npm installation tutorial: 1. Download the Node.j...