LoginSignup
0
1

More than 5 years have passed since last update.

【備忘録】MacのPHPからPostgreSQLに接続する準備【PHP】【PostgreSQL】

Posted at

MacのデフォルトのPHPではPostgreSQLに接続できない問題

【状況】 PostgreSQL使用時にDB接続エラーに遭遇した

PHPからDBに接続しようとすると、以下のようなエラーが出てしまいました😇

  [PDOException]         
  could not find driver 

【解決策】 そんな時はbrewで楽にインストールしたいですよね?

--with-postgresql

オプションを使えば、使用中のphpにオプション追加して、インストールが可能です。

$ brew update
$ brew upgrade
↑ 最近アップデート、アップグレードしてないわーって方はこちらを

$ brew unlink php71
↑ 使用中のphpをunlinkしないと、コンフリクトしてエラーって言われる場合があります

$ brew reinstall php71 --with-postgresql
$ brew link php71

【補足?】 違うエラーが出たんですけど...

ZLIBがないよって言われちゃう時があります。

$ brew reinstall php71 --with-postgresql
..
省略
..
checking if the location of ZLIB install directory is defined... no
configure: error: Cannot find libz

そんな時は、

$ xcode-select --install

で、インストールしてあげましょう。

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1