Home >Backend Development >PHP Tutorial >Detailed explanation of how to install php extension-amqp

Detailed explanation of how to install php extension-amqp

藏色散人
藏色散人forward
2021-05-07 09:16:304403browse

This article will introduce how to install the php extension-amqp. It has certain reference value. Friends in need can refer to it. I hope it will be helpful to everyone.

Detailed explanation of how to install php extension-amqp

Recommended: "PHP Video Tutorial"

Install the php extension (the php7.2 version I use)

php uses amqp to call RabbitMQ, so download ampq first

$ wget https://pecl.php.net/get/amqp-1.9.3.tgz #下载
$ tar -xvf amqp-1.9.3.tgz #解压
$ cd amqp-1.9.3$ /usr/local/php/bin/phpize #用phpize生成编译文件,注意查看你的php在哪里
$ ./configure --with-php-config=/usr/local/php/bin/php-config

At this step, I reported an error: checking for amqp using pkg-config... configure: error: librabbitmq not found

This error prompts that you need to install one more: rabbitmq-c

Go here to download: https://github.com/alanxz/rabbitmq-c/releases

$ wget https://github.com/alanxz/rabbitmq-c/archive/v0.9.0.tar.gz
$ tar -xvf v0.9.0.tar.gz
$ cd rabbitmq-c-0.9.0/

Prepare to configure At that time, I found that there was no configure, and 0.9 was changed to cmake. Damn, install cmake

$ yum -y install cmake
$ cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/rabbitmq-c-0.9.0 #指定安装目录
$ make
$ make install

and then go back and compile amqp-1.9.3

$ ./configure --with-php-config=/usr/local/php/bin/php-config --with-amqp --with-librabbitmq-dir=/usr/local/rabbitmq-c-0.9.0$ make
$ make install

make and report an error!

I found some clues. I entered the /usr/local/rabbitmq-c-0.9.0/lib directory. After checking, I found that /usr/local/rabbitmq-c-0.9.0/ does not have lib, but there is lib64 bit.

Process it:

$ cp -R /usr/local/rabbitmq-c-0.9.0/lib64/ /usr/local/rabbitmq-c-0.9.0/lib

Then do: make && make install, OK.

Detailed explanation of how to install php extension-amqp

Add to php.ini to check it out!

extension=amqp.so

Detailed explanation of how to install php extension-amqp

The extension is installed successfully. At this time, you can use PHP to operate RabbitMQ.

The above is the detailed content of Detailed explanation of how to install php extension-amqp. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:learnku.com. If there is any infringement, please contact admin@php.cn delete