CentOS 7系统如何安装ThinkPHP所需扩展及配置yum源?

2026-05-06 15:291阅读0评论SEO教程
  • 内容介绍
  • 文章标签
  • 相关推荐

本文共计682个文字,预计阅读时间需要3分钟。

CentOS 7系统如何安装ThinkPHP所需扩展及配置yum源?

ThinkPHP项目在CentOS 7上运行不正常,常见原因可能是PHP缺少以下扩展:

yum安装扩展比手动编译更稳妥

CentOS 7默认PHP版本多为 5.4/5.6(EPEL源)或 7.2+(Remi源),手动编译扩展容易因头文件路径、PHP配置参数不一致导致 undefined symbol 错误。优先走 yum 安装:

  • 先确认PHP版本:php -v;再查PHP安装方式:rpm -qa | grep php
  • 若用系统自带PHP(如 php-5.4.16):启用 EPEL 源后执行 yum install php-mbstring php-curl php-gd php-opcache php-pdo php-mysqlnd
  • 若用 Remi 源的 PHP 7.4+:需先启用对应仓库,例如 yum install php74-php-mbstring php74-php-curl php74-php-gd —— 注意包名带版本前缀,且 php74-php-fpmphp74-php 必须同源
  • 装完别忘了重启服务:systemctl restart php-fpmsystemctl restart httpd

手动编译扩展只在特定场景下必要

只有两种情况才需要手动编译:用了非RPM安装的PHP(如源码编译安装),或 要启用某些未打包进yum的扩展(如 swooleredis

阅读全文

本文共计682个文字,预计阅读时间需要3分钟。

CentOS 7系统如何安装ThinkPHP所需扩展及配置yum源?

ThinkPHP项目在CentOS 7上运行不正常,常见原因可能是PHP缺少以下扩展:

yum安装扩展比手动编译更稳妥

CentOS 7默认PHP版本多为 5.4/5.6(EPEL源)或 7.2+(Remi源),手动编译扩展容易因头文件路径、PHP配置参数不一致导致 undefined symbol 错误。优先走 yum 安装:

  • 先确认PHP版本:php -v;再查PHP安装方式:rpm -qa | grep php
  • 若用系统自带PHP(如 php-5.4.16):启用 EPEL 源后执行 yum install php-mbstring php-curl php-gd php-opcache php-pdo php-mysqlnd
  • 若用 Remi 源的 PHP 7.4+:需先启用对应仓库,例如 yum install php74-php-mbstring php74-php-curl php74-php-gd —— 注意包名带版本前缀,且 php74-php-fpmphp74-php 必须同源
  • 装完别忘了重启服务:systemctl restart php-fpmsystemctl restart httpd

手动编译扩展只在特定场景下必要

只有两种情况才需要手动编译:用了非RPM安装的PHP(如源码编译安装),或 要启用某些未打包进yum的扩展(如 swooleredis

阅读全文