php7.4.33 编译安装
一、 下载
wget https://www.php.net/distributions/php-7.4.33.tar.gz
二、 安装依赖
yum install gcc gcc++ gcc-c++ libxml2-devel libicu-devel sqlite-devel oniguruma oniguruma-devel autoconf zip unzip openssl-devel libcurl-devel libpng-devel libjpeg-devel freetype-devel libxslt-devel
安装libzip
2.1 删除原有libzip
yum remove libzip
2.2 下载指定版本的libzip
wget --no-check-certificate https://nih.at/libzip/libzip-1.2.0.tar.gz
2.3 安装libzip1.2.0
tar -xzvf libzip-1.2.0.tar.gz ``` |
2.4 配置环境
export PKG_CONFIG_PATH="/usr/local/libzip-1.2.0/lib/pkgconfig/"
三、 编译安装
tar -xzvf php-7.4.33.tar.gz |
关于编译配置选项
关于一些配置项, 可以参考php的官方文档
或者运行 ./configure –help 命令
3.1 配置 php
ln -s /usr/local/php7.4/bin/php /usr/bin/php
cat $PATH_OF_PHP_SOURCE_FOLDER/php.ini-development > /usr/local/php7.4/etc/php.ini
3.2 配置 php-fpm
ln -s /usr/local/php7.4/sbin/php-fpm /usr/bin/php-fpm
cd /usr/local/php7.4/etc
cp php-fpm.conf.default php-fpm.conf
3.3 配置 php-fpm 用户文件
cd /usr/local/php7.4/etc/php-fpm.d
cp www.conf.default www.conf
3.4 使用 systemctl 管理 php-fpm
# vim /usr/lib/systemd/system/php74-fpm.service |
四、 相关问题
4.1 error: Package requirements (openssl >= 1.0.1) were not met
解决: yum install openssl-devel
4.2 error: Package requirements (libcurl >= 7.15.5) were not met
解决: yum install libcurl-devel
4.3 error: Package requirements (libpng) were not met
解决: yum install libpng-devel
4.4 error: Package requirements (libjpeg) were not met
解决: yum install libjpeg-devel
4.5 error: Package requirements (freetype2) were not met
解决: yum install freetype-devel
4.6 configure: error: C++ preprocessor “/lib/cpp” fails sanity check
解决: yum install gcc-c++
4.7 error: Package requirements (libxslt >= 1.1.0) were not met
解决: yum install libxslt-devel