You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Laravel 5.5部署至PHP7.2主机时出现Class 'PDO' not found错误

Fixing "Class 'PDO' not found" Error When Deploying Laravel 5.5 on PHP 7.2

Hey there, let's cut straight to the root of your issue. Looking at your PHP configure command, the problem jumps right out: your PHP 7.2 build was compiled with the --disable-pdo flag, which completely turns off the PDO extension Laravel relies on to connect to your database. That's exactly why you're hitting the "Class 'PDO' not found" error when accessing your public directory.

Take a look at this line in your configure arguments — it's the direct culprit:

'--disable-pdo'

Laravel (and nearly all modern PHP database-driven frameworks) depends on PDO for database operations. Since your PHP installation explicitly disables this extension, the framework can't locate the PDO class when trying to establish a database connection.

How to Resolve This

Since you're using cPanel's EA-PHP72, here's the straightforward fix:

  1. Enable PDO via cPanel's PHP Extension Manager

    • Log into your cPanel account
    • Head to either Select PHP Version or MultiPHP Manager (the exact option depends on your cPanel theme)
    • Look for extensions like pdo_mysql (if you're using MySQL/MariaDB) or the relevant PDO driver for your database (e.g., pdo_pgsql for PostgreSQL)
    • Check the box next to the extension to enable it, then save your changes
    • Most cPanel setups will restart the web server automatically, but if you still see the error, you can manually restart it via the Restart Services section in cPanel
  2. Verify the Fix
    To confirm PDO is enabled correctly, create a temporary phpinfo.php file in your public directory with this code:

    <?php phpinfo(); ?>
    

    Access this file through your browser, then search for "PDO" — you should see a dedicated section for PDO, along with your enabled database driver (like PDO MySQL) listed as active.

内容的提问来源于stack exchange,提问作者A. Mohamed

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.28 09:04:23