首先更新系统yum -y update
我一般把PHP安装在这里cd /usr/local
下载PHP8.2的安装包wget https://www.php.net/distributions/php-8.2.10.tar.gz
解压安装包tar -zxvf php-8.2.10.tar.gz
进入解压后的PHP8.2目录cd php-8.2.10
# 进行编译参数
./configure --prefix=/usr/local/php \
--sysconfdir=/etc/php \
--with-openssl \
--with-zlib \
--with-bz2 \
--with-curl \
--enable-bcmath \
--enable-gd \
--with-webp \
--with-jpeg \
--with-mhash \
--enable-mbstring \
--with-imap-ssl \
--with-mysqli \
--enable-exif \
--with-ffi \
--with-zip \
--enable-sockets \
--with-pcre-jit \
--enable-fpm \
--with-pdo-mysql \
--with-pdo-pgsql \
--enable-pcntl
解决报错后需要重新运行 ./configure
编译参数
遇到报错:checking for libxml-2.0 >= 2.9.0… no
configure: error: Package requirements (libxml-2.0 >= 2.9.0) were not met:
Package 'libxml-2.0', 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 LIBXML_CFLAGS
and LIBXML_LIBS to avoid the need to call pkg-config.
See the pkg-config man page for more details.
解决方法:
CentOS/RHEL:sudo yum install libxml2 libxml2-devel
Ubuntu/Debian:sudo apt-get install libxml2 libxml2-dev
遇到报错:checking for openssl >= 1.0.2… no
configure: error: Package requirements (openssl >= 1.0.2) were not met:
Package 'openssl', 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 OPENSSL_CFLAGS
and OPENSSL_LIBS to avoid the need to call pkg-config.
See the pkg-config man page for more details.
解决方法:
CentOS/RHEL:sudo yum install openssl openssl-devel
Ubuntu/Debian:sudo apt-get install openssl libssl-dev
遇到报错:checking for sqlite3 >= 3.7.7… no
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.
解决方法:
CentOS/RHEL:sudo yum install sqlite sqlite-devel
Ubuntu/Debian:sudo apt-get install sqlite3 libsqlite3-dev
遇到报错:checking for BZip2 in default path… not found
configure: error: Please reinstall the BZip2 distribution
解决方法:
CentOS/RHEL:sudo yum install bzip2-devel
Ubuntu/Debian :sudo apt-get install libbz2-dev
遇到报错:checking for libcurl >= 7.29.0… no
configure: error: Package requirements (libcurl >= 7.29.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.
解决方法:
CentOS/RHEL:sudo yum install libcurl-devel
Ubuntu/Debian:sudo apt-get install libcurl4-openssl-dev
遇到报错:checking for libffi >= 3.0.11… no
configure: error: Package requirements (libffi >= 3.0.11) were not met:
Package 'libffi', 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 FFI_CFLAGS
and FFI_LIBS to avoid the need to call pkg-config.
See the pkg-config man page for more details.
解决方法:
CentOS/RHEL:sudo yum install libffi-devel
Ubuntu/Debian:sudo apt-get install libffi-dev
遇到报错:checking for libpng… no
configure: error: Package requirements (libpng) were not met:
Package 'libpng', 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 PNG_CFLAGS
and PNG_LIBS to avoid the need to call pkg-config.
See the pkg-config man page for more details.
解决方法:
CentOS/RHEL:sudo yum install libpng-devel
Ubuntu/Debian:sudo apt-get install libpng-dev
遇到报错:checking for libwebp >= 0.2.0… no
configure: error: Package requirements (libwebp >= 0.2.0) were not met:
Package 'libwebp', 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 WEBP_CFLAGS
and WEBP_LIBS to avoid the need to call pkg-config.
See the pkg-config man page for more details.
解决方法:
CentOS/RHEL:sudo yum install libwebp-devel
Ubuntu/Debian:sudo apt-get install libwebp-dev
遇到报错:checking for libjpeg… no
configure: error: Package requirements (libjpeg) were not met:
Package 'libjpeg', 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 JPEG_CFLAGS
and JPEG_LIBS to avoid the need to call pkg-config.
See the pkg-config man page for more details.
解决方法:
CentOS/RHEL:
sudo yum install libjpeg-devel
Ubuntu/Debian:sudo apt-get install libjpeg-dev
遇到报错:checking for oniguruma… no
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.
解决方法:
CentOS/RHEL:sudo yum --enablerepo=PowerTools install oniguruma-devel
(dnf --enablerepo=PowerTools install oniguruma-devel
)
Ubuntu/Debian:sudo apt-get --enablerepo=PowerTools install oniguruma-devel
遇到报错:checking for pg_config… not found
configure: error: Cannot find libpq-fe.h. Please specify correct PostgreSQL installation path
解决方法:
CentOS/RHEL:sudo yum install postgresql-devel
Ubuntu/Debian:sudo apt-get install libpq-dev
遇到报错:checking for libzip >= 0.11 libzip != 1.3.1 libzip != 1.7.0… no
configure: error: Package requirements (libzip >= 0.11 libzip != 1.3.1 libzip != 1.7.0) were not met:
Package 'libzip', required by 'virtual:world', not found
Package 'libzip', required by 'virtual:world', not found
Package 'libzip', 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 LIBZIP_CFLAGS
and LIBZIP_LIBS to avoid the need to call pkg-config.
See the pkg-config man page for more details.
解决方法:
CentOS/RHEL:sudo yum install libzip-devel
Ubuntu/Debian:sudo apt-get install libzip-dev
进行编译make
遇到报错:cc: fatal error: Killed signal terminated program cc1
compilation terminated.
make: *** [Makefile:1101: ext/fileinfo/libmagic/apprentice.lo] Error 1
解决方法: (参考链接:https://www.jianshu.com/p/a4ad05a51456)
获取要增加的2G的SWAP文件块dd if=/dev/zero of=/swapfile bs=1k count=2048000
设置权限sudo chmod 600 /swapfile
创建SWAP文件mkswap /swapfile
激活SWAP文件swapon /swapfile
查看当前交换空间sudo swapon --show
查看SWAP信息是否正确swapon -s
添加到fstab文件中让系统引导时自动启动echo "/var/swapfile swap swap defaults 0 0" >> /etc/fstab
swapfile文件的路径在/var/下。
删除交换分区:swapoff /swapfile
rm -rf /swapfile
进行安装make install
文章评论