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

错误:

/usr/local/src/rabbitmq-c-0.9.0/tools/publish.c:87:23: note: each undeclared identifier is reported only once for each function it appears in
gmake[2]: *** [tools/CMakeFiles/amqp-publish.dir/publish.c.o] Error 1
gmake[1]: *** [tools/CMakeFiles/amqp-publish.dir/all] Error 2
gmake: *** [all] Error 2

解决:yum -y install popt popt-devel # 还是不成功
http://freshmeat.sourceforge.net/projects/popt,源码安装 ok

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-devel
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

 

posted @ 2018-12-21 17:23  myvic  阅读(1587)  评论(0编辑  收藏  举报