📜 ⬆️ ⬇️

PHP & AMQP (Continued) Installing php-rabbit

In the continuation of the article "AMQP is now in PHP"
Who cares what stones are expected when installing php-rabbit

1) The installation of the RabbitMQ broker itself went smoothly. Gathers from FreeBSD ports, MacOs, .deb packages
dependencies: requires an Erlang package (otp), taken for granted, as RabbitMQ is implemented on an Erlang, which has good internal multithreading mechanisms. I tried to build RabbitMQ from source, but did not take into account something. In general, the experience was not enough.

2) With the installation of C, the client had to tinker, the features of which I will describe a little below. But if you use the Mercurial client, the installation went through without any problems:
{{{
echo Cloning rabbitmq-c
hg clone -r 84aaa77eba59 hg.rabbitmq.com/rabbitmq-c
cd rabbitmq-c

echo Closning rabbitmq-codegen
hg clone -r 75c3ef2e1083 hg.rabbitmq.com/rabbitmq-codegen codegen
echo Compiling

autoreconf -i && ./configure && make && make install
}}}

')
But, initially, as a smart Masha, I decided to compile from source.
Here, it should be noted that the architecture of applications of the RabbitMQ family is arranged as follows: in order not to make the code firmly dependent on changes to the AMQP protocol, the development team proposed a code generation solution in which all protocol-dependent parts were described in JSON and to this file (stable amqp -0.8.json, experiment amqp-0.9.json) in addition there was a code generator. Kodogenerator can take hg.rabbitmq.com/rabbitmq-codegen/

The regular Makefile turned out to be slightly inoperable and at startup it gives an error for the absence of the amqp_framing.h and amqp_framing.c files, therefore, they need to be generated as follows:
- initially download files (amqp-0.8.json, amqp_codegen.py) from the code generator folder and add it to the librabbitmq directory
- run the code generator from the librabbitmq: python codegen.py directory, you should see the following:
python codegen.py
Usage:
codegen.py header|body path_to_amqp_spec.json path_to_output_file

- enter the command:
python codegen.py header <full/path/to/amqp-0.8.json> <full/path/to/amqp_framing.h>
python codegen.py body <full/path/to/amqp-0.8.json> <full/path/to/amqp_framing.c>

After code generation, you need to disable code generation sections in the Makefile: amqp_framing.h and amqp_framing.c. And why are they needed if we did it with pens.

I just commented out their contents. amqp_framing.h: $(AMQP_SPEC_JSON_PATH) $(CODEGEN_PY)
# PYTHONPATH=$(AMQP_CODEGEN_DIR) $(PYTHON) $(CODEGEN_PY) header $< $@

amqp_framing.c: $(AMQP_SPEC_JSON_PATH) $(CODEGEN_PY)
# PYTHONPATH=$(AMQP_CODEGEN_DIR) $(PYTHON) $(CODEGEN_PY) body $< $@


perhaps it was enough just to tinker in the Makefile and set it up so that it was not dancing with tambourines ...

3) the installation of the extension is normal, if as .so, then:
in the phpize
./configure
sudo make install
project phpize
./configure
sudo make install
phpize
./configure
sudo make install

further write in php.ini: rabbit.so;

If we want to install statically, then we rewrite the mod in the directory php / ext and then everything is the same as any PECL extension:
./buildconf
./configure .... --with-rabbit
make & make install

Source: https://habr.com/ru/post/70792/


All Articles