Ubuntu gearman 搭建,ubuntugearman搭建_PHP教程

來源:互聯網
上載者:User

Ubuntu gearman 搭建,ubuntugearman搭建


近階段一直在查看項目裡所使用到的一些技術點,發現了gearman,於是就動手搞了下環境,下面是來自百度百科關於gearman的介紹:

Gearman是一個用來把工作委派給其他機器、分布式的調用更適合做某項工作的機器、並發的做某項工作在多個調用間做負載平衡、或用來在調用其它語言的函數的系統。可用於sso 分發串連,但有弊端就是佔用系統資源較多,例如CPU、記憶體。

1.更新

sudo apt-get update


wgethttps://launchpad.net/gearmand/1.2/1.1.12/+download/gearmand-1.1.12.tar.gz


tarzxvf gearmand-1.1.12.tar.gz


cdgearmand-1.1.12/


./configure


configure:error: could not find boost


sudoapt-get install libboost-dev


接著重新執行:./configure


configure:error: Could not find a version of the library!


sudoapt-get install libboost-all-dev


接著重新執行:./configure


configure:error: could not find gperf


sudoapt-get install gperf*


接著重新執行:./configure


configure:error: Unable to find libevent


sudoapt-get install libevent-dev


接著重新執行:./configure


configure:error: Unable to find libuuid



安裝libuuid


這裡不能通過sudoapt-get install 來安裝了,找不到,通過下面方式安裝


wgethttp://nchc.dl.sourceforge.net/project/libuuid/libuuid-1.0.3.tar.gz


sudotar zxvf libuuid-1.0.3.tar.gz


cdlibuuid-1.0.3/


./configure


沒有錯誤的情況下繼續


sudomake


sudomake install


接下來繼續上面的安裝



./configure


sudomake && make install


這裡要等一段時間。。

根據運行結果來看並沒安裝成功,繼續往下


sudomake clean (清除上次的make命令所產生的object檔案(尾碼為“.o”的檔案)及可執行檔。)


重新安裝


./configure


sudomake


sudomake install


貌似沒有錯誤,繼續


gearman


第一次運行會看到以下提示:

gearman:error while loading shared libraries: libgearman.so.8: cannot openshared object file: No such file or directory

(這表示系統不知道libgearman.so.8 放在哪個目錄下。 要在/etc/ld.so.conf中加入libgearman.so.8所在的目錄。 檢查了下,檔案所在目錄為/usr/local/lib。 因此出現這個問題的原因是libgearman.so.8剛產生,沒有加入到ld.so.cache中,所以這時需要重新運行一下 /sbin/ldconfig(ldconfig命令的作用):)


sudo/sbin/ldconfig



此時再執行gearman則已安裝成功!


安裝完JobServer之後,用gearmand–d命令啟動


gearmand-d


第一次運行會看到以下提示:


gearmand:Could not open log file "/usr/local/var/log/gearmand.log",from "/home/wangyulu/下載/gearmand-1.1.12",switching to stderr. (No such file or directory)


在提示的目錄下建立好/log/gearmand.log檔案,再次執行上述命令,就正常啟動了jobserver。



sudogearmand -d


到這裡就已經完全ok了






安裝PHPGearman擴充


wgethttp://pecl.php.net/get/gearman-1.1.2.tgz


sudotar zxvf gearman-1.1.2.tgz


cdgearman-1.1.2/


sudophpize(這裡可能會提示沒有此命令,執行sudoapt-get install php5-dev 安裝)


sudo./configure


sudomake


sudomake install



sudoecho "extension=gearman.so" >>/etc/php5/apache2/php.ini (注意這裡php.ini位置)


sudo/etc/init.d/apache2 restart


這時查看php_info時就應該看到gearman擴充了

程式碼完成:

https://gist.github.com/andreaspag/6242671/archive/a66d18d191b880c1f8210deb612eb51b185f0892.zip

解壓後把裡面的檔案複製到相應目錄即可,如我是在用netbeans開發,我會把它放在

/usr/local/netbeans-8.1/php/phpstubs/phpruntime 這個目錄裡;

以下是安裝Job Server時的部分

PHP Gearman 擴充

http://www.bkjia.com/PHPjc/1106386.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/1106386.htmlTechArticleUbuntu gearman 搭建,ubuntugearman搭建 近階段一直在查看項目裡所使用到的一些技術點,發現了gearman,於是就動手搞了下環境,下面是來自百度百...

  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.