Server-side
#!/bin/bashfunction Nginx_install () {if [[-f/usr/sbin/nginx]]; Thenecho ' Nginx has been installed. ' Exitelseflag1=3while [[$flag 1-GT 0]]; Doyum Install epel-release-y && yum install nginx-yif [[$?-ne 0]]; Then ((flag1--)) Elseecho ' Nginx had been installed. ' Exitfidoneecho ' Nginx install failed. ' Fisystemctl start Nginx}function nginx_balancer () {msg1= ' upstream MyApp1 {server 192.168.60.129; server 192.168.60.130; Server 192.168.60.131; } ' msg2= ' Proxy_pass http://myapp1; ' Sed-ri "/^http/a $msg 1"/etc/nginx/nginx.confsed-ri "/^ *location \ \{$/a $msg 2"/etc/nginx/nginx.confsystemctl Reload Nginx}function Nfs_install () {rpm-qa |grep rpcbind >>/dev/nullif [[$?-eq 0]]; Thenecho ' Rpcbind has been install Ed ' Elseflag2=3while [[$flag 2-gt 0]; Doyum install Rpcbind-yif [[$-ne 0]]; Then ((flag2--)) Elseecho ' RPCbind have been installed. ' Exitfidoneecho ' RPCbind install failed. ' Firpm-qa |grep nfs-utils >>/dev/nullif [[$?-eq 0]]; Thenecho ' Nfs-utils has beenInstalled ' Elseflag3=3while [[$flag 3-gt 0]; Doyum install Nfs-utils-yif [[$-ne 0]]; Then ((flag3--)) Elseecho ' nfs-utils have been installed. ' Exitfidoneecho ' nfs-utils install failed. ' Fi}function Nfs_server () {mkdir/sharetouch/share/index.htmlecho '---NFS---Hello---' >/share/index.htmlchmod-r o+ W/shareecho '/share 192.168.60.0/24 (rw,sync,fsid=0) ' >>/etc/exportssystemctl start Rpcbind.service && Systemctl start Nfs-server.serviceif [[$-eq 0]]; Thenecho ' NFS server running. ' Fisystemctl Enable Rpcbind.service && Systemctl enable Nfs-server.service}nginx_installnginx_balancernfs_ Installnfs_server
Client
#!/bin/bashfunction Nginx_install () {if [[-f/usr/sbin/nginx]]; Thenecho ' Nginx has been installed. ' Exitelseflag1=3while [[$flag 1-GT 0]]; Doyum Install epel-release-y && yum install nginx-yif [[$?-ne 0]]; Then ((flag1--)) Elseecho ' Nginx had been installed. ' Exitfidoneecho ' Nginx install failed. ' Fisystemctl start Nginx}function Nfs_install () {rpm-qa |grep rpcbind >>/dev/nullif [[$?-eq 0]]; Thenecho ' Rpcbin D has been installed ' elseflag2=3while [[$flag 2-gt 0]; Doyum install Rpcbind-yif [[$-ne 0]]; Then ((flag2--)) Elseecho ' RPCbind have been installed. ' Exitfidoneecho ' RPCbind install failed. ' Firpm-qa |grep nfs-utils >>/dev/nullif [[$?-eq 0]]; Thenecho ' nfs-utils has been installed ' elseflag3=3while [[$flag 3-gt 0]; Doyum install Nfs-utils-yif [[$-ne 0]]; Then ((flag3--)) Elseecho ' nfs-utils have been installed. ' Exitfidoneecho ' nfs-utils install failed. ' Fi}function nfs_client () {systemctl start rpcbind.service && systemctl start Nfs-servEr.servicesystemctl Enable Rpcbind.service && systemctl enable nfs-server.servicemount-t NFS 192.168.60.128:/ SHARE/USR/SHARE/NGINX/HTML/DF |grep 192.168.60.128 >>/dev/nullif [[$?-eq 0]]; Thenecho ' NFS client running. ' Fi}nginx_installnfs_installnfs_client
Scripting automatic deployment of reverse proxy, Web, NFS