項目規劃圖:
項目概述:
如上圖所述,部署lnmp環境,實現nginx負載均衡後端的兩個nginx web服務,要求在nginx上搭建wordpress應用。
項目實現
-
搭建php-fpm服務器
安裝php-fpm包及相關包yum install php php-fpm php-mcrypt php-mysql php-mbstring mariadb-server -y
編輯/etc/php-fpm.d/www.conf的內容
啓動php-fpm服務
安裝mariadb數據庫yum install -y mariadb
編輯/etc/my.conf
啓動mariadb,進入數據庫
在數據庫中創建wordpress的數據庫wpdb
授權wpuser管理賬號
創建資源頁面目錄文件
下載wordpress應用,並放到資源目錄下
對wordpress做好鏈接
創建測試頁面
關閉防火牆firewalld和Selinux - 搭建nginx-server服務器
編輯/etc/nginx/conf.d/vhost文件
創建頁面資源目錄
下載wordpress應用。並做好鏈接
啓動服務,並關閉防火牆和Selinux
nginx-server2服務器的配置同1
3.配置nginx負載均衡服務器nginx-gw
編輯/etc/ginx/conf.d/vhosts文件,寫入代理配置
爲驗證負載均衡服務器是否生效,在nginx-server1與2兩臺服務器上做測試頁面
nginx-server1:
nginx-server2:
啓動負載均衡器nginx服務,並關閉firewall和Selinux
4.測i是負載均衡和fastcgi代理是否實現
負載均衡測試
fastcgi代理測試
由上說明我們的lnmp環境下的負載均衡已實現。
5.安裝wordpress應用
訪問www.lishauyang.com/blog,按照網頁提示進行安裝
填寫數據庫信息
安提供的代碼創建wp-config.php文件
註冊賬號賬號後便創建成功了