php7.2.4安装rabbitmq扩展的过程中错误处理

1、根据自己php的版本选择amqp包的版本,我开始随便选择了amqp-1.6.1.tar.gzmake之后出现如下错误:

/opt/amqp-1.6.1/amqp.c:984:37: error: too many arguments to function ‘zend_register_internal_class_ex’
  amqp_queue_exception_class_entry = zend_register_internal_class_ex(&ce, amqp_exception_class_entry, NULL TSRML
                                     ^
In file included from /usr/local/php/include/php/main/php.h:39:0,
                 from /opt/amqp-1.6.1/amqp.c:30:
/usr/local/php/include/php/Zend/zend_API.h:303:28: note: declared here
 ZEND_API zend_class_entry *zend_register_internal_class_ex(zend_class_entry *class_entry, zend_class_entry *par
                            ^
/opt/amqp-1.6.1/amqp.c:987:40: error: too many arguments to function ‘zend_register_internal_class_ex’
  amqp_exchange_exception_class_entry = zend_register_internal_class_ex(&ce, amqp_exception_class_entry, NULL TS
                                        ^
In file included from /usr/local/php/include/php/main/php.h:39:0,
                 from /opt/amqp-1.6.1/amqp.c:30:
/usr/local/php/include/php/Zend/zend_API.h:303:28: note: declared here
 ZEND_API zend_class_entry *zend_register_internal_class_ex(zend_class_entry *class_entry, zend_class_entry *par
                            ^
Makefile:194: recipe for target 'amqp.lo' failed
make: *** [amqp.lo] Error 1

以上错误只粘贴了最后部分

通过分析之后,把问题定位到可能是由于amqp的版本引起的

2、通过阅读官网更新日志,选择1.8版本进行尝试

下载地址: https://pecl.php.net/get/amqp-1.8.0.tgz

----------------------------------------------------------------------
Libraries have been installed in:
   /opt/amqp-1.8.0/modules

If you ever happen to want to link against installed libraries
in a given directory, LIBDIR, you must either use libtool, and
specify the full pathname of the library, or use the `-LLIBDIR'
flag during linking and do at least one of the following:
   - add LIBDIR to the `LD_LIBRARY_PATH' environment variable
     during execution
   - add LIBDIR to the `LD_RUN_PATH' environment variable
     during linking
   - use the `-Wl,--rpath -Wl,LIBDIR' linker flag
   - have your system administrator add LIBDIR to `/etc/ld.so.conf'

See any operating system documentation about shared libraries for
more information, such as the ld(1) and ld.so(8) manual pages.
----------------------------------------------------------------------

Build complete.
Don't forget to run 'make test'.

root@thinkpad:/opt/amqp-1.8.0# make install
Installing shared extensions:     /usr/local/php/lib/php/extensions/no-debug-non-zts-20170718/

编辑php.ini

php --ini

root@thinkpad:/opt/amqp-1.8.0# php --ini
Configuration File (php.ini) Path: /usr/local/php/lib
Loaded Configuration File:         /usr/local/php/lib/php.ini
Scan for additional .ini files in: (none)
Additional .ini files parsed:      (none)
root@thinkpad:/opt/amqp-1.8.0# vim /usr/local/php/lib/php.ini

最后一行添加

extension = /usr/local/php/lib/php/extensions/no-debug-non-zts-20170718/amqp.so

安装成功!

重启php,查看amqp安装情况如下

root@thinkpad:/opt/amqp-1.8.0# php --ri amqp

amqp

Version => 1.8.0
Revision => release
Compiled => May 19 2018 @ 18:39:21
AMQP protocol version => 0-9-1
librabbitmq version => 0.7.1
Default max channels per connection => 256
Default max frame size => 131072
Default heartbeats interval => 0

Directive => Local Value => Master Value
amqp.host => localhost => localhost
amqp.vhost => / => /
amqp.port => 5672 => 5672
amqp.timeout => no value => no value
amqp.read_timeout => 0 => 0
amqp.write_timeout => 0 => 0
amqp.connect_timeout => 0 => 0
amqp.login => guest => guest
amqp.password => guest => guest
amqp.auto_ack => 0 => 0
amqp.prefetch_count => 3 => 3
amqp.channel_max => 256 => 256
amqp.frame_max => 131072 => 131072
amqp.heartbeat => 0 => 0
amqp.cacert => no value => no value
amqp.cert => no value => no value
amqp.key => no value => no value
amqp.verify => 1 => 1

相关推荐