(实验准备1号机,2号机,3号机,4号机网卡统一、nginx软件包)
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.2 (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.3 (ESC:wq)保存退出
#ifdown ens33;ifup ens33
#getenforce (显示为disabled)
#systemctl stop firewalld
4号机#
#vim /etc/sysconfig/network-scripts/ifcfg-ens33
BOOTPROTO=static
IPADDR=192.168.1.4 (ESC:wq)保存退出
#ifdown ens33;ifup ens33
#getenforce (显示为disabled)
#systemctl stop firewalld
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-http_stub_status_module --with-file-aio --with-http_gzip_static_module --with-http_flv_module --with-http_ssl_module && make && make install (可以选择行安装选项)
#vim /usr/local/nginx/conf/nginx.conf
20行:在default_type....下面输入
upstream http_server {
server 192.168.1.2 weight=1;
server 192.168.1.3 weight=1;
}
49行:在index dnex..html index.html下面输入:必须在 } 符号里面输入
proxy_pass http://http_server; (ESC:wq)保存退出
#nginx -t (检测一下)
#nginx (启动)
2号机#
#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 httpd
#echo " 192.168.1.2" > /var/www/html/index.html
#systemctl start httpd
3号机#
# 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 httpd
#echo " 192.168.1.3" > /var/www/html/index.html
#systemctl start httpd
本主机测试ipv4:192.168.1.10 255.255.255.0 浏览器输入:192.168.1.1 (出现两个网页刷新交互出现)
4号机#
#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 nfs-utils rpcbind
#mkdir /webroot/
#echo "www.benet.com192.168.1.4" > /webroot/index.html
#vim /etc/exports
/webroot 192.168.1.0/24(rw,sync,no_root_squash) (ESC:wq)保存退出
#systemctl start rpcbind
#systemctl start nfs
#showmount -e 127.0.0.1 (出现list for 127.0.0.1 /webroot 192.168.1.0/24)
2号机#
#showmount -e 192.168.1.4 (出现list for 127.0.0.1 /webroot 192.168.1.0/24)
#mount 192.168.1.4:/webroot /var/www/html
3号机#
#showmount -e 192.168.1.4 (出现list for 127.0.0.1 /webroot 192.168.1.0/24)
#mount 192.168.1.4:/webroot /var/www/html
本主机浏览器测试192.168.1.1 直连nfs出现www.benet.com 192.168.1.4