php rabbitmq的扩展

1.下载:https://github.com/alanxz/rabbitmq-c/archive/v0.9.0.tar.gz

mkdir build && cd build # 这一步是在rabbitmq-c的根目录下创建一个build子目录 
cmake -DCMAKE_INSTALL_PREFIX=/usr/local/librabbitmq .. # 这一步是让cmake根据../CMakeList.txt,即rabbitmq-c的根目录下的CMakeList.txt创建Makefile文件,Makefile文件会被创建到build目录中
cmake --build . # 这一步是真正的build rabbitmq-c库的,注意,不要漏掉结尾的点 '.'

make

make install

2.下载php 扩展

http://pecl.php.net/get/amqp-1.9.0.tgz
tar zvxf amqp-1.9.0.tgz #解压
cd amqp-1.9.9 #打开目录
/usr/bin/phpize
./configure --with-php-config=/usr/bin/php-config --with-amqp --with-librabbitmq-dir=/usr/local/librabbitmq

make
make install
报错:
/usr/bin/ld: cannot find -lrabbitmq collect2: error: ld returned 1 exit status make: *** [amqp.la] Error 1
解决:yum install librabbitmq-dev
php -i |grep php.ini

extension=amqp.so #extension_dir自己定义
service php-fpm restart #重启

参考资料:https://www.cnblogs.com/spectrelb/p/6856246.html

https://www.jianshu.com/p/65490900a937

猜你喜欢

转载自www.cnblogs.com/myvic/p/10157043.html
今日推荐