Debian 12源码编译安装PHP 8.4.14
编程 2025年11月12日 作者: 管振佐
38 阅读 0 评论

Debian 12源码编译安装PHP 8.4.14

1.下载PHP8.4.14

wget https://www.php.net/distributions/php-8.4.14.tar.gz

2.解压并进入压缩包

tar -zxvf php-8.4.14.tar.gz && cd php-8.4.14

3.编译

 ./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/ --enable-fpm --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-iconv-dir --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml --disable-rpath --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --enable-mbregex --enable-mbstring --with-mcrypt --enable-ftp --with-gd --enable-gd-native-ttf --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --enable-soap --without-pear --with-gettext --disable-fileinfo --enable-maintainer-zts

如果需要使用PostgreSQL和MariaDB:

./configure  --prefix=/usr/local/php8.4  --with-config-file-path=/usr/local/php8.4/etc  --with-config-file-scan-dir=/usr/local/php8.4/etc/conf.d --enable-fpm  --with-fpm-user=www-data  --with-fpm-group=www-data --enable-mbstring --enable-exif  --enable-zip   --enable-bcmath  --enable-pcntl --enable-ftp  --enable-sockets  --enable-soap --enable-intl  --enable-calendar  --with-pdo-pgsql  --with-pgsql --with-pdo-mysql --with-mysqli   --with-gd --with-jpeg --with-freetype  --with-webp  --with-xpm   --with-openssl  --with-zlib --with-bz2 --with-libxml --with-xsl --with-curl  --with-readline --with-libedit --with-pear --enable-opcache --with-sodium --with-password-argon2

 

可能遇到的报错及解决方法,这里的解决方法,仅仅是为快速解决问题

checking for libxml-2.0 >= 2.9.4... no
configure: error: in '/root/php-8.4.14':
configure: error: The pkg-config script could not be found or is too old.  Make sure it
is in your PATH or set the PKG_CONFIG environment variable to the full
path to pkg-config.

Alternatively, you may set the environment variables LIBXML_CFLAGS
and LIBXML_LIBS to avoid the need to call pkg-config.
See the pkg-config man page for more details.

这个错误是因为缺少 pkg-config 工具和 libxml2 开发库。在 Debian 12 上,您需要安装一些依赖包来解决这个问题。解决方法:sudo apt install pkg-config libxml2-dev

configure: error: Package requirements (libedit) were not met:

Package 'libedit', required by 'virtual:world', not found

Consider adjusting the PKG_CONFIG_PATH environment variable if you
installed software in a non-standard prefix.

Alternatively, you may set the environment variables EDIT_CFLAGS
and EDIT_LIBS to avoid the need to call pkg-config.
See the pkg-config man page for more details.

这个错误是因为缺少 libedit 开发库。解决方法:sudo apt install -y libedit-dev

安装 libedit-dev 包应该能解决这个错误。libedit 是 readline 的替代品,提供了命令行编辑功能,对于 PHP 的交互式 shell 很有用。

configure: error: Package requirements (libsodium >= 1.0.8) were not met:

Package 'libsodium', required by 'virtual:world', not found

Consider adjusting the PKG_CONFIG_PATH environment variable if you
installed software in a non-standard prefix.

Alternatively, you may set the environment variables LIBSODIUM_CFLAGS
and LIBSODIUM_LIBS to avoid the need to call pkg-config.
See the pkg-config man page for more details.

这个错误是因为缺少 libsodium 开发库。解决方法:sudo apt install -y libsodium-dev 

configure: error: Package requirements (libargon2) were not met:

Package 'libargon2', required by 'virtual:world', not found

Consider adjusting the PKG_CONFIG_PATH environment variable if you
installed software in a non-standard prefix.

Alternatively, you may set the environment variables ARGON2_CFLAGS
and ARGON2_LIBS to avoid the need to call pkg-config.
See the pkg-config man page for more details.

这个错误是因为缺少 libargon2 开发库。解决方法:sudo apt install -y libargon2-dev 

configure: error: Package requirements (libxslt >= 1.1.0) were not met:

Package 'libxslt', required by 'virtual:world', not found

Consider adjusting the PKG_CONFIG_PATH environment variable if you
installed software in a non-standard prefix.

Alternatively, you may set the environment variables XSL_CFLAGS
and XSL_LIBS to avoid the need to call pkg-config.
See the pkg-config man page for more details.

这个错误是因为缺少 libxslt 开发库。解决方法:sudo apt install -y libxslt1-dev 

configure: error: Package requirements (sqlite3 >= 3.7.7) were not met:

Package 'sqlite3', required by 'virtual:world', not found

Consider adjusting the PKG_CONFIG_PATH environment variable if you
installed software in a non-standard prefix.

Alternatively, you may set the environment variables SQLITE_CFLAGS
and SQLITE_LIBS to avoid the need to call pkg-config.
See the pkg-config man page for more details.

这个错误是因为缺少 SQLite3 开发库。解决方法: sudo apt install -y libsqlite3-dev 

configure: error: Package requirements (libcurl >= 7.61.0) were not met:

Package 'libcurl', required by 'virtual:world', not found

Consider adjusting the PKG_CONFIG_PATH environment variable if you
installed software in a non-standard prefix.

Alternatively, you may set the environment variables CURL_CFLAGS
and CURL_LIBS to avoid the need to call pkg-config.
See the pkg-config man page for more details.

这个错误是因为缺少 cURL 开发库。解决方法:sudo apt install -y libcurl4-openssl-dev

configure: error: Package requirements (oniguruma) were not met:

Package 'oniguruma', required by 'virtual:world', not found

Consider adjusting the PKG_CONFIG_PATH environment variable if you
installed software in a non-standard prefix.

Alternatively, you may set the environment variables ONIG_CFLAGS
and ONIG_LIBS to avoid the need to call pkg-config.
See the pkg-config man page for more details.

这个错误是因为缺少 Oniguruma 正则表达式库的开发文件。sudo apt install -y libonig-dev

checking for BZip2... bzlib.h not found
configure: error: Please reinstall the BZip2 library package

这个错误是因为缺少 BZip2 开发库。sudo apt install -y libbz2-dev

我这是开发用服务器,编译参数有些多。实际需要根据自己需求进行编译,请注意有路径的地方

4.安装

make && make install

标签:

评论 (0)

验证码
评论需要审核后才会显示

暂无评论,快来抢沙发吧!

文章信息

分类 编程
发布时间 2025年11月12日
作者 管振佐
浏览量 38 次
标签