(实验准备1号机,2号机,3号机,apach-tomcat软件包)
1号机#
#vim /etc/sysconfig/network-scripts/ifcfg-ens33
BOOTPROTO=static
IPADDR=192.168.1.1 (ESC:wq)保存退出
#ifdown ens33;ifup ens33
#getenforce (显示为disabled)
#systemctl stop firewalld
2号机#
#vim /etc/sysconfig/network-scripts/ifcfg-ens33
BOOTPROTO=static
IPADDR=192.168.1.10 (ESC:wq)保存退出
#ifdown ens33;ifup ens33
#getenforce (显示为disabled)
#systemctl stop firewalld
3号机#
#vim /etc/sysconfig/network-scripts/ifcfg-ens33
BOOTPROTO=static
IPADDR=192.168.1.20 (ESC:wq)保存退出
#ifdown ens33;ifup ens33
#getenforce (显示为disabled)
#systemctl stop firewalld
2号机#
#tar zxf /root/Desktop/apach-tomcat...tar.gz -C /usr/src
#cd /usr/src
#mv apach-tomcat-8.5.16/ /usr/local/tomcat
#/usr/local/tomcat/bin/startup.sh (一号机网页测试192.168.1.10:8080初tomcat页面)
#mkdir -p /web/webapp1
#vim /web/webapp1/index.jsp
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<% out.println("welcome to 192.168.1.10");%>
(ESC:wq)保存退出
#vim /usr/local/tomcat/conf/server.xml
150行:输入
(ESC:wq)保存退出
#/usr/local/tomcat/bin/shutdonw.sh
#/usr/local/tomcat/bin/startup.sh (1号机网页测试出现输入的welcome to 192.168.1.10)
3号机#
#tar zxf /root/Desktop/apach-tomcat...tar.gz -C /usr/src
#cd /usr/src
#mv apach-tomcat-8.5.16/ /usr/local/tomcat
#/usr/local/tomcat/bin/startup.sh (一号机网页测试192.168.1.20:8080初tomcat页面)
2号机#
#scp -r /web [email protected]:/ (远程传送web目录到192.168.1.20上)
#scp /usr/local/tomcat/conf/server.xml [email protected]:/usr/local/tomcat/conf (远程传送/usr/local/tomcat/conf配置文件到192.168.1.20上)
3号机#
#cd /web/webapp1
#vim index.html
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<% out.println("welcome to 192.168.1.20");%>
(ESC:wq)保存退出
#/usr/local/tomcat/bin/shutdonw.sh
#/usr/local/tomcat/bin/startup.sh (1号机网页测试出现输入的welcome to 192.168.1.20)
1号机#
#mount /dev/cdrom /mnt
#cd /etc/yum.repos.d/
#ls (默认将第一个备份为Centos-Base.repo.bak)
#mv Centos-Base.repo Centos-Base.repo.bak
#vim Centos-Base.repo
【a】
baseurl=file:///mnt
gpgcheck=0 (ESC:wq)保存退出
#yum clean all (清除缓存)
#yum -y install pcre-devel zlib-devel openssl-devel
#useradd -M -s /sbin/nologin www
#tar zxf /root/Desktop/nginx-.....tar.gz -C /usr/src
#cd /usr/src/nginx ..../
#./configure --prefix=/usr/local/nginx --user=www --group=www --with-file-aio --with-http_stub_status_module --with-http_gzip_static_module --with-http_flv_module --with-http_ssl_module && mkae && make install
#vim /usr/local/nginx/conf/nginx.conf
20行:在default_type....下面输入
upstream tomcat_server {
server 192.168.1.10:8080 weight=1;
server 192.168.1.20:8080 weight=1;
}
49行:在index dnex..html index.html下面输入:必须在 } 符号里面输入
proxy_pass http://tomcat_server; (ESC:wq)保存退出
#nginx -t (检测一下)
#nginx (启动)
本主机浏览器测试:192.168.1.1 (刷新交互式出现网页)