#!/bin/bash
IP=192.168.186.77
WG=192.168.186.2
YM=255.255.255.0
DIR=/etc/sysconfig/network-scripts
WK=ip a|grep ens33 |grep -v inet |awk '{print $2}' |awk -F: '{print $1}'
cat >
D
I
R
/
i
f
c
f
g
−
DIR/ifcfg-
DIR/ifcfg−WK <<EOF
NAME=
W
K
D
E
V
I
C
E
=
WK DEVICE=
WKDEVICE=WK
ONBOOT=yes
BOOTPROTO=none
IPADDR=
I
P
N
E
T
M
A
S
K
=
IP NETMASK=
IPNETMASK=YM
GATEWAY=
W
G
D
N
S
1
=
WG DNS1=
WGDNS1=WG
EOF
systemctl restart network
yum -y install epel-*
yum -y install nginx
mkdir /dvd
mount /dev/cdrom /dvd
mkdir /etc/yum.repos.d/111
mv /etc/yum.repos.d/.repo /etc/yum.repos.d/111
cat > /etc/yum.repos.d/dvd.repo <<EOF
[dvd]
name=dvd
baseurl=file:///dvd
enabled=1
gpgcheck=0
EOF
yum clean all
yum -y install php httpd net-tools vim bash-com
setenforce 0
sed -i s/=enforcing/=disabled/g /etc/selinux/config
systemctl restart firewalld
systemctl enable firewalld
rm -rf /etc/httpd/conf.d/welcome.conf
sed -i 42d /etc/httpd/conf/httpd.conf
cat > /etc/httpd/conf.d/abc.conf <<EOF
Listen 8001
Listen 8002
<VirtualHost *:8001>
DocumentRoot “/work/web1”
<Directory “/work/web1”>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
<VirtualHost *:1002>
DocumentRoot “/work/web2”
<Directory “/work/web2”>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
EOF
mkdir -p /work/web{1,2}
echo 1111111111 > /work/web1/index.php
echo 2222222222 > /work/web2/index.php
sed -i '38,KaTeX parse error: Expected 'EOF', got '}' at position 3: 'c}̲ /etc/nginx/ngi… {
proxy_pass http://httpd;
}
location /{
proxy_pass http://nginx;
}
}
upstream httpd {
server 127.0.0.1:8001;
server 127.0.0.1:8002;
}
upstream nginx {
server 127.0.0.1:8003;
server 127.0.0.1:8004;
}
EOF
mkdir -p /work/web{3,4}
echo 3333333333 > /work/web3/index.html
echo 4444444444 > /work/web4/index.html
systemctl start httpd
systemctl start nginx
systemctl enable httpd nginx
firewall-cmd --add-port=80/tcp
firewall-cmd --add-port=80/tcp --permanent
echo “127.0.0.1 a.com” >> /etc/hosts
负载均衡反向代理 动静分离
最新推荐文章于 2023-09-17 11:36:11 发布