目前使用Centos6.x系統,php使用7.1版本,wlnmp一鍵套件已支援此擴充功能
php7安裝amqp擴充功能(基於Centos7.x)參考:https://www. php.cn/topic/php7/437499.html
amqp擴充位址:
https://pecl.php.net/package/amqp
與Centos7不同的是,在Centos6.x環境下需要手動編譯rabbitmq-c,否則會看到如下報錯
amqp-1.9.4/amqp.c: In function ‘zm_startup_amqp’: amqp-1.9.4/amqp.c:177: error: ‘AMQP_SASL_METHOD_EXTERNAL’ undeclared (first use in this function) amqp-1.9.4/amqp.c:177: error: (Each undeclared identifier is reported only once amqp-1.9.4/amqp.c:177: error: for each function it appears in.) make: *** [amqp.lo] Error 1
1、安裝所需依賴,如果在編譯時還提示缺少其他依賴,請自行安裝
yum install autoconf gcc gcc-c++ cmake librabbitmq-devel librabbitmq
2、編譯rabbitmq-c
注意:rabbitmq-c-0.9.0與rabbitmq-c-0.8.0版本編譯方式不同,我這裡以最新的0.9.0為例
wget https://github.com/alanxz/rabbitmq-c/archive/v0.9.0.tar.gz tar xf v0.9.0.tar.gz cd rabbitmq-c-0.9.0/ mkdir build && cd build cmake .. make make install
Install the project... -- Install configuration: "Release" -- Installing: /usr/local/lib64/pkgconfig/librabbitmq.pc -- Installing: /usr/local/lib64/librabbitmq.so.4.3.0 -- Installing: /usr/local/lib64/librabbitmq.so.4 -- Installing: /usr/local/lib64/librabbitmq.so -- Installing: /usr/local/lib64/librabbitmq.a -- Installing: /usr/local/include/amqp.h -- Installing: /usr/local/include/amqp_framing.h -- Installing: /usr/local/include/amqp_tcp_socket.h -- Installing: /usr/local/include/amqp_ssl_socket.h
3、下載amqp最新穩定版
wget https://pecl.php.net/get/amqp-1.9.4.tgz tar xf amqp-1.9.4.tgz cd amqp-1.9.4 /usr/local/php/bin/phpize
依照自己phpize的位置來運作即可(不知道phpize在哪的直接find / -name phpize查找),執行完提示下面信息,然後編譯
Configuring for: PHP Api Version: 20160303 Zend Module Api No: 20160303 Zend Extension Api No: 320160303
4、編譯擴充模組
./configure --with-php-config=/usr/local/php/bin/php-config make make install
執行完成後會顯示擴充模組編譯到的目錄/usr/local/php/lib /php/extensions/no-debug-non-zts-20160303/
5、修改php.ini新增擴充功能
extension_dir = "/usr/local/php/lib/php/extensions/no-debug-non-zts-20160303/" extension=amqp.so
注意:如果之前配置過extension_dir路徑了,則只需設定extension=amqp.so即可
儲存退出,重啟php
透過phpinfo可看到,擴充已生效
##更多相關PHP7內容請造訪:《PHP7》教學#
以上是php7安裝amqp擴充的方法(基於Centos6.x)的詳細內容。更多資訊請關注PHP中文網其他相關文章!