以上是拓扑图。
前面三台都是nginx服务器。通过第一台nginx做负债均衡。要写一个upstream 。
然后在web01和web02上搭建好同一个网站。可以先在web01上把网站搭建好,数据库和NFS客户端都连接好,然后把web01的网站代码拷贝到web02就可以了。
搭建web01就是先安装nginx和php-fpm .
先安装建立yum源
vim /etc/yum.repos.d/nginx.repo
vim /etc/yum.repos.d/php.repo
安装nginx
yum install -y nginx
systemctl enable nginx
systemctl start nginx
安装php
yum install -y php72w php72w-cli php72w-common php72w-devel php72w-embedded php72w-gd php72w-mcrypt php72w-mbstring php72w-pdo php72w-fpm php72w-mysqlnd php72w-opcache php72w-pecl-memcached php72w-pecl-redis php72w-pecl-mongodb
systemctl enable php-fpm
systemctl start php-fpm
web01下的 cat /etc/nginx/conf.d/blog.oldboylinux.cn.conf
web02下的 cat /etc/nginx/conf.d/blog.oldboylinux.cn.conf
建立一个网站的访问用户
groupadd -g 1999 www
useradd -u 1999 -g www -s /sbin/nologin -M www
建立这个用户是为了网站的安全
还有php配置文件的用户
vim /etc/php-fpm.d/www.conf
搭建NFS .
yum install -y rpcbind nfs-utils
这个1999 的就是我建立的www用户,写入到nfs配置文件里
客户端挂载nfs
如果没有相应的文件夹,就先建立。
最后安装mysql
yum install -y mariadb-server
systemctl enable mariadb
systemctl start mariadb
配置
mysql_secure_installation
创建数据库
create database wordpress;
grant all PRIVILEGES on wordpress.* to 'wp'@'%' identified by 'iso9001';
表示建立一个wp的用户,设置密码iso9001 ,然后允许所有网络可以连接