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)的詳細內容,更多請關注TW511.COM其它相關文章!