centos安装php的rabbitmq扩展amqp



1、先安装rabbitmq-c-0.4.1
#cd /usr/local/
#wget https://github.com/alanxz/rabbitmq-c/releases/download/v0.4.1/rabbitmq-c-0.4.1.tar.gz
#tar zxvf rabbitmq-c-0.4.1.tar.gz
#cd rabbitmq-c-0.4.1
#./configure --prefix=/usr/local/rabbitmq-c-0.4.1
最后显示一下内容表示正常
config.status: executing depfiles commands
config.status: executing libtool commands


rabbitmq-c build options:
        Host: x86_64-unknown-linux-gnu
        Version: 0.4.1
        SSL/TLS: openssl
        Tools: no
        Documentation: no
        Examples: yes
然后进行make和安装了.
#make && make install
如果没有报错,那就是安装成功了




2、安装amqp-1.2.0
#wget http://pecl.php.net/get/amqp-1.2.0.tgz
#tar zxvf amqp-1.2.0.tgz
#cd amqp-1.2.0
#phpize
Configuring for:
PHP Api Version:         20090626
Zend Module Api No:      20090626
Zend Extension Api No:   220090626


要是没有phpize这个命令的话需要安装一下
#yum install php-devel
要是自己安装的php的话 可能需要自己查找一下
#find / -name phpize




3、php加载redis扩展
#vi /etc/php.ini
extension_dir = "/usr/lib64/php/modules"
extension="soap.so"
#:wq! #保存退出




4、重新加载php-fpm
#service php-fpm reload
如果是apache 则 #service httpd restart




5、测试,查看phpinfo信息,如下图所示:

centos安装php的rabbitmq扩展amqp_第1张图片


6、php代码测试
<?php
$conn_args = array( 
    'host' => 'localhost',  
    'port' => '5672', 
    'login' => 'guest',
    'password' => 'guest', 
);
$conn = new AMQPConnection($conn_args);
if (!$conn->connect()) {   
    die("Cannot connect to the broker!\n");   

print_r($conn);exit;



你可能感兴趣的:(centos安装php的rabbitmq扩展amqp)