MacにphpPgAdminを入れてみる
phpMyAdminのサイトに行ってDownloadを選択。
http://phppgadmin.sourceforge.net/index.php
↓
今回はphpPgAdmin-4.2.3.tar.gzを選択。
バージョンは2010年7月8日現在のもの。
↓
phpPgAdminを展開する場所を決めます。
今回はMacPortsでインストールしたapache2を使います。
デフォルトのドキュメントルートは
/opt/local/apache2/htdocs
になっています。
Max OS Xにバンドルされているapacheを使う場合のデフォルトのドキュメントルートは
/Library/WebServer/Documents/
になっています。
さらにバンドルapache2で「http://localhost/~ユーザー名」でアクセスする場合は
/Users/ユーザー名/Sites
です。
↓
ドキュメントルートにphpPgAdmin-4.2.3.tar.gzを置いてダブルクリックしてその場に解凍します。
パーミッションもちゃんと再現してくれます。
解凍されて出来たフォルダを「phpPgAdmin-4.2.3」から「phpPgAdmin」に変更します。
↓
phpPgAdmiの下のconf/config.inc.php-disをコピーしてconfig.inc.phpにリネームします。
リネームしたconfig.inc.phpを編集します。
postgresが動いてるサーバのホスト名またはIPアドレスを設定します。
例)
$conf['servers'][0]['host'] = '192.168.0.xxx';
↓
phpでpostgresqlを使える状態になっていない場合、/phpPgAdmin/にアクセスすると以下のようなメッセージが表示されると思います。
「データベースをサポートするように PHP のコンパイル・インストールがされていません。configure の --with-pgsql オプションを用いて PHP を再コンパイルする必要があります。」
または
「Your PHP installation does not support PostgreSQL. You need to recompile PHP using the --with-pgsql configure option.」
言われた通りphpをインストールしなおす必要があるかもしれません。configureで--with-pgsqlを付けてコンパイルしてインストールします。
CentOSとかだと「yum install php-pgsql」だけでいけると思います。
自分はMacPortsで入れ直しました。ついでに必要そうなものがあったら入れておく。
インストール済みのphpとオプションを確認する。
# port installed | grep php
php5 @5.3.2_0+apache2 (active)
アンインストール
# port uninstall php5
インストール
# port install php5 +apache2 +mysql5 +postgresql84
インストール中にphp5-postgresqlをインストールしてくださいと出る。
The +postgresql83 variant is obsolete. Please install the php5-postgresql port instead.
最後の方でこのphpを有効にする方法を教えてくれる。
If this is your first install, you need to activate PHP in your web server.
To enable PHP in Apache, run
cd /opt/local/apache2/modules
/opt/local/apache2/bin/apxs -a -e -n "php5" libphp5.so
php5-postgresqlインストール
# port install php5-postgresql
apacheにモジュールを追加します。
# cd /opt/local/apache2/modules
# /opt/local/apache2/bin/apxs -a -e -n "php5" libphp5.so
[activating module `php5' in /opt/local/apache2/conf/httpd.conf]
/opt/local/apache2/conf/httpd.confには以下を追記
Include conf/extra/mod_php.conf
/opt/local/apache2/conf/extra/mod_php.confはこうする。
<IfModule php5_module>
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
<IfModule dir_module>
DirectoryIndex index.html index.php
</IfModule>
</IfModule>
↓
次はこんなエラーが出た。
--------------------
Deprecated: Assigning the return value of new by reference is deprecated in /opt/local/apache2/htdocs/phpPgAdmin/classes/Misc.php on line 344
Warning: session_start() [function.session-start]: open(/var/folders/BP/BPYVBESYEA8pbaykdpSOKU+++TI/-Tmp-/sess_o9i2dhcir4ahk3dt29r8uucj62, O_RDWR) failed: Permission denied (13) in /opt/local/apache2/htdocs/phpPgAdmin/libraries/lib.inc.php on line 56
Warning: Unknown: open(/var/folders/BP/BPYVBESYEA8pbaykdpSOKU+++TI/-Tmp-/sess_o9i2dhcir4ahk3dt29r8uucj62, O_RDWR) failed: Permission denied (13) in Unknown on line 0
Warning: Unknown: Failed to write session data (files). Please verify that the current setting of session.save_path is correct () in Unknown on line 0
--------------------
-Tmp-ディレクトリのパーミッションを変える。
# /var/folders/BP/BPYVBESYEA8pbaykdpSOKU+++TI
--------------------
Deprecated: Assigning the return value of new by reference is deprecated in /opt/local/apache2/htdocs/phpPgAdmin/classes/Misc.php on line 344
--------------------
エラーは減ったけどまだ残っている。
Misc.phpの344行目あたりを見てみる
// Create a database wrapper class for easy manipulation of the
// connection.
include_once('./classes/database/' . $_type . '.php');
$data =& new $_type($_connection->conn); ←344行目
$data->platform = $_connection->platform;
調べてみると、php4ではnewの結果を「=&」で参照渡ししていたのが、php5では使われなくなり「=」でのみ参照渡しできるようになっていた為。
$data =& new $_type($_connection->conn); ←344行目
↓
$data = new $_type($_connection->conn); ←344行目
こうしたらエラーが出なくなった。
php4.3で動かせという事だろうか。
http://phppgadmin.sourceforge.net/index.php
↓
今回はphpPgAdmin-4.2.3.tar.gzを選択。
バージョンは2010年7月8日現在のもの。
↓
phpPgAdminを展開する場所を決めます。
今回はMacPortsでインストールしたapache2を使います。
デフォルトのドキュメントルートは
/opt/local/apache2/htdocs
になっています。
Max OS Xにバンドルされているapacheを使う場合のデフォルトのドキュメントルートは
/Library/WebServer/Documents/
になっています。
さらにバンドルapache2で「http://localhost/~ユーザー名」でアクセスする場合は
/Users/ユーザー名/Sites
です。
↓
ドキュメントルートにphpPgAdmin-4.2.3.tar.gzを置いてダブルクリックしてその場に解凍します。
パーミッションもちゃんと再現してくれます。
解凍されて出来たフォルダを「phpPgAdmin-4.2.3」から「phpPgAdmin」に変更します。
↓
phpPgAdmiの下のconf/config.inc.php-disをコピーしてconfig.inc.phpにリネームします。
リネームしたconfig.inc.phpを編集します。
postgresが動いてるサーバのホスト名またはIPアドレスを設定します。
例)
$conf['servers'][0]['host'] = '192.168.0.xxx';
↓
phpでpostgresqlを使える状態になっていない場合、/phpPgAdmin/にアクセスすると以下のようなメッセージが表示されると思います。
「データベースをサポートするように PHP のコンパイル・インストールがされていません。configure の --with-pgsql オプションを用いて PHP を再コンパイルする必要があります。」
または
「Your PHP installation does not support PostgreSQL. You need to recompile PHP using the --with-pgsql configure option.」
言われた通りphpをインストールしなおす必要があるかもしれません。configureで--with-pgsqlを付けてコンパイルしてインストールします。
CentOSとかだと「yum install php-pgsql」だけでいけると思います。
自分はMacPortsで入れ直しました。ついでに必要そうなものがあったら入れておく。
インストール済みのphpとオプションを確認する。
# port installed | grep php
php5 @5.3.2_0+apache2 (active)
アンインストール
# port uninstall php5
インストール
# port install php5 +apache2 +mysql5 +postgresql84
インストール中にphp5-postgresqlをインストールしてくださいと出る。
The +postgresql83 variant is obsolete. Please install the php5-postgresql port instead.
最後の方でこのphpを有効にする方法を教えてくれる。
If this is your first install, you need to activate PHP in your web server.
To enable PHP in Apache, run
cd /opt/local/apache2/modules
/opt/local/apache2/bin/apxs -a -e -n "php5" libphp5.so
php5-postgresqlインストール
# port install php5-postgresql
apacheにモジュールを追加します。
# cd /opt/local/apache2/modules
# /opt/local/apache2/bin/apxs -a -e -n "php5" libphp5.so
[activating module `php5' in /opt/local/apache2/conf/httpd.conf]
/opt/local/apache2/conf/httpd.confには以下を追記
Include conf/extra/mod_php.conf
/opt/local/apache2/conf/extra/mod_php.confはこうする。
<IfModule php5_module>
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
<IfModule dir_module>
DirectoryIndex index.html index.php
</IfModule>
</IfModule>
↓
次はこんなエラーが出た。
--------------------
Deprecated: Assigning the return value of new by reference is deprecated in /opt/local/apache2/htdocs/phpPgAdmin/classes/Misc.php on line 344
Warning: session_start() [function.session-start]: open(/var/folders/BP/BPYVBESYEA8pbaykdpSOKU+++TI/-Tmp-/sess_o9i2dhcir4ahk3dt29r8uucj62, O_RDWR) failed: Permission denied (13) in /opt/local/apache2/htdocs/phpPgAdmin/libraries/lib.inc.php on line 56
Warning: Unknown: open(/var/folders/BP/BPYVBESYEA8pbaykdpSOKU+++TI/-Tmp-/sess_o9i2dhcir4ahk3dt29r8uucj62, O_RDWR) failed: Permission denied (13) in Unknown on line 0
Warning: Unknown: Failed to write session data (files). Please verify that the current setting of session.save_path is correct () in Unknown on line 0
--------------------
-Tmp-ディレクトリのパーミッションを変える。
# /var/folders/BP/BPYVBESYEA8pbaykdpSOKU+++TI
--------------------
Deprecated: Assigning the return value of new by reference is deprecated in /opt/local/apache2/htdocs/phpPgAdmin/classes/Misc.php on line 344
--------------------
エラーは減ったけどまだ残っている。
Misc.phpの344行目あたりを見てみる
// Create a database wrapper class for easy manipulation of the
// connection.
include_once('./classes/database/' . $_type . '.php');
$data =& new $_type($_connection->conn); ←344行目
$data->platform = $_connection->platform;
調べてみると、php4ではnewの結果を「=&」で参照渡ししていたのが、php5では使われなくなり「=」でのみ参照渡しできるようになっていた為。
$data =& new $_type($_connection->conn); ←344行目
↓
$data = new $_type($_connection->conn); ←344行目
こうしたらエラーが出なくなった。
php4.3で動かせという事だろうか。