質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.48%
CentOS

CentOSは、主にRed Hat Enterprise Linux(RHEL)をベースにした、フリーのソフトウェアオペレーティングシステムです。

PostgreSQL

PostgreSQLはオープンソースのオブジェクトリレーショナルデータベース管理システムです。 Oracle Databaseで使われるPL/SQLを参考に実装されたビルトイン言語で、Windows、 Mac、Linux、UNIX、MSなどいくつものプラットフォームに対応しています。

PDO

PDO(PHP Data Objects)はPHPのデータベース抽象化レイヤーです。

PHP

PHPは、Webサイト構築に特化して開発されたプログラミング言語です。大きな特徴のひとつは、HTMLに直接プログラムを埋め込むことができるという点です。PHPを用いることで、HTMLを動的コンテンツとして出力できます。HTMLがそのままブラウザに表示されるのに対し、PHPプログラムはサーバ側で実行された結果がブラウザに表示されるため、PHPスクリプトは「サーバサイドスクリプト」と呼ばれています。

rpm

rpmコマンドは、UNIX系OSのroot権限でのみ利用可能なコマンドで、 RPMパッケージのインストールなどができます。

Q&A

解決済

1回答

6341閲覧

"php -i"と"psql -V"で表示されるpostgresqlのバージョンを揃えたい

abababa03

総合スコア14

CentOS

CentOSは、主にRed Hat Enterprise Linux(RHEL)をベースにした、フリーのソフトウェアオペレーティングシステムです。

PostgreSQL

PostgreSQLはオープンソースのオブジェクトリレーショナルデータベース管理システムです。 Oracle Databaseで使われるPL/SQLを参考に実装されたビルトイン言語で、Windows、 Mac、Linux、UNIX、MSなどいくつものプラットフォームに対応しています。

PDO

PDO(PHP Data Objects)はPHPのデータベース抽象化レイヤーです。

PHP

PHPは、Webサイト構築に特化して開発されたプログラミング言語です。大きな特徴のひとつは、HTMLに直接プログラムを埋め込むことができるという点です。PHPを用いることで、HTMLを動的コンテンツとして出力できます。HTMLがそのままブラウザに表示されるのに対し、PHPプログラムはサーバ側で実行された結果がブラウザに表示されるため、PHPスクリプトは「サーバサイドスクリプト」と呼ばれています。

rpm

rpmコマンドは、UNIX系OSのroot権限でのみ利用可能なコマンドで、 RPMパッケージのインストールなどができます。

0グッド

2クリップ

投稿2018/03/29 09:40

編集2018/03/29 09:49

前提・実現したいこと

centos6でweb開発環境を構築しております。phpの設定を見直していたところ、"php -i"と"psql -V"で表示されるpostgresqlのバージョンが異なることに気づきました。

[root@localhost ~]# php -i | grep PostgreSQL PDO Driver for PostgreSQL => enabled PostgreSQL(libpq) Version => 8.4.20 PostgreSQL Support => enabled PostgreSQL(libpq) Version => 8.4.20 PostgreSQL(libpq) => PostgreSQL 8.4.20 on x86_64-redhat-linux-gnu, compiled by GCC gcc (GCC) 4.4.7 20120313 (Red Hat 4.4.7-17), 64-bit [root@localhost ~]# psql -V psql (PostgreSQL) 9.6.8

コマンドラインからのpostgresql接続はできています。現在用意したphpファイルでpg_connect()が読み込まれていないエラーが出ており、このバージョンの差異のせいなのかなと思案しています。postgresqlはデフォルトの8.4.20ではなく9.6を使用したいです。どのようにしたら揃えられるでしょうか?

開発環境

CentOS release 6.9 (Final)
Server version: Apache/2.2.15 (Unix)
PHP 7.0.29 (cli) (built: Mar 28 2018 07:19:53) ( NTS )

必要なパッケージはソースではなくyumでインストールしています。

試したこと

バージョンを揃える方法を探していたところ、peclでPDO_PGSQLをインストールしたらよいというのを見かけたので試してみました。
"yum remove php70-php-pgsql"で現在インストールしているpdo_pgsqlを削除し、"php -m"でpdo_pgsqlが消えているのを確認しました。

発生している問題・エラーメッセージ

peclでのインストールはmakeで失敗しているようです。

[root@localhost ~]# pecl install PDO_PGSQL WARNING: "pecl/PDO" is deprecated in favor of "channel://http://svn.php.net/viewvc/php/php-src/trunk/ext/pdo//ext/PDO" downloading PDO_PGSQL-1.0.2.tgz ... Starting to download PDO_PGSQL-1.0.2.tgz (14,961 bytes) .....done: 14,961 bytes downloading PDO-1.0.3.tgz ... Starting to download PDO-1.0.3.tgz (52,613 bytes) ...done: 52,613 bytes 12 source files, building running: phpize Configuring for: PHP Api Version: 20151012 Zend Module Api No: 20151012 Zend Extension Api No: 320151012 building in /var/tmp/pear-build-minoue0KBhq0/PDO-1.0.3 running: /var/tmp/PDO/configure --with-php-config=/opt/remi/php70/root/usr/bin/php-config checking for grep that handles long lines and -e... /bin/grep checking for egrep... /bin/grep -E checking for a sed that does not truncate output... /bin/sed checking for cc... cc // 中略 checking whether to build static libraries... no configure: creating ./config.status config.status: creating config.h config.status: executing libtool commands running: make /bin/sh /var/tmp/pear-build-minoue0KBhq0/PDO-1.0.3/libtool --mode=compile cc -I. -I/var/tmp/PDO -DPHP_ATOM_INC -I/var/tmp/pear-build-minoue0KBhq0/PDO-1.0.3/include -I/var/tmp/pear-build-minoue0KBhq0/PDO-1.0.3/main -I/var/tmp/PDO -I/opt/remi/php70/root/usr/include/php -I/opt/remi/php70/root/usr/include/php/main -I/opt/remi/php70/root/usr/include/php/TSRM -I/opt/remi/php70/root/usr/include/php/Zend -I/opt/remi/php70/root/usr/include/php/ext -I/opt/remi/php70/root/usr/include/php/ext/date/lib -DHAVE_CONFIG_H -g -O2 -c /var/tmp/PDO/pdo.c -o pdo.lo libtool: compile: cc -I. -I/var/tmp/PDO -DPHP_ATOM_INC -I/var/tmp/pear-build-minoue0KBhq0/PDO-1.0.3/include -I/var/tmp/pear-build-minoue0KBhq0/PDO-1.0.3/main -I/var/tmp/PDO -I/opt/remi/php70/root/usr/include/php -I/opt/remi/php70/root/usr/include/php/main -I/opt/remi/php70/root/usr/include/php/TSRM -I/opt/remi/php70/root/usr/include/php/Zend -I/opt/remi/php70/root/usr/include/php/ext -I/opt/remi/php70/root/usr/include/php/ext/date/lib -DHAVE_CONFIG_H -g -O2 -c /var/tmp/PDO/pdo.c -fPIC -DPIC -o .libs/pdo.o In file included from /var/tmp/PDO/pdo.c:32: /var/tmp/PDO/php_pdo_driver.h: In function 'pdo_attr_lval': /var/tmp/PDO/php_pdo_driver.h:191: error: too many arguments to function 'zend_hash_index_find' /var/tmp/PDO/php_pdo_driver.h:192: warning: passing argument 1 of 'zval_get_type' from incompatible pointer type /opt/remi/php70/root/usr/include/php/Zend/zend_types.h:326: note: expected 'const struct zval *' but argument is of type 'struct zval **' /var/tmp/PDO/php_pdo_driver.h:192: warning: passing argument 1 of 'convert_to_long' from incompatible pointer type /opt/remi/php70/root/usr/include/php/Zend/zend_operators.h:244: note: expected 'struct zval *' but argument is of type 'struct zval **' /var/tmp/PDO/php_pdo_driver.h: In function 'pdo_attr_strval': /var/tmp/PDO/php_pdo_driver.h:201: error: too many arguments to function 'zend_hash_index_find' /var/tmp/PDO/php_pdo_driver.h:202: warning: passing argument 1 of 'zval_get_type' from incompatible pointer type /opt/remi/php70/root/usr/include/php/Zend/zend_types.h:326: note: expected 'const struct zval *' but argument is of type 'struct zval **' /var/tmp/PDO/php_pdo_driver.h:202: warning: passing argument 1 of 'zval_get_type' from incompatible pointer type /opt/remi/php70/root/usr/include/php/Zend/zend_types.h:326: note: expected 'const struct zval *' but argument is of type 'struct zval **' /var/tmp/PDO/php_pdo_driver.h:202: warning: passing argument 1 of '_convert_to_string' from incompatible pointer type /opt/remi/php70/root/usr/include/php/Zend/zend_operators.h:243: note: expected 'struct zval *' but argument is of type 'struct zval **' /var/tmp/PDO/php_pdo_driver.h:203: warning: passing argument 1 of '_estrndup' makes pointer from integer without a cast /opt/remi/php70/root/usr/include/php/Zend/zend_alloc.h:85: note: expected 'const char *' but argument is of type 'int' In file included from /var/tmp/PDO/pdo.c:33: /var/tmp/PDO/php_pdo_int.h: At top level: /var/tmp/PDO/php_pdo_int.h:34: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'pdo_dbh_new' /var/tmp/PDO/php_pdo_int.h:39: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'pdo_dbstmt_new' /var/tmp/PDO/php_pdo_int.h:48: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'pdo_row_new' /var/tmp/PDO/pdo.c: In function 'php_pdo_get_exception_base': /var/tmp/PDO/pdo.c:68: warning: passing argument 2 of 'zend_hash_find' from incompatible pointer type /opt/remi/php70/root/usr/include/php/Zend/zend_hash.h:154: note: expected 'struct zend_string *' but argument is of type 'char *' /var/tmp/PDO/pdo.c:68: error: too many arguments to function 'zend_hash_find' /var/tmp/PDO/pdo.c: In function 'zif_pdo_drivers': /var/tmp/PDO/pdo.c:96: warning: passing argument 2 of 'zend_hash_get_current_data_ex' from incompatible pointer type /opt/remi/php70/root/usr/include/php/Zend/zend_hash.h:171: note: expected 'HashPosition *' but argument is of type 'void **' /var/tmp/PDO/pdo.c:96: error: too many arguments to function 'zend_hash_get_current_data_ex' /var/tmp/PDO/pdo.c:97: error: too many arguments to function 'add_next_index_stringl' /var/tmp/PDO/pdo.c: In function 'php_pdo_register_driver': /var/tmp/PDO/pdo.c:165: warning: passing argument 2 of 'zend_hash_exists' from incompatible pointer type /opt/remi/php70/root/usr/include/php/Zend/zend_hash.h:159: note: expected 'struct zend_string *' but argument is of type 'char *' /var/tmp/PDO/pdo.c:165: error: too many arguments to function 'zend_hash_exists' /var/tmp/PDO/pdo.c:171:41: error: macro "zend_hash_add" passed 6 arguments, but takes just 3 /var/tmp/PDO/pdo.c:170: error: 'zend_hash_add' undeclared (first use in this function) /var/tmp/PDO/pdo.c:170: error: (Each undeclared identifier is reported only once /var/tmp/PDO/pdo.c:170: error: for each function it appears in.) /var/tmp/PDO/pdo.c: In function 'php_pdo_unregister_driver': /var/tmp/PDO/pdo.c:176: warning: passing argument 2 of 'zend_hash_exists' from incompatible pointer type /opt/remi/php70/root/usr/include/php/Zend/zend_hash.h:159: note: expected 'struct zend_string *' but argument is of type 'char *' /var/tmp/PDO/pdo.c:176: error: too many arguments to function 'zend_hash_exists' /var/tmp/PDO/pdo.c:180: warning: passing argument 2 of 'zend_hash_del' from incompatible pointer type /opt/remi/php70/root/usr/include/php/Zend/zend_hash.h:146: note: expected 'struct zend_string *' but argument is of type 'char *' /var/tmp/PDO/pdo.c:180: error: too many arguments to function 'zend_hash_del' /var/tmp/PDO/pdo.c: In function 'pdo_find_driver': /var/tmp/PDO/pdo.c:187: warning: passing argument 2 of 'zend_hash_find' from incompatible pointer type /opt/remi/php70/root/usr/include/php/Zend/zend_hash.h:154: note: expected 'struct zend_string *' but argument is of type 'char *' /var/tmp/PDO/pdo.c:187: error: too many arguments to function 'zend_hash_find' /var/tmp/PDO/pdo.c: In function 'zm_startup_pdo': /var/tmp/PDO/pdo.c:323: error: too many arguments to function 'zend_register_internal_class_ex' /var/tmp/PDO/pdo.c: In function 'zm_info_pdo': /var/tmp/PDO/pdo.c:371: warning: passing argument 2 of 'zend_hash_get_current_data_ex' from incompatible pointer type /opt/remi/php70/root/usr/include/php/Zend/zend_hash.h:171: note: expected 'HashPosition *' but argument is of type 'void **' /var/tmp/PDO/pdo.c:371: error: too many arguments to function 'zend_hash_get_current_data_ex' make: *** [pdo.lo] Error 1 ERROR: `make' failed

長くなりましたが、知りたいのは以下になります。

  1. "php -i"と"psql -V"で表示されるpostgresqlのバージョンを揃える方法
  2. もしpeclを使った方法が方向性として正しいのであれば、現在出ているmakeエラーの解決方法

何か足りない情報などありましたらご指摘ください。よろしくお願いいたします。

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

退会済みユーザー

退会済みユーザー

2018/03/29 09:55

6.9とか2.2とか7.0は維持しつつも、php-pgsqlを更新したい、と?
abababa03

2018/03/29 10:01

はい、"php -i | grep PostgreSQL"で表示されるバージョンを9.6.8に揃えたいです。
abababa03

2018/03/29 10:03

すみません、6.9とか2.2とか7.0は維持しつつ、です
deadjupiter

2018/03/29 10:37

deprecatedって言われてんだからPHP 7.0.29本体に入ってるext/pdo_pgsqlをmakeしたら?
退会済みユーザー

退会済みユーザー

2018/03/29 11:30

ソースからインストールしたら?(いろいろと追加は必要だが)
guest

回答1

0

自己解決

PHPをソースから入れ直し解決することができました。ご意見をくださったみなさま有難うございました。

[root@localhost ~]# php -i | grep PostgreSQL PDO Driver for PostgreSQL => enabled PostgreSQL(libpq) Version => 9.6.8 PostgreSQL Support => enabled PostgreSQL(libpq) Version => 9.6.8 PostgreSQL(libpq) => PostgreSQL 9.6.8 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 4.4.7 20120313 (Red Hat 4.4.7-18), 64-bit

投稿2018/03/30 07:28

abababa03

総合スコア14

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.48%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問