Ubuntu 22.04编译安装PHP 8.2

下载:

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

解压缩包:

tar zxf php-8.2.12.tar.gz

进入源码目录:

cd php-8.2.12

编译安装:

./configure --prefix=/usr/local/php --with-mysql-sock=/var/lib/mysql/mysql.sock --enable-fpm --with-fpm-user=test --with-fpm-group=test --enable-gd --with-jpeg --with-webp --with-openssl --with-zlib --with-curl --enable-mbstring --with-mysqli --with-freetype --enable-intl --enable-exif --with-zip && make && make install

安装过程中可能出现的报错:

configure: error: no acceptable C compiler found in $PATH
configure: error: The pkg-config script could not be found or is too old
configure: error: Package requirements (libxml-2.0 >= 2.9.0) were not met
configure: error: Package requirements (openssl >= 1.0.2) were not met
configure: error: Package requirements (sqlite3 >= 3.7.7) were not met
configure: error: Package requirements (zlib >= 1.2.0.4) were not met
configure: error: Package requirements (libcurl >= 7.29.0) were not met
configure: error: Package requirements (libpng) were not met
configure: error: Package requirements (libwebp >= 0.2.0) were not met
configure: error: Package requirements (libjpeg) were not met
configure: error: Package requirements (freetype2) were not met
configure: error: C++ preprocessor "/lib/cpp" fails sanity check
configure: error: Package requirements (oniguruma) were not met
configure: error: Package requirements (libzip >= 0.11 libzip != 1.3.1 libzip != 1.7.0) were not met

解决方法:

apt install gcc pkg-config libxml2-dev libssl-dev libsqlite3-dev zlib1g-dev libcurl4-openssl-dev libpng-dev libwebp-dev libjpeg-dev libfreetype-dev g++ libonig-dev libzip-dev

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注