酆叔のBlog

  • 首页
  • 分享技术
  • 八卦黑料
  • 生活日常
  • 日记
酆叔のBlog
上辈子作恶多端,这辈子早起上班。
  1. 首页
  2. IT技术
  3. 正文

编译安装PHP

2024年3月30日 746点热度 0人点赞 0条评论

首先更新系统
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
标签: Linux PHP
最后更新:2024年4月11日

酆叔

上辈子作恶多端,这辈子早起上班。

点赞
< 上一篇
下一篇 >

文章评论

razz evil exclaim smile redface biggrin eek confused idea lol mad twisted rolleyes wink cool arrow neutral cry mrgreen drooling persevering
取消回复

最新 热点 随机
最新 热点 随机
2025/05/15 周四 晴 2025/05/12 周一 晴 2025/05/08 周四 多云 2025/05/07 周三 阵雨 2025/05/06 周二 阵雨 2025/04/30 周三 多云
2025/04/29 周二 晴2025/04/30 周三 多云2025/05/06 周二 阵雨2025/05/07 周三 阵雨2025/05/08 周四 多云2025/05/12 周一 晴
认识PHP(四)变量 PHP 文件上传 工厂模式 2025/05/15 周四 晴 GO 编码风格 认识PHP(二)函数
腾讯云
又拍云
订阅
订阅

COPYRIGHT © 2024 酆叔のBlog. ALL RIGHTS RESERVED.

Theme Kratos Made By Seaton Jiang

豫ICP备2023016219号