ubuntu下手動安裝php-amqp模組教程

來源:互聯網
上載者:User

標籤:oar   .com   color   port   target   with   內容   this   rabbit   

用於ubuntu的預設源裡面沒有php5-amqp這個包,所以要用上amqp得考手動編譯。

參考手冊 http://php.net/manual/pl/book.amqp.php

首先安裝必須的php編譯工具

[html] view plain copy
  1. sudo apt-get install php5-dev  


安裝rabbitmq的庫

[html] view plain copy
  1. sudo apt-get install librabbitmq-dev  


如果你的Linux發行版沒有現成的librabbitmq-dev包,那麼可以通過下載源碼編譯安裝
然後如果你沒有安裝git話請安裝一下git,因為我們要從官方的版本庫中擷取原始碼
# 複製源碼並編譯

[html] view plain copy
  1. git clone git://github.com/alanxz/rabbitmq-c.git  
  2. cd rabbitmq-c  
  3. git submodule init  
  4. git submodule update  


# 編譯庫

[html] view plain copy
  1. autoreconf -i && ./configure && make && sudo make install  


然後我們需要去下載php擴充的原始碼,地址在此:http://pecl.php.net/package/amqp

當前最新版本為1.0.10

[html] view plain copy
  1. wget http://pecl.php.net/get/amqp-1.0.10.tgz  
  2. tar zxf amqp-1.0.10.tgz  
  3. cd amqp-1.0.10/  
  4. phpize && ./configure --with-amqp && make && sudo make install  

如果報錯

[html] view plain copy
  1. /root/amqp-1.0.9/amqp_queue.c: In function ‘read_message_from_channel’:  
  2. /root/amqp-1.0.9/amqp_queue.c:341:11: error: ‘AMQP_FIELD_KIND_U64’ undeclared (first use in this function)  
  3. /root/amqp-1.0.9/amqp_queue.c:341:11: note: each undeclared identifier is reported only once for each function it appears in  
  4. /root/amqp-1.0.9/amqp_queue.c: In function ‘zim_amqp_queue_class_nack’:  
  5. /root/amqp-1.0.9/amqp_queue.c:1093:2: error: unknown type name ‘amqp_basic_nack_t’  
  6. /root/amqp-1.0.9/amqp_queue.c:1113:3: error: request for member ‘delivery_tag’ in something not a structure or union  
  7. /root/amqp-1.0.9/amqp_queue.c:1114:3: error: request for member ‘multiple’ in something not a structure or union  
  8. /root/amqp-1.0.9/amqp_queue.c:1115:3: error: request for member ‘requeue’ in something not a structure or union  
  9. /root/amqp-1.0.9/amqp_queue.c:1120:3: error: ‘AMQP_BASIC_NACK_METHOD’ undeclared (first use in this function)  
  10. make: *** [amqp_queue.lo] Error 1  


是因為預設的librabbitmq-dev發行版的包比較舊,用上面git方式編譯安裝最新即可。

去下載最新的php擴充的原始碼,地址在此:http://pecl.php.net/package/amqp

  1. wget http://pecl.php.net/get/amqp-x.x.x.tgz  
  2. tar zxf amqp-x.x.x.tgz  
  3. cd amqp-x.x.x/  
  4. 繼續執行
  5. phpize && ./configure --with-amqp && make && sudo make install

最後一步建立設定檔

[html] view plain copy
  1. sudo echo "extension = amqp.so" > /etc/php5/conf.d/amqp.ini  


重啟web伺服器在phpinfo頁面中看到以下內容說明安裝好了

sudo /etc/init.d/apache2 restart

http://localhost/phpinfo.php

ubuntu下手動安裝php-amqp模組教程

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.