首页 新闻动态 技术文章

PHP扩展 AMQP 安装指南(rabbitmq)

发布时间:2025-03-24 18:17 点击:134

安装 Rabbitmq-c


需要先安装 Rabbitmq-c 。

地址:https://github.com/alanxz/rabbitmq-c/releases

这里选 0.8.0 的版本,再之后的版本都是需要使用 cmake 安装。


  1. wget https://github.com/alanxz/rabbitmq-c/releases/download/v0.8.0/rabbitmq-c-0.8.0.tar.gz
    tar zxvf rabbitmq-c-0.8.0.tar.gz
    cd rabbitmq-c-0.8.0/
    ./configure --prefix=/usr/local/rabbitmq-c-0.8.0
    make && make install


安装 AMQP 扩展

php扩展下载地址 https://pecl.php.net/package/amqp

  1. wget https://pecl.php.net/get/amqp-1.10.0.tgz
    tar zxvf amqp-1.10.0.tgz
    cd amqp-1.10.0/
    #这里是PHP路径下的phpize,根据各自环境安装地址运行
    /usr/bin/phpize
    #--with-librabbitmq-dir 填写上面 rabbitmq-c 的安装地址
    ./configure --with-php-config=/usr/bin/php-config --with-amqp --with-librabbitmq-dir=/usr/local/rabbitmq-c-0.8.0
    make && make install


修改 php.ini

修改配置文件,添加 amqp 扩展。 vi /etc/php.ini

添加 extension = amqp.so

查看 php -m 里面有 amqp 则成功完成安装。

         PHP 需要重启才能生效