LoginSignup
7
7

More than 5 years have passed since last update.

postgresql+phpの環境構築 (Mac OSX, Marvericks)

Last updated at Posted at 2014-05-13

apacheとphpはMacに標準で用意されているものを使い、postgresはHomebrewでインストールした。

Homebrewでpostgresqlのインストール

$ brew install postgresql

pgsqlの拡張機能を追加

標準で用意されているphpには,pgsqlの拡張機能が入ってない.
ソースコードをダウンロードして,インストールした.
標準で入っているphpと同じバージョンのものをダウンロードし,適当な場所に解凍し,

$ ./configure

をする.問題なければ,拡張機能のディレクトリに移動し,phpizeを実行する.

$ cd ext/pgsql
$ phpize

autoconfがないとエラーがでた.

Configuring for:
PHP Api Version:         20100412
Zend Module Api No:      20100525
Zend Extension Api No:   220100525
Cannot find autoconf. Please check your autoconf installation and the
$PHP_AUTOCONF environment variable. Then, rerun this script.

Homebrewでautoconfをインストールし,再度phpizeを実行すると,configureが作成されたので,pgsqlをコンパイルし,インストールした.

$ brew install autoconf
$ phpize
$ ./configure
$ make
$ cp modules/pgsql.so /path/to/php_extension_dir

php.iniの編集

phpの設定ファイルphp.iniにpgsqlの行を追記.

extension=pgsql.so

設定ファイルに書かれている行のコメントを外せばいいのかと思いきや,

;extension=php_pgsql.dll

これはwindows用のdllファイル.紛らわしかった.
apacheを再起動して,phpinfo()で,pgsqlが読み込まれていることを確認できた.

7
7
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
7
7