laravel 未找到 PDO - Centos7 PHP7.1
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/51463117/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
PDO Not Found - Centos7 PHP7.1
提问by warmjaijai
I am a server newbie so please bare my foolishness.
我是服务器新手,所以请原谅我的愚蠢。
This is more a Server problem (I think) rather than a Laravel problem, but my website is based on Laravel5.4 so Just FYI.
这更像是服务器问题(我认为)而不是 Laravel 问题,但我的网站基于 Laravel5.4,所以仅供参考。
I am currently using Google Cloud Platform to set up a VM which seemingly works as any others.
我目前正在使用 Google Cloud Platform 来设置一个看起来和其他任何人一样工作的虚拟机。
Currently installed:
当前安装:
- Centos 7
- mariadb
- Apache/2.4.6 (CentOS)
- php71
- Centos 7
- 玛丽亚数据库
- Apache/2.4.6 (CentOS)
- php71
so i put my website folder into /var/www/html/mywebsitefolder
所以我把我的网站文件夹放入 /var/www/html/mywebsitefolder
I set up mysql database and configure my website config for database set up and tried to run php71 artisan migrate
at this point. And it throws the following errors:
我设置了 mysql 数据库并为数据库设置配置了我的网站配置,并php71 artisan migrate
在此时尝试运行。它会引发以下错误:
PHP Fatal error: Class 'PDO' not found in /var/www/html/soyegg/vendor/laravel/framework/src/Illuminate/Database/Co nnection.php on line 1200 In Connection.php line 1200: Class 'PDO' not found
PHP 致命错误:第 1200 行 /var/www/html/soyegg/vendor/laravel/framework/src/Illuminate/Database/Connection.php 中未找到“PDO”类 在 Connection.php 第 1200 行中:“PDO”类未找到
which i researched and said php-pdo needed to be installed so I ran the following line in cli:
我研究了一下,说需要安装 php-pdo,所以我在 cli 中运行了以下行:
yum install php-pdo
yum install php-pdo_mysql
however the error still persists.
但是错误仍然存在。
Then I further researched and said I need explicitly stated extension in php.ini
in order to use them. But when I check my php.ini
for php71 it doesn't involve any line looks any like the following which others said they are supposed to be added into php.ini
:
然后我进一步研究并说我需要明确说明扩展名php.ini
才能使用它们。但是,当我检查我php.ini
的 php71 时,它不涉及任何类似于以下内容的行,其他人说他们应该添加到以下内容中php.ini
:
extension=pdo.so
extension=pdo_sqlite.so
extension=pdo_mysql.so
I am noob so I guess php71 doesn't play extension like this? But I still added it somewhere in php.ini
where it comments about extension.
我是菜鸟,所以我猜 php71 不会像这样播放扩展?但我仍然php.ini
在它评论扩展的某个地方添加了它。
Then more errors threw out.
然后抛出了更多错误。
Please Let me know what is going on.
请让我知道发生了什么。
EDIT:
Thanks for Daniel, after running yum install php-mysqlnd
the following error shown:
编辑:感谢丹尼尔,在运行yum install php-mysqlnd
显示以下错误后:
> Loaded plugins: fastestmirror Loading mirror speeds from cached
> hostfile * base: mirror.team-cymru.com * epel: mirror.steadfast.net
> * extras: mirror.team-cymru.com * remi-safe: mirror.team-cymru.com * updates: mirror.genesisadaptive.com Resolving Dependencies
> --> Running transaction check
> ---> Package php-mysqlnd.x86_64 0:5.4.16-45.el7 will be installed
> --> Processing Conflict: php-mysql-5.4.16-45.el7.x86_64 conflicts php-mysqlnd
> --> Finished Dependency Resolution Error: php-mysql conflicts with php-mysqlnd-5.4.16-45.el7.x86_64 You could try using --skip-broken to
> work around the problem
> ** Found 12 pre-existing rpmdb problem(s), 'yum check' output follows: 1:NetworkManager-1.10.2-14.el7_5.x86_64 has missing requires of
> NetworkManager-libnm(x86-64) = ('1', '1.10.2', '14. el7_5')
> 1:NetworkManager-1.10.2-16.el7_5.x86_64 is a duplicate with
> 1:NetworkManager-1.10.2-14.el7_5.x86_64
> binutils-2.27-28.base.el7_5.1.x86_64 is a duplicate with
> binutils-2.27-27.base.el7.x86_64 gnupg2-2.0.22-5.el7_5.x86_64 is a
> duplicate with gnupg2-2.0.22-4.el7.x86_64
> google-cloud-sdk-207.0.0-1.el7.noarch is a duplicate with
> google-cloud-sdk-204.0.0-1.el7.noarch
> google-cloud-sdk-208.0.1-1.el7.noarch is a duplicate with
> google-cloud-sdk-207.0.0-1.el7.noarch
> google-cloud-sdk-208.0.2-1.el7.noarch is a duplicate with
> google-cloud-sdk-208.0.1-1.el7.noarch
> google-cloud-sdk-209.0.0-1.el7.noarch is a duplicate with
> google-cloud-sdk-208.0.2-1.el7.noarch httpd-2.4.6-80.el7.centos.x86_64
> has missing requires of httpd-tools = ('0', '2.4.6', '80.el7.centos')
> httpd-2.4.6-80.el7.centos.1.x86_64 is a duplicate with
> httpd-2.4.6-80.el7.centos.x86_64
> selinux-policy-targeted-3.13.1-192.el7_5.3.noarch has missing requires
> of selinux-policy = ('0', '3.13.1', '192.el7
> _5.3') selinux-policy-targeted-3.13.1-192.el7_5.4.noarch is a duplicate with selinux-policy-targeted-3.13.1-192.el7_5.3.no arch
回答by Ahmed Numaan
Try the following command:
尝试以下命令:
yum install php71w-mysqlnd
If the installation is executed by this command then it will be added automatically to php.ini
configuration file.
如果通过此命令执行安装,则会自动将其添加到php.ini
配置文件中。
回答by Daniel
MariaDB is a branch of MySQL so install the PHP 7.1 version of the PDO driver for MySQL by running
MariaDB 是 MySQL 的一个分支,因此通过运行为 MySQL 安装 PHP 7.1 版本的 PDO 驱动程序
yum install php7.1-mysql
This should automatically add it to the loaded configuration php.ini
file.
这应该会自动将其添加到加载的配置php.ini
文件中。