赞
踩
快速扩展一台WEB02服务器 1.克隆一台web02 2.安装Nginx # 配置nginx仓库 [root@web02:~]#scp 172.16.1.7:/etc/yum.repos.d/nginx.repo /etc/yum.repos.d/ # 安装Nginx服务 [root@web02:~]#yum -y install nginx 3.安装PHP [root@web02:~]#yum -y install php php-bcmath php-cli php-common php-devel php-embedded php-fpm php-gd php-intl php-mbstring php-mysqlnd php-opcache php-pdo php-process php-xml php-json 4.创建用户 [root@web02:~]#groupadd -g666 www [root@web02:~]#useradd -u666 -g666 -M -s /sbin/nologin www 5.同步Nginx和PHP的配置文件 web01有啥 web02也有啥。 [root@web02:~]#rsync -avz --delete 10.0.0.7:/etc/nginx/ /etc/nginx/ [root@web02:conf.d]#nginx -t nginx: the configuration file /etc/nginx/nginx.conf syntax is ok nginx: configuration file /etc/nginx/nginx.conf test is successful 同步PHP配置 [root@web02:~]#scp 10.0.0.7:/etc/php-fpm.d/www.conf /etc/php-fpm.d/ 6.web01同步代码文件到web02 [root@web01:~]#tar zcvf all.tar.gz /code [root@web01:~]#scp all.tar.gz 10.0.0.8:/root/ 7.web02解压代码 [root@web02:~]#ll total 108684 -rw-r--r-- 1 root root 111291678 Aug 8 10:09 all.tar.gz [root@web02:~]#tar xf all.tar.gz -C / [root@web02:~]#ll /code/ total 16 -rw-r--r-- 1 root root 4 Aug 7 08:42 index.html -rw-r--r-- 1 root root 331 Aug 6 15:37 mysql.php drwxr-xr-x 7 www www 336 Aug 7 11:45 she drwxr-xr-x 6 www www 4096 Aug 7 11:41 wp drwxr-xr-x 14 www www 4096 Aug 7 09:29 zh 7.检查配置并启动nginx和php服务 [root@web02:~]#nginx -t nginx: the configuration file /etc/nginx/nginx.conf syntax is ok nginx: configuration file /etc/nginx/nginx.conf test is successful [root@web02:~]#php-fpm -t [08-Aug-2024 10:10:44] NOTICE: configuration file /etc/php-fpm.conf test is successful [root@web02:~]#systemctl start nginx php-fpm [root@web02:~]#systemctl enable nginx php-fpm 8.hosts解析测试
NFS服务 1.安装NFS服务 yum -y install nfs-utils 2.配置NFS服务 vim /etc/exports /data/wp 172.16.1.0/24(rw,sync,all_squash,anonuid=666,anongid=666) 3.创建必要的数据 groupadd -g666 www useradd -u666 -g666 -M -s /sbin/nologin www mkdir -p /data/wp chown www.www /data/wp 4.启动NFS服务 systemctl start nfs systemctl enable nfs 配置挂载 1.将web上所有的图片推送到NFS 将最全的服务器上图片推送到NFS 目前web02最全 [root@web02:~]#scp -r /code/wp/wp-content/uploads/2024/ 10.0.0.31:/data/wp/ [root@nfs:~]#chown -R www.www /data/wp/ 2.挂载nfs共享的目录到上传的目录 web01挂载: [root@web01:~]#showmount -e 172.16.1.31 Export list for 172.16.1.31: /data/wp 172.16.1.0/24 [root@web01:~]#mount -t nfs 172.16.1.31:/data/wp /code/wp/wp-content/uploads/ WEB02挂载: [root@web02:~]#showmount -e 172.16.1.31 Export list for 172.16.1.31: /data/wp 172.16.1.0/24 [root@web02:~]#mount -t nfs 172.16.1.31:/data/wp /code/wp/wp-content/uploads/ 浏览器测试
1.克隆一台LB01 10.0.0.5 172.16.1.5 2.安装Nginx [root@lb01:~]#scp 10.0.0.7:/etc/yum.repos.d/nginx.repo /etc/yum.repos.d/ [root@lb01:~]#yum -y install nginx 3.配置Nginx 为反向代理 [root@lb01:~]#cd /etc/nginx/conf.d/ [root@lb01:conf.d]#rm -rf default.conf [root@lb01:conf.d]#cat proxy.conf server { listen 80; server_name www.wp.com; location / { proxy_pass http://172.16.1.7; } } 4.启动Nginx [root@lb01:conf.d]#nginx -t nginx: the configuration file /etc/nginx/nginx.conf syntax is ok nginx: configuration file /etc/nginx/nginx.conf test is successful [root@lb01:conf.d]#systemctl restart nginx 5.修改hosts解析到10.0.0.5
代理两个业务配置: [root@lb01:conf.d]#cat proxy.conf server { listen 80; server_name www.wp.com; location / { proxy_pass http://10.0.0.7; proxy_set_header Host $http_host; proxy_http_version 1.1; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_connect_timeout 30; proxy_send_timeout 60; proxy_read_timeout 60; proxy_buffering on; proxy_buffer_size 32k; proxy_buffers 4 128k; } } server { listen 80; server_name www.zh.com; location / { proxy_pass http://10.0.0.7; proxy_set_header Host $http_host; proxy_http_version 1.1; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_connect_timeout 30; proxy_send_timeout 60; proxy_read_timeout 60; proxy_buffering on; proxy_buffer_size 32k; proxy_buffers 4 128k; } }
mysql和web部署在一起后面才拆分
直接把mysql部署到一台单独服务器
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。