termux编译php event扩展, bufferevent_openssl_get_ssl not found

1 . 编译所需要的工具安装一下:不需要安装dev后缀的包

说明:

  1. Termux 的包管理特点:

    • 开发库(头文件、静态库等)已包含在主包中

    • 不需要像 Debian/Ubuntu 那样寻找 -dev 后缀的包

 

pkg install  autoconf automake libtool make clang openssl libevent

2. 下载所需要的event扩展源码,并进行编译

# 创建临时目录并进入
mkdir -p ~/php-ext && cd ~/php-ext

# 下载vent 扩展源码
wget https://pecl.php.net/get/event-3.0.8.tgz
tar -xzf event-3.0.8.tgz
cd event-3.0.8

# 配置、编译和安装, 需要指定
phpize
./configure make && make install

3. 上面第二步骤最后会报错:需要指定libent的位置 --with-event-libevent-dir=$PREFIX 的位置

Configuring extension
checking for Event core support... yes, shared
checking for Event thread safety support... no
checking for Event extra functionality support... yes
checking for OpenSSL support in Event... yes
checking for custom PHP namespace in Event... no
checking for OpenSSL installation prefix... yes
checking whether Event debugging support enabled... no
checking whether to enable sockets support in Event... yes
checking PHP version... PHP 8.x
checking for include/event2/event.h... not found
configure: error: Please reinstall the event library, or provide the installation prefix via --with-event-libevent-dir option

4. 重新执行 编译

./configure  --with-event-libevent-dir=$PREFIX 

# 上述命令执行以后还是会报错;
Configuring extension
checking for Event core support... yes, shared
checking for Event thread safety support... no
checking for Event extra functionality support... yes
checking for OpenSSL support in Event... yes
checking for custom PHP namespace in Event... no
checking for OpenSSL installation prefix... yes
checking whether Event debugging support enabled... no
checking whether to enable sockets support in Event... yes
checking PHP version... PHP 8.x
checking for include/event2/event.h... found in /data/data/com.termux/files/usr
checking for libevent version... ok
checking for event_free in -levent_core... yes
checking for evdns_base_free in -levent_extra... yes
checking for openssl >= 1.1.1... yes
checking for bufferevent_openssl_get_ssl in -levent_openssl... no
configure: error: bufferevent_openssl_get_ssl not found in event_openssl library, or the library is not installed

  

 这一步骤还是会报错, 因为libevent 缺少 OpenSSL 支持,需要重新编译libevent 

4.1 下载重新安装libevnt,并开启openssl支持

# 安装编译依赖
pkg install openssl libtool autoconf automake

# 下载并编译 libevent
wget https://github.com/libevent/libevent/releases/download/release-2.1.12-stable/libevent-2.1.12-stable.tar.gz
tar -xzf libevent-2.1.12-stable.tar.gz
cd libevent-2.1.12-stable

./configure --prefix=$PREFIX --enable-openssl --enable-shared
make && make install

5. 再重新执行event的编译就可以正常通过了

编译命令

./configure --with-event-libevent-dir=$PREFIX
make && make install


# 编译成功后的输出
Libraries have been installed in: /data/data/com.termux/files/home/php-ext/event-3.0.8/modules If you ever happen to want to link against installed libraries in a given directory, LIBDIR, you must either use libtool, and specify the full pathname of the library, or use the `-LLIBDIR' flag during linking and do at least one of the following: - add LIBDIR to the `LD_LIBRARY_PATH' environment variable during execution - add LIBDIR to the `LD_RUN_PATH' environment variable during linking - use the `-Wl,--rpath -Wl,LIBDIR' linker flag - have your system administrator run these commands: PATH="$PATH:/sbin" ldconfig -n /data/data/com.termux/files/home/php-ext/event-3.0.8/modules See any operating system documentation about shared libraries for more information, such as the ld(1) and ld.so(8) manual pages. ---------------------------------------------------------------------- Build complete. Don't forget to run 'make test'. Parse /data/data/com.termux/files/home/php-ext/event-3.0.8/php8/php_event.stub.php to generate /data/data/com.termux/files/home/php-ext/event-3.0.8/php8/php_event_arginfo.h Parse /data/data/com.termux/files/home/php-ext/event-3.0.8/php8/src/../php_event.stub.php to generate /data/data/com.termux/files/home/php-ext/event-3.0.8/php8/src/../php_event_arginfo.h Installing shared extensions: /data/data/com.termux/files/usr/lib/php/

# 最终的so存在于/data/data/com.termux/files/usr/lib/php/这个目录中

6. 进入php扩展目录,新建event扩展配置

cd $PREFIX/etc/php/conf.d/
vim event.php

# 开启扩展
extension=event

# 执行php -m 验证是否成功
php -m | grep event
php --ri event

 

posted @ 2025-05-30 18:07  brave_jman  阅读(22)  评论(0)    收藏  举报