一、dns的搭建
安装dns服务
yum install bind
修改dns的主配置文件
1 [root@234c17 named]# vim /etc/named.conf 2 3 // 4 5 // named.conf 6 7 // 8 9 // Provided by Red Hat bind package to configure the ISC BIND named(8) DNS 10 11 // server as a caching only nameserver (as a localhost DNS resolver only). 12 13 // 14 15 // See /usr/share/doc/bind*/sample/ for example named configuration files. 16 17 // 18 19 // See the BIND Administrator's Reference Manual (ARM) for details about the 20 21 // configuration located in /usr/share/doc/bind-{version}/Bv9ARM.html 22 23 options { 24 25 // listen-on port 53 { 127.0.0.1; }; //将其注释掉, 26 27 listen-on-v6 port 53 { ::1; }; 28 29 directory "/var/named"; 30 31 dump-file "/var/named/data/cache_dump.db"; 32 33 statistics-file "/var/named/data/named_stats.txt"; 34 35 memstatistics-file "/var/named/data/named_mem_stats.txt"; 36 37 // allow-query { localhost; }; //将其注释掉, 38
修改dns服务的rfc192.zones,增加zone
1 [root@234c17 named]# vim /etc/named.rfc1912.zones 2 3 // named.rfc1912.zones: 4 5 // 6 7 // Provided by Red Hat caching-nameserver package 8 9 // 10 11 // ISC BIND named zone configuration for zones recommended by 12 13 // RFC 1912 section 4.1 : localhost TLDs and address zones 14 15 // and http://www.ietf.org/internet-drafts/draft-ietf-dnsop-default-local-zones-02.txt 16 17 // (c)2007 R W Franks 18 19 // 20 21 // See /usr/share/doc/bind*/sample/ for example named configuration files. 22 23 // 24 25 zone "gdkj.com" IN { 26 27 type master; 28 29 file "gdkj.com.zone"; 30 31 };
新建zone文件
1 [root@234c17 named]# vim gdkj.com.zone 2 3 $TTL 1D 4 5 @ IN SOA dns1 admin.gdkj.com. ( 1 1D 3H 1W 2D ) 6 7 NS dns1 8 9 dns1 A 192.168.234.17 10 11 www A 192.168.234.27 12 13 www A 192.168.234.37
修改windows的dns地址后windows能通
mysql的准备
//安装mysql服务启动
yum install mariadb-server
systemctl start mariadb
创建wordpress数据库和帐号
1 MariaDB [(none)]> create database wpdb 2 3 -> ; 4 5 Query OK, 1 row affected (0.00 sec) 6 7 MariaDB [(none)]> grant all on wpdb.* to wpuser@"192.168.234.27" identified by "centos"; 8 9 Query OK, 0 rows affected (0.00 sec) 10 11 MariaDB [(none)]> grant all on wpdb.* to wpuser@"192.168.234.37" identified by "centos";
nfs服务配置在此共享wordpress目录
下载worfpress软件包 准备配置文件
mkdir -p /data/www tar xf wordpress-4.9.4-zh_CN.tar.gz -C /data/ cd /data/ mv wordpress www mv wp-config-sample.php wp-config.php
wordpress与mysql的连接的修改
1 [root@234c47 exports.d]# vim wp-config.php 2 3 // ** MySQL 设置 - 具体信息来自您正在使用的主机 ** // 4 5 /** WordPress数据库的名称 */ 6 7 define('DB_NAME', 'wpdb'); 8 9 /** MySQL数据库用户名 */ 10 11 define('DB_USER', 'wpuser'); 12 13 /** MySQL数据库密码 */ 14 15 define('DB_PASSWORD', 'centos'); 16 17 /** MySQL主机 */ 18 19 define('DB_HOST', '192.168.234.57');
现在配置nfs的共享
[root@234c47 exports.d]# vim /etc/exports.d/www.exports ///新建共享配置文件 /data/www 192.168.234.0/24(rw,all_squash,anonuid=48,anongid=48) //让webservice1和webservice2拥有本机wordpress的共享权限 useradd -u 48 apache //然后新建一个apache帐号 systemctl start nfs-server //配置完成启动服务
web服务的配置
上面已经搭建好了mysql 准备好了wordpress文件及nfs共享
那么现在将远程的nfs共享目录挂载到本机目录
安装服务
yum install httpd php-fpm php-mysql
//修改webservice1的的配置 [root@234c27 httpd]# vim /etc/fstab 192.168.234.47:/data/www /var/www/html nfs defaults 0 0 //修改webservice1的的配置 [root@234c37 httpd]# vim /etc/fstab 192.168.234.47:/data/www /var/www/html/ nfs defaults 0 0
修改代理webserivce1
1 [root@234c27 httpd]# vim /etc/httpd/conf.d/fcgi.conf 2 3 ProxyRequests Off 4 5 ProxyPassMatch ^/(.*.php)$ fcgi://127.0.0.1:9000/var/www/html/$1
修改代理webserivce2
1 [root@234c37 httpd]# vim /etc/httpd/conf.d/fcgi.conf 2 3 ProxyRequests Off 4 5 ProxyPassMatch ^/(.*.php)$ fcgi://127.0.0.1:9000/var/www/html/$1
测试成功
备注:
一、期间因为挂载目录的不熟悉,将192.168.234.47:/data/www 挂载自本机的/var/www/html/www 导致错误。
二、实验图可扩展为dns的泛域名解析以及nfs的rsync和mysql的主从,及其他高可用