一.部署Tomcat
托包(apache-tomcat-8.5.16 、jdk-8u102-linux-x64 、nginx包)
包都在我主页的资源里
在后两台一起
rpm -ivh jdk-8u102-linux-x64.rpm
java -version
tar zxvf apache-tomcat-8.5.16.tar.gz
mv apache-tomcat-8.5.16 /usr/local/tomcat8
cd /usr/local/tomcat8/conf
vim server.xml
mkdir -p /web/webapp
各自
vim /web/webapp/index.jsp
/usr/local/tomcat8/bin/startup.sh
netstat -anpt |grep java
验证 ip:8080
在调度器上(主机上)
yum install -y make gcc gcc-c++ pcre-devel zlib-devel openssl-devel
useradd -M -s /sbin/nologin nginx
tar zxvf nginx-1.12.0.tar.gz -C /usr/src/
./configure --prefix=/usr/local/nginx --user=nginx --group=nginx --with-file-aio --with-http_stub_status_module --with-http_gzip_static_module --with-http_flv_module --with-http_ssl_module && make && make install
ln -s /usr/local/nginx/sbin/nginx /usr/local/sbin
二.配置Nginx负载均衡
vim /usr/local/nginx/conf/nginx.conf
三.配置Nginx反向代理
vim /usr/local/nginx/conf/nginx.conf
location ~ .*.jsp$ {
proxy_set_header HOST $host;
proxy_set_header X-Real-IP $remote_addr; proxy_set_header Client-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_pass http://tomcat_server; }
三.配置Nginx动静分离
nginx -t
cd /usr/local/nginx/html/
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html;charset=utf-8">
<title>静态页面</title>
<style>
body {
width: 35em;
margin: 0 auto;
font-family: Tahoma, Verdana, Arial, sans-serif;
}
</style>
</head>
<body>
<h1>静态页面</h1>
<p>这是个静态页面</p>
</body>
</html>