資源描述:
《lvs keepalived nginx apache搭建高可用、高性能php集群》由會員上傳分享,免費(fèi)在線閱讀,更多相關(guān)內(nèi)容在行業(yè)資料-天天文庫。
1、LVS+keepalived+nginx+apache搭建高可用、高性能php集群2011-07-0112:04:30標(biāo)簽:php?mysql?apache?集群?nginx原創(chuàng)作品,允許轉(zhuǎn)載,轉(zhuǎn)載時請務(wù)必以超鏈接形式標(biāo)明文章?原始出處?、作者信息和本聲明。否則將追究法律責(zé)任。http://kerry.blog.51cto.com/172631/600590?????基于PHP的運(yùn)行環(huán)境大家用的比較多的是以apache做中間件的LAMP(linux+apache+mysql+php)環(huán)境和以nginx做中間件的LNMP(lin
2、ux+nginx+mysql+php)環(huán)境,apache是世界排名第一的web服務(wù)器,apache可以整合大多數(shù)應(yīng)用,比如jsp,php,cgi,python等等,但是apache過于臃腫以及對靜態(tài)文件響應(yīng)過于緩慢是讓人很不滿意的;而nginx作為后起之秀,大有超越前輩的勢頭,從最近很多門戶網(wǎng)站選用nginx就可見一斑,nginx速度快,占用資源少,高性能轉(zhuǎn)發(fā),很高的穩(wěn)定性,支持熱部署,殺手級的proxy和rewrite,但nginx對于php處理依托于fastcgi,fastcgi不夠穩(wěn)定,經(jīng)常出現(xiàn)502錯誤,生成相對復(fù)雜的
3、頁面沒有優(yōu)勢,反而會使php-cgi進(jìn)程變?yōu)榻┦M(jìn)程,多用戶多站點(diǎn)的安全性不高,對于其它開發(fā)語言的整合,apache表現(xiàn)的更好;綜上述對比,為了搭建高性能的php運(yùn)行環(huán)境,就要考慮對apache、nginx進(jìn)行整合,各取所長,nginx在處理靜態(tài)內(nèi)容上的效率較apache強(qiáng)很大,那么就用nginx在前端處理靜態(tài)文件,把基于php的動態(tài)文件轉(zhuǎn)發(fā)到后端的apache來處理,接下來我們就開始布署LNAMP(linux+nginx+apache+mysql+php)環(huán)境一、網(wǎng)絡(luò)拓?fù)??lvs-master:192.168.9.221L
4、VS-backup:192.168.9.222LVS-VIP:192.168.9.220web_server_1:192.168.9.223web_server_2:192.168.9.224nfs_server_1:192.168.9.228nfs_server_1:192.168.9.229nfs_vip:192.168.9.230mysql_master:192.168.9.226mysql_backup:192.168.9.227mysql_vip:192.168.9.225目的:搭建高可用、高性能的php集群二、初始
5、化系統(tǒng)#initsystem系統(tǒng)環(huán)境:CentOS5.5(最小化安裝)./init_system.sh???#此腳本參見http://kerry.blog.51cto.com/172631/555535#更新組件sudo-sLANG=Cyum-yinstallgccgcc-c++bisonpatchunzipmlocateflexwgetautomakeautoconfgdcppgettextreadline-devellibjpeglibjpeg-devellibpnglibpng-develfreetypefreetyp
6、e-devellibxml2libxml2-develzlibzlib-develglibcglibc-develglib2glib2-develbzip2bzip2-develncursesncurses-develcurlcurl-devele2fsprogse2fsprogs-devellibidnlibidn-developenldapopenldap-developenldap-clientsopenldap-serversnss_ldapexpat-devellibtoollibtool-ltdl-develb
7、ison三、LVS+keeplived#關(guān)于LVS+keeplived的配置請參考我的另一篇博文《CentOS5.5環(huán)境下布署LVS+keepalived》http://kerry.blog.51cto.com/172631/401253四、web_server安裝配置(nginx、apache整合)#downloadsoftwarecd/optwget?http://nginx.org/download/nginx-1.0.4.tar.gzwget?http://www.apache.org/dist/httpd/httpd
8、-2.2.19.tar.gzwget?http://www.cmake.org/files/v2.8/cmake-2.8.4.tar.gzwget?http://mysql.he.net/Downloads/MySQL-5.5/mysql-5.5.13.tar.gzwget?