lnmp__web集群

主机角色
主机名称 ip地址
client client eth0  192.168.4.10/24

代理服务器

DNS服务器

proxy

eth0  192.168.4.5/24

eth1  192.168.2.5/24

web1服务器 web1 eth1  192.168.2.11/24
web2服务器 web2 eth1  192.168.2.12/24
web3服务器 web3 eth1  192.168.2.13/24
数据库服务器 database eth1  192.168.2.21/24
NFS服务器 nfs eth1  192.168.2.31/24

 

********************************************************************************************************************************

web2  web3安装lnp

yum install -y gcc pcre-devel openssl-devel

tar -xvf nginx-1.12.2.tar.gz

cd nginx-1.12.2

./configure  --with-http_ssl_module  --with-http_stub_status_module

make && make install

yum install -y php php-fpm php-mysql mariadb-devel

********************************************************************************************************************************

web2 web3 动静分离

vim /usr/local/nginx/conf/nginx.conf

location / {

 root html;

index index.php index.html index.htm;

}

location ~ \.php$ {

root html;

fastcgi_pass 127.0.0.1:9000;

fastcgi_index index.php;

include fastcgi.conf;

}

********************************************************************************************************************************

web2 web3启动服务,关防火墙

echo "/usr/local/nginx/sbin/nginx" >> /etc/rc.local

chmod +x /etc/rc.local

/usr/local/nginx/sbin/nginx

systemctl enable --now php-fpm

firewall-cmd --set-default-zone=trusted

setenforce 0

sed -i '/SELINUX/s/enforcingpermissive'  /etc/selinux/config

echo "/usr/local/nginx/sbin/nginx" >> /etc/rc.local

*********************************************************************************************************************************

部署nfs

yum install -y nfs-utils

mkdir /web_share

vim /etc/exports

/web_share  192.168.2.0/24(rw,no_root_squash)

systemctl enable --now rpcbind

systemctl enable --now  nfs

firewall-cmd --set-default-zone=trusted

setenforce 0

sed -i '/SELINUX/s/enforcing/permissive/' /etc/selinux/config

*********************************************************************************************************************************

网站文件迁移到nfs

cd /usr/local/nginx

tar -czvpf  html.tar.gz  html/

scp html.tar.gz   192.168.2.31:/web_share/

cd /web_share/

tar -xvf html.tar.gz

********************************************************************************************************************************

web服务器挂载共享

rm -rf /usr/local/nginx/html/*

yum install -y nfs-utils

echo "192.168.2.31:/web_share/html    /usr/local/nginx/html/  nfs defaults 0 0" >> /etc/fstab

mount -a

********************************************************************************************************************************

部署代理服务器haproxy

yum install -y haproxy

vim /etc/haproxy/haproxy.cfg

listen  wordpress *:80

balance roundrobin

server web1 192.168.2.11:80 check inter 2000 rise 2 fall 3

server web1 192.168.2.12:80 check inter 2000 rise 2 fall 3

server web1 192.168.2.13:80 check inter 2000 rise 2 fall 3

systemctl enable --now haproxy

firewall-cmd --set-default-zone=trusted

setenforce 0

sed -i '/SELINUX/s/enforcing/permissive/' /etc/selinux/config

*********************************************************************************************************************************

修改wordpress配置文件

vim /usr/local/nginx/html/wp-config.php

 

posted @ 2022-05-15 23:04  蔷薇花盛开  阅读(35)  评论(0)    收藏  举报