實驗邏輯圖:
實驗環境:
所有伺服器均為centos6作業系統
均關閉防火牆和selinux
[[email protected] ~]# service iptables stop
[[email protected] ~]# setenforce 0
haproxy動靜分離器配置
安裝
[[email protected] ~]# yum -y install haproxy
修改配置檔案
[[email protected] ~]# vim /etc/haproxy/haproxy.cfg
配置檔案修改内容如圖:
開啟服務
[[email protected] haproxy]# service haproxy start
Starting haproxy: [ OK ]
Static_server1 配置
安裝Apache服務
[[email protected] ~]# yum -y install httpd
建立靜态測試頁面
[[email protected] ~]# echo static_111 > /var/www/html/index.html
開啟Apache服務
[[email protected] ~]# service httpd start
Static_server2 配置
安裝Apache服務
[[email protected] ~]# yum -y install httpd
建立靜态測試頁面
[[email protected] ~]# echo static_222 > /var/www/html/index.html
開啟Apache服務
[[email protected] ~]# service httpd start
Dynamic_server1 配置
安裝Apache和PHP
[[email protected] ~]# yum -y install httpd php
修改Apache配置檔案中的預設首頁
建立動态測試頁面
[[email protected] ~]# vim /var/www/html/index.php
[[email protected] ~]# cat /var/www/html/index.php
dynamic_111
<?php
phpinfo();
?>
開啟Apache服務
Dynamic_server2 配置
安裝Apache和PHP
[[email protected] ~]# yum -y install httpd php
修改Apache配置檔案中的預設首頁
建立動态測試頁面
[[email protected] ~]# vim /var/www/html/index.php
[[email protected] ~]# cat /var/www/html/index.php
dynamic_222
<?php
phpinfo();
?>