目录
2.安装tomcat在一台已经部署了tomcat的机器上复制tomcat的配置文件取名tomcat1
打开浏览器访问192.168.17.27:8080? ? ? 8081(验证是否成功)
测试访问? 192.168.17.30/static/test.html
192.168.17.30/test/qwe.jsp? ? (刷新界面发生改变)
vim /etc/profile.d/1.sh #在profile的子目录的下创建一个文件
export JAVA_HOME=/usr/local/jdk1.8.0_361
export JRE HOME=$JAVA_HOME/jre
export CLASSPATH=.:$JAVA_HOME/lib:$JRE_HOME/lib
export PATH=$JAVA_HOME/bin:$JRE_HOME/bin:$PATH
. /etc/profile #运行
java -version #查看版本
java version "1.8.0_361" #更改成功版本号
Java(TM) SE Runtime Environment (build 1.8.0_361-b09)
Java HotSpot(TM) 64-Bit Server VM (build 25.361-b09, mixed mode)
vim /usr/local/tomcat1/conf/server.xml
cd /usr/local/tomcat/bin/ #启动tomcat
./startup.sh
cd /usr/local/tomcat1/bin/ #启动tomcat1
./startup.sh
-bash-4.2# ss -natp |grep :8080
LISTEN 0 100 :::8080 :::* users:(("java",pid=3557,fd=51))
-bash-4.2# ss -natp |grep :8081
LISTEN 0 100 :::8081 :::* users:(("java",pid=45066,fd=51))
-bash-4.2#
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<html>
<head>
<title>JSP test1 page</title> #指定为 test1 页面
</head>
<body>
<% out.println("动态页面 1,http://www.test1.com");%>
</body>
</html>
192.168.7.27:8080
192.168.7.27:8081
192.168.17.26:8080/test/qwe.jsp
192.168.17.27:8081/test/qwe.jsp
192.168.17.27:8080/test/qwe.jsp
vim /usr/local/nginx/nginx.conf
upstream tomcat_server{
server 192.168.17.26:8080 weight=1;
server 192.168.17.27:8081 weight=1;
server 192.168.17.27:8080 weight=1;
}
location ~ .*\.jsp$ {
proxy_pass http://tomcat_server;
proxy_set_header HOST $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
编辑一个静态网页
cd /usr/local/nginx/html
mkdir static
添加图片 用于测试
<html>
<body>
<h1>this is static web01</h1>
<img src="iu.jpeg"/>
</body>
</html>