標籤:style blog http color 使用 os
centos安裝gearmanpost by rocdk890 / 2012-8-4 1:11 Saturday linux技術發表評論 今天公司讓我在伺服器上安裝gearman,伺服器環境是lamp,那gearman是什麼?其實這個gearman是一個處理分布式過程通訊的健壯系統.它提供了一個通用的應用程式架構,主要用來把任務轉寄給到其他機器或進程.使用Gearman 能讓程式實現並行工作、負載平衡和跨語言調用.它能夠用於不同類型的應用程式,從高可用的web網站到資料庫複寫傳輸.
系統:centos 5.5
需要的軟體包:boost_1_50_0.tar.gz gearman-1.0.2.tgz gearmand-0.34.tar.gz
1.安裝boost
如果不安裝boost的話,是安裝不上gearmand和gearman的.
wget -c http://download.slogra.com/gearman/boost_1_50_0.tar.gz
tar zxf boost_1_50_0.tar.gz && cd boost_1_50_0
./bootstrap.sh --prefix=/usr/local/boost
如出現,則輸入命令:
./b2 install
這一步安裝等待的時間比較久,各位可以去喝個茶,休息休息下.
如沒有問題,在/etc/profile裡的最下方加入:
export CPPFLAGS=-I/usr/local/boost/include
export LDFLAGS=-L/usr/local/boost/lib
儲存退出後運行
source /etc/profile
好了,boost就安裝成功了.
2.安裝gearmand
wget -c http://download.slogra.com/gearman/gearmand-0.34.tar.gz
tar zxf gearmand-0.34.tar.gz && cd gearmand-0.34
./configure --prefix=/usr/local/gearman
如果出現configure: error: Unable to find libevent,則輸入命令:
yum -y install libevent libevent-devel
然後重新configure.
沒有問題後再執行
make
這步出現./libgearman-1.0/gearman.h:53:27: error: tr1/cinttypes: No such file or directory錯誤,可以推斷是gcc編譯器的問題,執行命令:
yum install gcc44 gcc44-c++ libstdc++44-devel -y
然後在環境變數裡加入:
export CC=/usr/bin/gcc44 or export CC=/usr/bin/gcc
export CXX=/usr/bin/g++44
儲存退出後執行:
source /etc/profile
刪除gearmand-0.34檔案夾重新進行編譯.
重新進行編譯後執行make這步,
沒有報錯的話才能繼續執行
make install
如果沒有報錯的話,那麼恭喜你可以繼續安裝gearman了.
3.安裝gearman
gearman是要整合到php中,所以你必須得有lamp環境.我伺服器上已經有lamp環境,所以接下來就直接進行安裝.
wget -c http://download.slogra.com/gearman/gearman-1.0.2.tgz
tar zxf gearman-1.0.2.tgz && cd gearman-1.0.2
/usr/local/php/bin/phpize
./configure --with-gearman=/usr/local/gearman/ --with-php-config=/usr/local/php/bin/php-config
make && make install
沒有報錯的話,去php.ini添加擴充語句
vi /etc/php.ini
extension=gearman.so
extension_dir = "/usr/local/php/lib/php/extensions/no-debug-non-zts-20090626/"
重啟httpd
service httpd restart
好了,到此就全部安裝成功.