一、web01服务器搭建
1.安装nginx
[root@web01 ~]#vim /etc/yum.repos.d/nginx.repo
[root@web01 ~]#yum -y install nginx
2.安装php
[root@web01 ~]#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
3.创建用户
[root@web01 /etc/nginx/conf.d]#groupadd -g666 www
[root@web01 /etc/nginx/conf.d]#useradd -u666 -g666 -M -s /sbin/nologin www
4.修改nginx、php配置文件
[root@web01 /etc/nginx/conf.d]#cat /etc/nginx/nginx.conf |egrep 'user|client'
user www;
client_max_body_size 1024m;
[root@web01 /etc/nginx/conf.d]#sed -n '24p;26p;38p' /etc/php-fpm.d/www.conf
user = www
group = www
listen = 127.0.0.1:9000
[root@web01 /etc/nginx/conf.d]#cat wp.conf
server{
listen 80;
server_name www.wp.com;
root /code/wordpress;
index index.php index.html;
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
5.创建代码目录并下载代码
[root@web01 ~]#mkdir /code
[root@web01 /code]#wget https://cn.wordpress.org/wordpress-5.0.3-zh_CN.tar.gz
[root@web01 /code]#tar xf wordpress-5.0.3-zh_CN.tar.gz
6.修改代码属主属组
[root@web01 /code]#chown -R www.www wordpress/
7.启动nginx、php
[root@web01 /code]#systemctl enable --now nginx
[root@web01 /code]#systemctl enable --now php-fpm
二、mysql服务器搭建
1.安装数据库mariadb-server
[root@mysql ~]#yum -y install mariadb-server
2.创建密码 并创建普通用户
[root@mysql ~]#systemctl enable --now mariadb
[root@mysql ~]#mysqladmin password 'lzy123.com'
MariaDB [(none)]> grant all on *.* to lzy@'%' identified by 'lzy123.com';
3.创建表
MariaDB [(none)]> create database wordpress;
三、web02服务器搭建
1.安装nginx、安装php
[root@web01 /code]#scp /etc/yum.repos.d/nginx.repo 172.16.1.8:/etc/yum.repos.d/
[root@web02 ~]#yum -y install nginx
[root@web01 ~]#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
2.同步配置文件
[root@web01 /code]#rsync -avz --delete /etc/nginx/ 172.16.1.8:/etc/nginx
[root@web01 /code]#scp /etc/php-fpm.d/www.conf 172.16.1.8:/etc/php-fpm.d
3.同步代码
[root@web01 /code]#scp -r /code 172.16.1.8:/
4.创建用户
[root@web02 /code]#groupadd -g666 www
[root@web02 /code]#useradd -u666 -g666 -M -s /sbin/nologin www
[root@web02 /code]#chown -R www.www wordpress/
5.启动服务
[root@web02 /code]#systemctl enable --now nginx
[root@web02 /code]#systemctl enable --now php-fpm
四、lb服务器搭建
1.安装nginx
[root@web01 /code]#scp /etc/yum.repos.d/nginx.repo 172.16.1.5:/etc/yum.repos.d/
[root@lb ~]#yum -y install nginx
2.配置负载均衡
[root@lb /etc/nginx/conf.d]#cat lb.conf
upstream webs {
server 172.16.1.7;
server 172.16.1.8;
}
server {
listen 80;
server_name www.wp.com;
location / {
proxy_pass http://webs;
include proxy_params;
}
}
[root@lb /etc/nginx/conf.d]#cat proxy_params
proxy_set_header Host $http_host;
proxy_http_version 1.1;
proxy_connect_timeout 30;
proxy_send_timeout 60;
proxy_read_timeout 60;
proxy_buffering on;
proxy_buffer_size 32k;
proxy_buffers 4 128k;
3.启动nginx
五、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)
创建目录和用户
groupadd -g666 www
useradd -u666 -g666 -M -s /sbin/nologin www
mkdir /code/wp -p
chown www.www /data/wp
3.启动nfs服务
systemctl start nfs
systemctl enable nfs
4.将完整的图片拷贝到31服务器
[root@web02 ~]# scp -r /code/wordpress/wp-content/uploads/* 10.0.0.31:/data/wp/
5.挂载
[root@web01 /code/wordpress/wp-content]#mount -t nfs 172.16.1.31:data/wp /code/wordpress/wp-content/uploads/
Comments NOTHING