准备
系统版本检查
[root@ecs ~
]
CentOS Linux release 7.8.2003
(Core
)
检查是否曾经安装过php
[root@ecs ~
]
-bash: php:
command not found
不存在php命令,说明未成功安装PHP
安装
下载安装编译工具
yum groupinstall -y
'Development Tools'
安装依赖包
yum
install -y libxml2 libxml2-devel openssl openssl-devel
bzip2 bzip2-devel libcurl libcurl-devel libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel gmp gmp-devel libmcrypt libmcrypt-devel readline readline-devel libxslt libxslt-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel ncurses
curl gdbm-devel db4-devel libXpm-devel libX11-devel gd-devel gmp-devel expat-devel xmlrpc-c xmlrpc-c-devel libicu-devel libmcrypt-devel libmemcached-devel sqlite-devel
下载并解压php7.4.7
wget http://php.net/distributions/php-7.4.7.tar.gz
tar -zxvf php-7.4.7.tar.gz
编译安装
cd php-7.4.7
./configure
make && make install
检查
php -v
PHP模块
PDO 利用PDO对数据库进行操作,类似的还有mysql、mysqli
yum
install -y php-pdo
遇到的问题
编译后报错
configure: error: Package requirements
(sqlite3
> 3.7.4
) were not met:
No package
'sqlite3' found
解决办法,安装依赖包在重新编译,(已经加入到第2步中,所以按照上面的来不会出现这个问题了)
yum
install -y sqlite-devel
Apache无法自动加载php7.4 其它帖子只有解决php7.2的办法。。那个yum还没有php7.4模块
References
个性化配置教程 https://www.cnblogs.com/liubaoqing/p/12176017.html官网 https://www.php.net/downloads.php#v7.4.7问题解决方案 https://www.cnblogs.com/liyuanhong/p/12016767.htmlApache配置php7 https://editor.csdn.net/md?articleId=107119689https://blog.csdn.net/qq_41170899/article/details/80696200