網(wǎng)絡(luò)拓?fù)?/h1>
準(zhǔn)備工作:
禁用selinux,清空防火墻規(guī)則。
iptables -F
setenforce 0
配置各主機(jī)配置:
static server:
systemctl start httpd
dynamic server
yum install httpd php php-mysql php-mbstring php-mcrypt
vim /var/www/html/index.php
Dynamic Server -----three
<?php
phpinfo();
?>
nfs以及mysql服務(wù)器:
[root@centos7 ~]#yum -y install nfs-server nfs-utils mariadb-server
[root@centos7 ~]#systemctl start nfs-server.service
[root@centos7 ~]#systemctl start mariadb.service
[root@centos7 ~]#mysql_secure_installation //進(jìn)行mysql安全設(shè)置
[root@centos7 ~]#mysql -uroot -p123456 //以mysql的root身份登入猎拨。
MariaDB [(none)]> create database blogdb; //創(chuàng)建WordPress數(shù)據(jù)庫(kù)
MariaDB [(none)]> grant all on blogdb.* to wpuser@'192.168.18.%' identified by '123456';
//創(chuàng)建WordPress用戶和密碼
下載WordPress并解壓到、/app/blog下
[root@centos7 ~]#useradd -u 48 -r -s /sbin/nologin apache
[root@centos7 ~]#vim wp-config.php //直接對(duì)配置文件修改媚值,
/** WordPress數(shù)據(jù)庫(kù)的名稱 */
define('DB_NAME', 'blogdb');
/** MySQL數(shù)據(jù)庫(kù)用戶名 */
define('DB_USER', 'wpuser');
/** MySQL數(shù)據(jù)庫(kù)密碼 */
define('DB_PASSWORD', '123456');
/** MySQL主機(jī) */
define('DB_HOST', '172.16.%。%');
[root@centos7 ~]#vim /etc/exports //編輯nfs配置文件
/app/blog 192.168.18.0/24(rw,all_squash,anonuid=48,anongid=48)
掛載:
[root@centos7 ~]#vim /etc/fstab //寫進(jìn)配置文件护糖∪烀ⅲ可以以后開(kāi)機(jī)自動(dòng)掛載。
192.168.18.103:/app/blog /var/www/html/blog nfs defaults 0 0 //在最后添加這條記錄
[root@centos7 ~]#mkdir /var/www/html/blog -pv
[root@centos7 ~]#mount -a
varnish主機(jī):
Vim /etc/varnish/default.vcl
vcl 4.0;
import directors; # 導(dǎo)入負(fù)載均衡模塊
# Default backend definition. Set this to point to your content server.
probe healthchk { # 配置健康狀態(tài)檢查
.url = "/.healthchk.html"; # 檢查狀態(tài)檢查的URL
.timeout = 2s; # 超時(shí)時(shí)間
.interval = 2s;# 每2秒檢查一次
.window = 8; # 一共檢查的次數(shù)
.threshold = 5; # 如果大于4次則為健康
}
backend appsrv1 { # 配置后端主機(jī)
.host = "172.16.251.240";
.port = "80";
.probe = healthchk;
}
haproxy 主機(jī):
Vim /etc/haproxy/haproxy.cfg
frontend main
bind *:80
rspadd X-Via:\ HAProxy-1
rspidel Server.*
acl static path_end -i .html .css .js
acl static path_end -i .jpg .jpeg .gif .png
acl static path_beg -i /images /static
use_backend websrvs if static
default_backend appsrvs
listen status
bind *:9009
acl auth_admin src 192.168.52.1
stats enable
stats uri /myhaproxy?status
stats realm HAProxy\ Admin\ Area
stats auth admin:admin
stats admin if auth_admin
backend websrvs
option forwardfor header X-Client
balance uri
server web1 172.16.252.31:6081 check
hash-type consistent
backend appsrvs
option forwardfor header X-Client
balance uri
server app1 172.16.252.59:80 cookie app1 check
hash-type consistent
禁用selinux,清空防火墻規(guī)則。
iptables -F
setenforce 0
systemctl start httpd
yum install httpd php php-mysql php-mbstring php-mcrypt
vim /var/www/html/index.php
Dynamic Server -----three
<?php
phpinfo();
?>
[root@centos7 ~]#yum -y install nfs-server nfs-utils mariadb-server
[root@centos7 ~]#systemctl start nfs-server.service
[root@centos7 ~]#systemctl start mariadb.service
[root@centos7 ~]#mysql_secure_installation //進(jìn)行mysql安全設(shè)置
[root@centos7 ~]#mysql -uroot -p123456 //以mysql的root身份登入猎拨。
MariaDB [(none)]> create database blogdb; //創(chuàng)建WordPress數(shù)據(jù)庫(kù)
MariaDB [(none)]> grant all on blogdb.* to wpuser@'192.168.18.%' identified by '123456';
//創(chuàng)建WordPress用戶和密碼
下載WordPress并解壓到、/app/blog下
[root@centos7 ~]#useradd -u 48 -r -s /sbin/nologin apache
[root@centos7 ~]#vim wp-config.php //直接對(duì)配置文件修改媚值,
/** WordPress數(shù)據(jù)庫(kù)的名稱 */
define('DB_NAME', 'blogdb');
/** MySQL數(shù)據(jù)庫(kù)用戶名 */
define('DB_USER', 'wpuser');
/** MySQL數(shù)據(jù)庫(kù)密碼 */
define('DB_PASSWORD', '123456');
/** MySQL主機(jī) */
define('DB_HOST', '172.16.%。%');
[root@centos7 ~]#vim /etc/exports //編輯nfs配置文件
/app/blog 192.168.18.0/24(rw,all_squash,anonuid=48,anongid=48)
掛載:
[root@centos7 ~]#vim /etc/fstab //寫進(jìn)配置文件护糖∪烀ⅲ可以以后開(kāi)機(jī)自動(dòng)掛載。
192.168.18.103:/app/blog /var/www/html/blog nfs defaults 0 0 //在最后添加這條記錄
[root@centos7 ~]#mkdir /var/www/html/blog -pv
[root@centos7 ~]#mount -a
Vim /etc/varnish/default.vcl
vcl 4.0;
import directors; # 導(dǎo)入負(fù)載均衡模塊
# Default backend definition. Set this to point to your content server.
probe healthchk { # 配置健康狀態(tài)檢查
.url = "/.healthchk.html"; # 檢查狀態(tài)檢查的URL
.timeout = 2s; # 超時(shí)時(shí)間
.interval = 2s;# 每2秒檢查一次
.window = 8; # 一共檢查的次數(shù)
.threshold = 5; # 如果大于4次則為健康
}
backend appsrv1 { # 配置后端主機(jī)
.host = "172.16.251.240";
.port = "80";
.probe = healthchk;
}
Vim /etc/haproxy/haproxy.cfg
frontend main
bind *:80
rspadd X-Via:\ HAProxy-1
rspidel Server.*
acl static path_end -i .html .css .js
acl static path_end -i .jpg .jpeg .gif .png
acl static path_beg -i /images /static
use_backend websrvs if static
default_backend appsrvs
listen status
bind *:9009
acl auth_admin src 192.168.52.1
stats enable
stats uri /myhaproxy?status
stats realm HAProxy\ Admin\ Area
stats auth admin:admin
stats admin if auth_admin
backend websrvs
option forwardfor header X-Client
balance uri
server web1 172.16.252.31:6081 check
hash-type consistent
backend appsrvs
option forwardfor header X-Client
balance uri
server app1 172.16.252.59:80 cookie app1 check
hash-type consistent