2)创建www用户
[root@web01 PHP]# groupadd www -g 666
[root@web01 PHP]# useradd www -u 666 -g 666 -s /sbin/nologin -M
[root@web02 PHP]# groupadd www -g 666
[root@web02 PHP]# useradd www -u 666 -g 666 -s /sbin/nologin -M
[root@nfs ~]# groupadd www -g 666
[root@nfs ~]# useradd www -u 666 -g 666 -s /sbin/nologin -M
[root@db01 ~]# groupadd www -g 666
[root@db01 ~]# useradd www -u 666 -g 666 -s /sbin/nologin -M
[root@backup ~]# groupadd www -g 666
[root@backup ~]# useradd www -u 666 -g 666 -s /sbin/nologin -M
[root@web01 PHP]# vim /etc/Nginx/Nginx.conf
user www;
[root@web01 PHP]# vim /etc/PHP-fpm.d/www.conf
user = www
group = www
[root@web02 PHP]# vim /etc/Nginx/Nginx.conf
user www;
[root@web02 PHP]# vim /etc/PHP-fpm.d/www.conf
user = www
group = www
[root@web01 PHP]# vim /etc/Nginx/conf.d/blog.drz.com.conf
server {
listen 80;
server_name blog.drz.com;
root /code/wordpress;
index index.PHP index.html;
access_log /var/log/Nginx/blog.drz.com_access.log main;
location ~\.PHP$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;cd
}
}
[root@web01 PHP]# vim /etc/Nginx/conf.d/zh.drz.com.conf
server {
listen 80;
server_name zh.drz.com;
root /code/zh;
index index.PHP index.html;
access_log /var/log/Nginx/zh.drz.com_access.log main;
location ~\.PHP$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
5)创建站点目录并授权
[root@web01 PHP]# mkdir -p /code/{wordpress,zh}
6)代码上线
[root@web01 code]# tar xf wordpress-5.0.3-zh_CN.tar.gz
[root@web01 code]# unzip WeCenter_3-3-3.zip
[root@web01 code]# mkdir /code/wordpress/wp-content/uploads
[root@web01 PHP]# chown -R www.www /code/
[root@web01 code]# systemctl start Nginx PHP-fpm
[root@web01 code]# systemctl enable Nginx PHP-fpm
9)安装数据库
[root@db01 ~]# yum install -y mariadb-server
10)启动数据库
[root@db01 ~]# systemctl start mariadb
[root@db01 ~]# MysqL -uroot -pZls123.com
12)免交互创建数据库
#创建数据库
[root@db01 ~]# MysqLadmin -uroot -pZls123 create wordpress
[root@db01 ~]# MysqL -uroot -pZls123 -e 'create database zh'
#查看数据库
[root@db01 ~]# MysqL -uroot -pZls123 -e 'show databases'
[root@db01 ~]# MysqL -uroot -pZls123 -e "grant all on wordpress.* to wp@'172.16.1.%' identified by '1'"
[root@db01 ~]# MysqL -uroot -pZls123 -e "grant all on zh.* to zh@'172.16.1.%' identified by '1'"
[root@db01 ~]# MysqL -uroot -pZls123.com
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 3
Server version: 5.5.60-MariaDB MariaDB Server
copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| MysqL |
| performance_schema |
| test |
+--------------------+
4 rows in set (0.00 sec)
MariaDB [(none)]> create database wordpress;
Query OK, 1 row affected (0.00 sec)
MariaDB [(none)]> create database zh;
Query OK, 1 row affected (0.00 sec)
MariaDB [(none)]> grant all on wordpress.* to wp@'172.16.1.%' identified by 'Zls123.com';
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> grant all on zh.* to zh@'172.16.1.%' identified by 'Zls123.com';
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| MysqL |
| performance_schema |
| test |
| wordpress |
| zh |
+--------------------+
6 rows in set (0.00 sec)
MariaDB [(none)]>
密码是123
14)部署第二台web
#推送代码
[root@web01 code]# scp -r /code 172.16.1.8:/
#推送配置文件
[root@web01 ~]# scp /etc/Nginx/conf.d/* 172.16.1.8:/etc/Nginx/conf.d/
#授权
[root@web02 PHP]# chown -R www.www /code/
#删除默认虚拟主机配置文件
[root@web01 ~]# rm -f /etc/Nginx/conf.d/default.conf
[root@web02 PHP]# rm -f /etc/Nginx/conf.d/default.conf
#启动Nginx和PHP并加入开机自启
[root@web02 PHP]# systemctl start Nginx PHP-fpm
[root@web02 PHP]# systemctl enable Nginx PHP-fpm
15)共享静态资源
-
安装nfs服务端
[root@nfs ~]# yum install -y nfs-utils
[root@backup ~]# yum install -y nfs-utils
[root@nfs ~]# vim /etc/exports
/data/wordpress 172.16.1.0/24(rw,sync,all_squash,anonuid=666,anongid=666)
/data/zh 172.16.1.0/24(rw,sync,all_squash,anonuid=666,anongid=666)
[root@backup ~]# vim /etc/exports
/data/wordpress 172.16.1.0/24(rw,sync,all_squash,anonuid=666,anongid=666)
/data/zh 172.16.1.0/24(rw,sync,all_squash,anonuid=666,anongid=666)
-
创建共享目录
[root@nfs ~]# mkdir -p /data/{wordpress,zh}
[root@nfs ~]# chown -R www.www /data
[root@backup ~]# mkdir -p /data/{wordpress,zh}
[root@backup ~]# chown -R www.www /data
-
启动nfs和rpcbind
[root@nfs ~]# systemctl start nfs-server
[root@nfs ~]# systemctl enable nfs-server
[root@backup ~]# systemctl start nfs-server
[root@backup ~]# systemctl enable nfs-server
-
安装nfs客户端
[root@web01 code]# yum install -y nfs-utils
[root@web02 PHP]# yum install -y nfs-utils
-
查看挂载点
[root@web01 code]# showmount -e 172.16.1.31
Export list for 172.16.1.31:
/data/zh 172.16.1.0/24
/data/wordpress 172.16.1.0/24
[root@web01 code]# showmount -e 172.16.1.41
Export list for 172.16.1.41:
/data/zh 172.16.1.0/24
/data/wordpress 172.16.1.0/24
[root@web02 PHP]# showmount -e 172.16.1.31
Export list for 172.16.1.31:
/data/zh 172.16.1.0/24
/data/wordpress 172.16.1.0/24
[root@web02 PHP]# showmount -e 172.16.1.41
Export list for 172.16.1.41:
/data/zh 172.16.1.0/24
/data/wordpress 172.16.1.0/24
-
挂载
[root@web01 code]# mount -t nfs 172.16.1.31:/data/wordpress /code/wordpress/wp-content/uploads/
[root@web01 code]# mount -t nfs 172.16.1.31:/data/zh /code/zh/uploads/
[root@web02 PHP]# mount -t nfs 172.16.1.31:/data/wordpress /code/wordpress/wp-content/uploads/
[root@web02 PHP]# mount -t nfs 172.16.1.31:/data/zh /code/zh/uploads/
16)部署rsync和sersync
-
安装rsync服务端
[root@backup ~]# yum install -y rsync
[root@backup ~]# vim /etc/rsyncd.conf
uid = www
gid = www
port = 873
fake super = yes
use chroot = no
max connections = 200
timeout = 600
ignore errors
read only = false
list = false
auth users = rc
secrets file = /etc/rsync.passwd
log file = /var/log/rsyncd.log
#####################################
[nfs]
comment = welcome to oldboyedu backup!
path = /data
-
创建密码文件并授权
[root@backup ~]# echo 'rc:123' > /etc/rsync.passwd
[root@backup ~]# chmod 600 /etc/rsync.passwd
-
启动rsyncd
[root@backup ~]# systemctl start rsyncd
17)客户端部署sersync
-
安装rsync和inotify-tools
[root@nfs ~]# yum install -y rsync inotify-tools
-
安装sersync
[root@nfs ~]# tar xf sersync2.5.4_64bit_binary_stable_final.tar.gz
[root@nfs ~]# mv GNU-Linux-x86/ /usr/local/sersync
[root@nfs ~]# vim /usr/local/sersync/confxml.xml
<sersync>
<localpath watch="/data">
<remote ip="172.16.1.41" name="nfs"/>
<!--<remote ip="192.168.8.39" name="tongbu"/>-->
<!--<remote ip="192.168.8.40" name="tongbu"/>-->
</localpath>
<rsync>
<commonParams params="-az"/>
<auth start="true" users="rc" passwordfile="/etc/rsync.pass"/>
<userDefinedPort start="false" port="874"/><!-- port=874 -->
<timeout start="true" time="100"/><!-- timeout=100 -->
<ssh start="false"/>
</rsync>
<failLog path="/tmp/rsync_fail_log.sh" timetoExecute="60"/><!--default every 60mins execute once-->
<crontab start="false" schedule="600"><!--600mins-->
<crontabfilter start="false">
<exclude expression="*.PHP"></exclude>
<exclude expression="info/*"></exclude>
</crontabfilter>
</crontab>
<plugin start="false" name="command"/>
</sersync>
-
创建密码文件并授权
[root@nfs ~]# echo 123 > /etc/rsync.pass
[root@nfs ~]# chmod 600 /etc/rsync.pass
-
启动sersync
[root@nfs ~]# /usr/local/sersync/sersync2 -rdo /usr/local/sersync/confxml.xml
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。