Help us understand the problem. What is going on with this article?

PHP7+Nginx+MariaDBでPDO接続したとき"could not find driver"が出た際にやったこと

More than 3 years have passed since last update.

検索から一発で正解に辿りつけなかったので備忘録もかねて書き残す。

環境

CentOS release 6.8 (Final)
PHP7.0.9
Nginx1.0.15
10.1.16-MariaDB

現状

phpinfo(); を表示して現状を見てみる。
2016-08-17_03h51_26.png

本来はPDO driversのとこにmysqlが入っているはず。

php-mysqlndを入れる

どこかでphp-mysqlnd入れた方がいいよと書いてあったので入れてみる。

sudo yum install --enablerepo=remi-php70 php-mysqlnd
~ ~ ~
sudo yum list installed | grep php-mysqlnd                                                     
php-mysqlnd.x86_64               7.0.9-1.el6.remi                    @remi-php70

php-fpmを再起動

sudo service php-fpm restart

ここがちょっとハマった。
Apacheの感覚でNginxを再起動していたので、変化なくて「あれ~?」ってなった。

反映を確認

PDO driversのところにmysqlが追加されていることが確認できる。
あとpdo_mysqlという項目も増えている。
2016-08-17_03h56_02.png

PDO接続も試して私の環境では無事接続できることを確認した。

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした