Linux based Lamt reverse proxy test

Source: Internet
Author: User

Test environment: CentOS 6.8 Tomcat

Test environment: CentOS 7.3 Apache


Software version: jdk-8u144-linux-x64.tar.gz

Apache-tomcat-8.0.45.tar.gz

Apache 2.4.6


You need to use DNS service resolution, if not, modify/etc/hosts to add the corresponding IP address and relative domain name.

1. Install Tomcat on CentOS 6.8

Create a Tomcat user and specify an ID number of 601.

] #useradd-U 601 Tomcat

Unzip the JDK

] #tar XF jdk-8u144-linux-x64.tar.gz

Move JDK to/usr/local

] #mv jdk1.8.0_144//usr/local/

Create a soft link name for JDK

] #ln-S/usr/local/jdk1.8.0_144//usr/local/jdk

Unzip Tomcat.

] #tar XF apache-tomcat-8.0.45.tar.gz

Move to/usr/local below

]# MV apache-tomcat-8.0.45/usr/local/

Create soft connection name for Tomcat

]# ln-s/usr/local/apache-tomcat-8.0.45//usr/local/tomcat


Configuring the environment variables required for Tomcat

]# Vim/etc/profile

Export JAVA_HOME=/USR/LOCAL/JDK

Export path= $JAVA _home/bin: $JAVA _home/jre/bin: $PATH

Export classpath=. $CLASSPATH: $JAVA _home/lib: $JAVA _home/jre/lib: $JAVA _home/lib/tools.jar

Export Tomcat_home=/usr/local/tomcat

Reread/etc/profile

]# Source/etc/profile


Check that the environment variable is in effect, view the version number

]# java-version

Java Version "1.8.0_144"

Java (TM) SE Runtime Environment (build 1.8.0_144-b01)

Java HotSpot (TM) 64-bit Server VM (build 25.144-b01, Mixed mode)

Modify/USR/LOCAL/JDK,/usr/local/tomcat of the genus Group is tomcat.

]# Chown-r TOMCAT:TOMCAT/USR/LOCAL/JDK

]# Chown-r tomcat:tomcat/usr/local/tomcat/

Create log directory

]# Mkdir/usr/local/tomcat/logs

Switch to Tomcat user under Start Tomcat

]# Su-tomcat

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

-bash:/usr/local/tomcat/bin/startup.sh:permission denied

The error here is that there is no execute permission, switch to root and use chmod to modify

]# chmod u+x/usr/local/tomcat/bin/*.sh

Switch to Tomcat and start Tomcat again

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

Using catalina_base:/usr/local/tomcat

Using Catalina_home:/usr/local/tomcat

Using Catalina_tmpdir:/usr/local/tomcat/temp

Using Jre_home:/USR/LOCAL/JDK

Using CLASSPATH:/usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar

Tomcat started.

See if Tomcat is listening on port 8080

]# SS-TNL

State recv-q send-q Local address:port Peer address:port

LISTEN 0 1:: ffff:127.0.0.1:8005:::*

LISTEN 0::: 8009:::*

LISTEN 0::: 8080:::*

LISTEN 0 128::: 22:: :*

LISTEN 0 *:22 *:*

Access Address ip+8080 Port

650) this.width=650; "Src=" https://s1.51cto.com/wyfs02/M01/A2/78/wKioL1mf6zaBUT3zAAF_n3nzqcc913.jpg-wh_500x0-wm_ 3-wmp_4-s_535639489.jpg "title=" 38.jpg "alt=" Wkiol1mf6zabut3zaaf_n3nzqcc913.jpg-wh_50 "/>

Directories and index.jsp files required to create a virtual host

]# mkdir-p/data/{logs,webapps}

]# mkdir root/{classes, Lib,meta-inf,web-inf}

}# Vim index.jsp

<%@ page language= "java"%>

<%@ page import= "java.util.*"%>

<title>to Text Page </title>

<body>

<% out.println ("hello,world!!"); %>

</body>

Edit Server.xml, and add the following configuration at the end.

]# cd/usr/local/tomcat/conf/

]# Vim Server.xml

</Host>

<context path= "" docbase= "ROOT" reloadable= "true"/>

<valve classname= "Org.apache.catalina.valves.AccessLogValve" directory= "/data/logs"

prefix= "Web1_access_log" suffix= ". txt"

pattern= "%h%l%u%t &quot;%r&quot; %s%b "/>

</Host>

Restart Tomcat, and then test for normal access.

650) this.width=650; "Src=" https://s1.51cto.com/wyfs02/M00/03/C8/wKiom1mf9RPT_QHqAAApWYsfhaU550.jpg-wh_500x0-wm_ 3-wmp_4-s_2711054904.jpg "title=" web.jpg "alt=" Wkiom1mf9rpt_qhqaaapwysfhau550.jpg-wh_50 "/>

2. Installing Apache in CentOS 7.3

CentOS 7.3 On the Apache is the 2.4.6 version, if you are installing the system is the use of basic services are automatically installed, I use the minimal installation, need to install separately. It can be installed directly with yum-y install httpd. The installation process is omitted.

Enter the httpd directory

]# cd/etc/httpd/

httpd]# ls

Conf CONF.D CONF.MODULES.D logs modules run

Add a configuration file for a virtual host under CONF.D

[Email protected] conf.d]# vim vhosts.conf

<virtualhost *:80>

ServerName web1.dklwj.com

Proxyvia on

Proxyrequests OFF

Proxypreservehost on

<proxy *>

Require all granted

</proxy>

Proxypass/status!

proxypass/http://192.168.2.38:8080/

proxypassreverse/http://192.168.2.38:8080/

<location/>

Require all granted

</Location>

</VirtualHost>

Use HTTPD-T to check the configuration file for errors.

[Email protected] conf.d]# httpd-t

Syntax OK

Restart HTTPD Service

[[email protected] CONF.D] #systemctl restart httpd

Test access;

650) this.width=650; "Src=" https://s4.51cto.com/wyfs02/M02/A2/79/wKioL1mf9seBk93jAAF7R0onPRU898.jpg-wh_500x0-wm_ 3-wmp_4-s_3234811820.jpg "style=" Float:none; "title=" test succeeded. jpg "alt=" wkiol1mf9sebk93jaaf7r0onpru898.jpg-wh_50 "/ >

650) this.width=650; "Src=" https://s4.51cto.com/wyfs02/M00/03/C9/wKiom1mf9tWg0AwPAAC86vd0lVg955.jpg-wh_500x0-wm_ 3-wmp_4-s_1201249533.jpg "style=" Float:none; "title=" virtual host test succeeded. jpg "alt=" wkiom1mf9twg0awpaac86vd0lvg955.jpg-wh_50 " />

Test success, if there is any problem, we can point out, learn from each other.

Linux based Lamt reverse proxy test

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.