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

LaravelやCakePHPでPDOが見つからない場合の対処方法

エラーの発生内容

AWSのEC2(AmazonLinux)で下記のフレームワークを実行した際に表題のエラーが発生した。
・Laravelのmigrate実行時
・CakePHPのビルドインサーバー実行時

環境

PHP7.2
PostgreSQL10系

対処方法

下記のコマンドを実行して、自身の環境に合ったモジュールを探す

$ yum search php-pdo

そうすると、下記のように表示される。

Loaded plugins: extras_suggestions, langpacks, priorities, update-motd
242 packages excluded due to repository priority protections
=========================================================================================================== N/S matched: php-pdo ============================================================================================================
php-pdo.x86_64 : A database access abstraction module for PHP applications
php-pdo-dblib.x86_64 : PDO driver Microsoft SQL Server and Sybase databases
php54-php-pdo.x86_64 : A database access abstraction module for PHP applications
php55-php-pdo.x86_64 : A database access abstraction module for PHP applications
php56-php-pdo.x86_64 : A database access abstraction module for PHP applications
php70-php-pdo.x86_64 : A database access abstraction module for PHP applications
php70-php-pdo-dblib.x86_64 : PDO driver Microsoft SQL Server and Sybase databases
php71-php-pdo.x86_64 : A database access abstraction module for PHP applications
php71-php-pdo-dblib.x86_64 : PDO driver Microsoft SQL Server and Sybase databases
php72-php-pdo.x86_64 : A database access abstraction module for PHP applications
php72-php-pdo-dblib.x86_64 : PDO driver Microsoft SQL Server and Sybase databases
php73-php-pdo.x86_64 : A database access abstraction module for PHP applications
php73-php-pdo-dblib.x86_64 : PDO driver Microsoft SQL Server and Sybase databases
php74-php-pdo.x86_64 : A database access abstraction module for PHP applications
php74-php-pdo-dblib.x86_64 : PDO driver for Microsoft SQL Server and Sybase databases
php74-php-pdo-firebird.x86_64 : PDO driver for Interbase/Firebird databases

  Name and summary matches only, use "search all" for everything.

今回使用しているPHPのバージョンはPHP7.2なので、下記のコマンドを実行してPDOをインストール

$ sudo yum install php72-php-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
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