PHP MQ amqp 安装
php 的rabbitmq 扩展模块amqp安装
首选下载rabbitmq-c
git clone https://github.com/alanxz/rabbitmq-c.git
./travis.sh cmake
运行后,会生成_install
将里面的lib64 的
-rw-r--r-- 1 root root 171848 2月 6 16:32 librabbitmq.a
lrwxrwxrwx 1 root root 16 2月 6 16:32 librabbitmq.so -> librabbitmq.so.4
lrwxrwxrwx 1 root root 20 2月 6 16:32 librabbitmq.so.4 -> librabbitmq.so.4.4.1
-rwxr-xr-x 1 root root 118184 2月 6 16:32 librabbitmq.so.4.4.1
cp librabbitmq* /usr/local/lib64/
做这一步会导致编译的时报错。
cannot find -lrabbitmq
pecl channel-update pecl.php.net
pecl install amqp
可能会提示部分函数因为安全问题被关闭,临时开一下。回头再关掉就可以了。如exec等。
/tmp/pear/temp/amqp/configure --with-php-config=/www/server/php/72/bin/php-config --with-librabbitmq-dir=/opt/rabbitmq-c/_install/
configure: WARNING: You will need re2c 0.13.4 or later if you want to regenerate PHP parsers.
checking for gawk... gawk
checking for amqp support... yes, shared
checking for amqp... yes, shared
checking for supported PHP versions... supported (7.2.33)
yes
checking for pkg-config... /usr/bin/pkg-config
checking for amqp files in default path... not found
configure: error: Please reinstall the librabbitmq distribution itself or (re)install librabbitmq development package if it available in your system
ERROR: `/tmp/pear/temp/amqp/configure --with-php-config=/www/server/php/72/bin/php-config --with-librabbitmq-dir=/opt/rabbitmq-c/build/librabbitq/' failed
主要是没有加相应的目录。加上后已经正常
编译的日志
[root@localhost rabbitmq-c]# ./travis.sh cmake
+ eval build_cmake
++ build_cmake
++ mkdir /opt/rabbitmq-c/_build
++ cd /opt/rabbitmq-c/_build
++ cmake .. -DCMAKE_INSTALL_PREFIX=/opt/rabbitmq-c/_build/../_install '-DCMAKE_C_FLAGS=-Werror -Wno-implicit-fallthrough'
-- The C compiler identification is GNU 4.8.5
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- CMAKE_BUILD_TYPE not specified. Creating Release build
-- Found C inline keyword: inline
-- Looking for getaddrinfo
-- Looking for getaddrinfo - found
-- Looking for socket
-- Looking for socket - found
-- Looking for poll
-- Looking for poll - found
-- Looking for clock_gettime in rt
-- Looking for clock_gettime in rt - found
-- Looking for posix_spawnp in rt
-- Looking for posix_spawnp in rt - found
-- Found OpenSSL: /usr/lib64/libssl.so;/usr/lib64/libcrypto.so (found suitable version "1.0.2k", minimum required is "0.9.8")
-- Looking for include file pthread.h
-- Looking for include file pthread.h - found
-- Looking for pthread_create
-- Looking for pthread_create - not found
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - found
-- Found Threads: TRUE
-- Performing Test HAVE_GNU90
-- Performing Test HAVE_GNU90 - Success
-- Could NOT find POPT (missing: POPT_INCLUDE_DIR POPT_LIBRARY)
-- Could NOT find XMLTO (missing: XMLTO_EXECUTABLE)
-- Could NOT find Doxygen (missing: DOXYGEN_EXECUTABLE)
-- Building rabbitmq as a shared library - yes
-- Building rabbitmq as a static library - yes
-- Configuring done
-- Generating done
-- Build files have been written to: /opt/rabbitmq-c/_build
++ cmake --build . --target install
Scanning dependencies of target rabbitmq
[ 1%] Building C object librabbitmq/CMakeFiles/rabbitmq.dir/amqp_framing.c.o
[ 2%] Building C object librabbitmq/CMakeFiles/rabbitmq.dir/amqp_api.c.o
[ 4%] Building C object librabbitmq/CMakeFiles/rabbitmq.dir/amqp_connection.c.o
[ 5%] Building C object librabbitmq/CMakeFiles/rabbitmq.dir/amqp_mem.c.o
[ 7%] Building C object librabbitmq/CMakeFiles/rabbitmq.dir/amqp_socket.c.o
[ 8%] Building C object librabbitmq/CMakeFiles/rabbitmq.dir/amqp_table.c.o
[ 10%] Building C object librabbitmq/CMakeFiles/rabbitmq.dir/amqp_url.c.o
[ 11%] Building C object librabbitmq/CMakeFiles/rabbitmq.dir/amqp_tcp_socket.c.o
[ 13%] Building C object librabbitmq/CMakeFiles/rabbitmq.dir/amqp_time.c.o
[ 14%] Building C object librabbitmq/CMakeFiles/rabbitmq.dir/amqp_consumer.c.o
[ 15%] Building C object librabbitmq/CMakeFiles/rabbitmq.dir/amqp_openssl.c.o
[ 17%] Building C object librabbitmq/CMakeFiles/rabbitmq.dir/amqp_openssl_hostname_validation.c.o
[ 18%] Building C object librabbitmq/CMakeFiles/rabbitmq.dir/amqp_hostcheck.c.o
[ 20%] Building C object librabbitmq/CMakeFiles/rabbitmq.dir/amqp_openssl_bio.c.o
Linking C shared library librabbitmq.so
[ 20%] Built target rabbitmq
Scanning dependencies of target rabbitmq-static
[ 21%] Building C object librabbitmq/CMakeFiles/rabbitmq-static.dir/amqp_framing.c.o
[ 23%] Building C object librabbitmq/CMakeFiles/rabbitmq-static.dir/amqp_api.c.o
[ 24%] Building C object librabbitmq/CMakeFiles/rabbitmq-static.dir/amqp_connection.c.o
[ 26%] Building C object librabbitmq/CMakeFiles/rabbitmq-static.dir/amqp_mem.c.o
[ 27%] Building C object librabbitmq/CMakeFiles/rabbitmq-static.dir/amqp_socket.c.o
[ 28%] Building C object librabbitmq/CMakeFiles/rabbitmq-static.dir/amqp_table.c.o
[ 30%] Building C object librabbitmq/CMakeFiles/rabbitmq-static.dir/amqp_url.c.o
[ 31%] Building C object librabbitmq/CMakeFiles/rabbitmq-static.dir/amqp_tcp_socket.c.o
[ 33%] Building C object librabbitmq/CMakeFiles/rabbitmq-static.dir/amqp_time.c.o
[ 34%] Building C object librabbitmq/CMakeFiles/rabbitmq-static.dir/amqp_consumer.c.o
[ 36%] Building C object librabbitmq/CMakeFiles/rabbitmq-static.dir/amqp_openssl.c.o
[ 37%] Building C object librabbitmq/CMakeFiles/rabbitmq-static.dir/amqp_openssl_hostname_validation.c.o
[ 39%] Building C object librabbitmq/CMakeFiles/rabbitmq-static.dir/amqp_hostcheck.c.o
[ 40%] Building C object librabbitmq/CMakeFiles/rabbitmq-static.dir/amqp_openssl_bio.c.o