Laravel:PDO类未找到错误 [英] Laravel: PDO Class not found error

查看:173
本文介绍了Laravel:PDO类未找到错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Centos上部署laravel项目期间,出现了此错误.

During deploy laravel project on Centos, I have gotten this error.

PHP Fatal error:  Class 'PDO' not found in /var/www/html/<laravel_project_name>/config/database.php on line 16

我已通过编辑php.ini文件启用了pdo扩展.

I have enabled pdo extension with editing php.ini file.

extension=pdo.so
extension=pdo_sqlite.so
extension=pdo_mysql.so
extension=sqlite.so

当我尝试使用php -v时,出现以下错误.

And when I try to php -v, I got following error.

PHP Startup: Unable to load dynamic library '/usr/lib64/php/modules/pdo_mysql.so' - /usr/lib64/php/modules/pdo_mysql.so: undefined symbol: mysqlnd_allocator in Unknown on line 0

在编辑php.ini文件后,我已经重新启动了httpd服务器. 请帮助我解决此错误. 问候.

I have restarted httpd server after edit php.ini file. Please help me to fix this error. Regards.

推荐答案

您收到的错误意味着您的php配置文件(通常是php.ini)中有一个extension = ...或zend_extension = ...行.正在尝试加载该扩展名,但由于该扩展名不存在或没有访问权限,因此无法为其加载文件.

The error you are getting means there is an extension=... or zend_extension=... line in your php configuration files (usually php.ini) that is trying to load that extension but it cannot load the files for it, either because it does not exist or it does not have permissions to access it.

在这种情况下,您已经在php.ini文件中设置了以下所有内容:

In this case you have set all of the below in your php.ini file:

extension=pdo.so
extension=pdo_sqlite.so
extension=sqlite.so
extension=pdo_mysql.so

但是它们实际上已经安装了吗?

But have they actually been installed?

鉴于您正在使用CentOS,请尝试运行以下命令来安装PDO:

Given you are using CentOS, try run the following to install PDO:

yum install php-pdo php-mysqli

如果已安装,请检查是否已正确设置对/usr/lib64/php/modules/pdo_mysql.so的权限.

If it is already installed then please check the permissions to /usr/lib64/php/modules/pdo_mysql.so have been set appropriately.

这篇关于Laravel:PDO类未找到错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆