How to install php-pgsql on CentOS


Step 1: find PHP version

[root@tutorialspots public_html]# php -v
PHP 5.6.30 (cli) (built: Jan 19 2017 07:57:06)
Copyright (c) 1997-2016 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies
    with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2016, by Zend Technologies

Step 2:

[root@tutorialspots public_html]# yum list *pgsql*
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirror.sale-dedic.com
 * epel: mirror.datacenter.by
 * extras: mirror.sale-dedic.com
 * remi-safe: mirror.reconn.ru
 * updates: mirror.sale-dedic.com
Available Packages
apr-util-pgsql.x86_64                          1.5.2-6.el7             base
dovecot-pgsql.x86_64                           1:2.2.10-8.el7          base
dspam-pgsql.x86_64                             3.10.2-12.el7           epel
erlang-epgsql.x86_64                           1.4-2.el7               epel
exim-pgsql.x86_64                              4.90.1-3.el7            epel
gnokii-smsd-pgsql.x86_64                       0.6.31-17.el7           epel
libdbi-dbd-pgsql.x86_64                        0.8.3-16.el7            base
libodb-pgsql.x86_64                            2.3.1-1.el7             epel
libodb-pgsql-devel.x86_64                      2.3.1-1.el7             epel
nagios-plugins-pgsql.x86_64                    2.2.1-9git5c7eb5b9.el7  epel
osm2pgsql.x86_64                               0.92.0-1.el7            epel
php-ZendFramework-Db-Adapter-Pdo-Pgsql.noarch  1.12.20-1.el7           epel
php-pear-MDB2-Driver-pgsql.noarch              1.5.0-0.8.b4.el7        epel
php-pgsql.x86_64                               5.4.16-45.el7           base
php54-php-pgsql.x86_64                         5.4.45-14.el7.remi      remi-safe
php55-php-pgsql.x86_64                         5.5.38-8.el7.remi       remi-safe
php56-php-pgsql.x86_64                         5.6.36-1.el7.remi       remi-safe
php70-php-pgsql.x86_64                         7.0.30-1.el7.remi       remi-safe
php71-php-pgsql.x86_64                         7.1.18-1.el7.remi       remi-safe
php72-php-pgsql.x86_64                         7.2.6-1.el7.remi        remi-safe
preludedb-pgsql.x86_64                         4.1.0-1.el7             epel
redland-pgsql.x86_64                           1.0.16-6.el7            base
root-sql-pgsql.x86_64                          6.12.06-1.el7           epel
rsyslog-pgsql.x86_64                           8.24.0-16.el7_5.4       updates
zabbix20-proxy-pgsql.x86_64                    2.0.21-1.el7            epel
zabbix20-server-pgsql.x86_64                   2.0.21-1.el7            epel
zabbix20-web-pgsql.noarch                      2.0.21-1.el7            epel
zabbix22-dbfiles-pgsql.noarch                  2.2.21-1.el7            epel
zabbix22-proxy-pgsql.x86_64                    2.2.21-1.el7            epel
zabbix22-server-pgsql.x86_64                   2.2.21-1.el7            epel
zabbix22-web-pgsql.noarch                      2.2.21-1.el7            epel

Step 3:
in this case we install php56-php-pgsql

[root@tutorialspots public_html]# yum install php56-php-pgsql
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirror.sale-dedic.com
 * epel: mirror.logol.ru
 * extras: mirror.sale-dedic.com
 * remi-safe: mirror.reconn.ru
 * updates: mirror.sale-dedic.com
Resolving Dependencies
--> Running transaction check
---> Package php56-php-pgsql.x86_64 0:5.6.36-1.el7.remi will be installed
--> Processing Dependency: php56-php-pdo(x86-64) = 5.6.36-1.el7.remi for package
: php56-php-pgsql-5.6.36-1.el7.remi.x86_64
--> Running transaction check
---> Package php56-php-pdo.x86_64 0:5.6.36-1.el7.remi will be installed
--> Processing Dependency: php56-php-common(x86-64) = 5.6.36-1.el7.remi for pack
age: php56-php-pdo-5.6.36-1.el7.remi.x86_64
--> Running transaction check
---> Package php56-php-common.x86_64 0:5.6.36-1.el7.remi will be installed
--> Processing Dependency: php56-runtime for package: php56-php-common-5.6.36-1.
el7.remi.x86_64
--> Processing Dependency: php56-php-pecl-zip(x86-64) for package: php56-php-com
mon-5.6.36-1.el7.remi.x86_64
--> Processing Dependency: php56-php-pecl-jsonc(x86-64) for package: php56-php-c
ommon-5.6.36-1.el7.remi.x86_64
--> Running transaction check
---> Package php56-php-pecl-jsonc.x86_64 0:1.3.10-1.el7.remi will be installed
---> Package php56-php-pecl-zip.x86_64 0:1.15.2-1.el7.remi will be installed
--> Processing Dependency: libzip5(x86-64) >= 1.3.2 for package: php56-php-pecl-
zip-1.15.2-1.el7.remi.x86_64
---> Package php56-runtime.x86_64 0:2.3-1.el7.remi will be installed
--> Processing Dependency: scl-utils for package: php56-runtime-2.3-1.el7.remi.x
86_64
--> Processing Dependency: environment-modules for package: php56-runtime-2.3-1.
el7.remi.x86_64
--> Processing Dependency: /usr/sbin/semanage for package: php56-runtime-2.3-1.e
l7.remi.x86_64
--> Running transaction check
---> Package environment-modules.x86_64 0:3.2.10-10.el7 will be installed
---> Package libzip5.x86_64 0:1.2.0-1.el7.remi will be updated
---> Package libzip5.x86_64 0:1.5.1-1.el7.remi will be an update
---> Package policycoreutils-python.x86_64 0:2.5-22.el7 will be installed
--> Processing Dependency: policycoreutils = 2.5-22.el7 for package: policycoreu
tils-python-2.5-22.el7.x86_64
--> Processing Dependency: setools-libs >= 3.3.8-2 for package: policycoreutils-
python-2.5-22.el7.x86_64
--> Processing Dependency: libsemanage-python >= 2.5-9 for package: policycoreut
ils-python-2.5-22.el7.x86_64
--> Processing Dependency: audit-libs-python >= 2.1.3-4 for package: policycoreu
tils-python-2.5-22.el7.x86_64
--> Processing Dependency: python-IPy for package: policycoreutils-python-2.5-22
.el7.x86_64
--> Processing Dependency: libselinux-python for package: policycoreutils-python
-2.5-22.el7.x86_64
--> Processing Dependency: libqpol.so.1(VERS_1.4)(64bit) for package: policycore
utils-python-2.5-22.el7.x86_64
--> Processing Dependency: libqpol.so.1(VERS_1.2)(64bit) for package: policycore
utils-python-2.5-22.el7.x86_64
--> Processing Dependency: libcgroup for package: policycoreutils-python-2.5-22.
el7.x86_64
--> Processing Dependency: libapol.so.4(VERS_4.0)(64bit) for package: policycore
utils-python-2.5-22.el7.x86_64
--> Processing Dependency: checkpolicy for package: policycoreutils-python-2.5-2
2.el7.x86_64
--> Processing Dependency: libqpol.so.1()(64bit) for package: policycoreutils-py
thon-2.5-22.el7.x86_64
--> Processing Dependency: libapol.so.4()(64bit) for package: policycoreutils-py
thon-2.5-22.el7.x86_64
---> Package scl-utils.x86_64 0:20130529-18.el7_4 will be installed
--> Running transaction check
---> Package audit-libs-python.x86_64 0:2.8.1-3.el7 will be installed
--> Processing Dependency: audit-libs(x86-64) = 2.8.1-3.el7 for package: audit-l
ibs-python-2.8.1-3.el7.x86_64
---> Package checkpolicy.x86_64 0:2.5-6.el7 will be installed
---> Package libcgroup.x86_64 0:0.41-15.el7 will be installed
---> Package libselinux-python.x86_64 0:2.5-12.el7 will be installed
--> Processing Dependency: libselinux(x86-64) = 2.5-12.el7 for package: libselin
ux-python-2.5-12.el7.x86_64
---> Package libsemanage-python.x86_64 0:2.5-11.el7 will be installed
--> Processing Dependency: libsemanage = 2.5-11.el7 for package: libsemanage-pyt
hon-2.5-11.el7.x86_64
---> Package policycoreutils.x86_64 0:2.5-11.el7_3 will be updated
---> Package policycoreutils.x86_64 0:2.5-22.el7 will be an update
--> Processing Dependency: libsepol >= 2.5-8 for package: policycoreutils-2.5-22
.el7.x86_64
--> Processing Dependency: libselinux-utils >= 2.5-12 for package: policycoreuti
ls-2.5-22.el7.x86_64
---> Package python-IPy.noarch 0:0.75-6.el7 will be installed
---> Package setools-libs.x86_64 0:3.3.8-2.el7 will be installed
--> Running transaction check
---> Package audit-libs.x86_64 0:2.6.5-3.el7_3.1 will be updated
---> Package audit-libs.x86_64 0:2.8.1-3.el7 will be an update
---> Package libselinux.x86_64 0:2.5-6.el7 will be updated
--> Processing Dependency: libselinux(x86-64) = 2.5-6.el7 for package: libselinu
x-devel-2.5-6.el7.x86_64
---> Package libselinux.x86_64 0:2.5-12.el7 will be an update
---> Package libselinux-utils.x86_64 0:2.5-6.el7 will be updated
---> Package libselinux-utils.x86_64 0:2.5-12.el7 will be an update
---> Package libsemanage.x86_64 0:2.5-5.1.el7_3 will be updated
---> Package libsemanage.x86_64 0:2.5-11.el7 will be an update
---> Package libsepol.x86_64 0:2.5-6.el7 will be updated
--> Processing Dependency: libsepol(x86-64) = 2.5-6.el7 for package: libsepol-de
vel-2.5-6.el7.x86_64
---> Package libsepol.x86_64 0:2.5-8.1.el7 will be an update
--> Running transaction check
---> Package libselinux-devel.x86_64 0:2.5-6.el7 will be updated
---> Package libselinux-devel.x86_64 0:2.5-12.el7 will be an update
---> Package libsepol-devel.x86_64 0:2.5-6.el7 will be updated
---> Package libsepol-devel.x86_64 0:2.5-8.1.el7 will be an update
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================
 Package                   Arch      Version                 Repository    Size
================================================================================
Installing:
 php56-php-pgsql           x86_64    5.6.36-1.el7.remi       remi-safe     98 k
Installing for dependencies:
 audit-libs-python         x86_64    2.8.1-3.el7             base          75 k
 checkpolicy               x86_64    2.5-6.el7               base         294 k
 environment-modules       x86_64    3.2.10-10.el7           base         107 k
 libcgroup                 x86_64    0.41-15.el7             base          65 k
 libselinux-python         x86_64    2.5-12.el7              base         235 k
 libsemanage-python        x86_64    2.5-11.el7              base         112 k
 php56-php-common          x86_64    5.6.36-1.el7.remi       remi-safe    692 k
 php56-php-pdo             x86_64    5.6.36-1.el7.remi       remi-safe    104 k
 php56-php-pecl-jsonc      x86_64    1.3.10-1.el7.remi       remi-safe     45 k
 php56-php-pecl-zip        x86_64    1.15.2-1.el7.remi       remi-safe     43 k
 php56-runtime             x86_64    2.3-1.el7.remi          remi-safe    1.1 M
 policycoreutils-python    x86_64    2.5-22.el7              base         454 k
 python-IPy                noarch    0.75-6.el7              base          32 k
 scl-utils                 x86_64    20130529-18.el7_4       base          24 k
 setools-libs              x86_64    3.3.8-2.el7             base         619 k
Updating for dependencies:
 audit-libs                x86_64    2.8.1-3.el7             base          99 k
 libselinux                x86_64    2.5-12.el7              base         162 k
 libselinux-devel          x86_64    2.5-12.el7              base         186 k
 libselinux-utils          x86_64    2.5-12.el7              base         151 k
 libsemanage               x86_64    2.5-11.el7              base         150 k
 libsepol                  x86_64    2.5-8.1.el7             base         297 k
 libsepol-devel            x86_64    2.5-8.1.el7             base          77 k
 libzip5                   x86_64    1.5.1-1.el7.remi        remi-safe     55 k
 policycoreutils           x86_64    2.5-22.el7              base         867 k

Transaction Summary
================================================================================
Install  1 Package  (+15 Dependent packages)
Upgrade             (  9 Dependent packages)

Total download size: 6.1 M
Is this ok [y/d/N]: y
Downloading packages:
No Presto metadata available for remi-safe
No Presto metadata available for base
(1/25): audit-libs-2.8.1-3.el7.x86_64.rpm                  |  99 kB   00:00
(2/25): environment-modules-3.2.10-10.el7.x86_64.rpm       | 107 kB   00:00
(3/25): libcgroup-0.41-15.el7.x86_64.rpm                   |  65 kB   00:00
(4/25): audit-libs-python-2.8.1-3.el7.x86_64.rpm           |  75 kB   00:00
(5/25): libselinux-2.5-12.el7.x86_64.rpm                   | 162 kB   00:00
(6/25): checkpolicy-2.5-6.el7.x86_64.rpm                   | 294 kB   00:00
(7/25): libselinux-devel-2.5-12.el7.x86_64.rpm             | 186 kB   00:00
(8/25): libsemanage-2.5-11.el7.x86_64.rpm                  | 150 kB   00:00
(9/25): libselinux-python-2.5-12.el7.x86_64.rpm            | 235 kB   00:00
(10/25): libselinux-utils-2.5-12.el7.x86_64.rpm            | 151 kB   00:00
(11/25): libsepol-2.5-8.1.el7.x86_64.rpm                   | 297 kB   00:00
(12/25): libsemanage-python-2.5-11.el7.x86_64.rpm          | 112 kB   00:00
(13/25): libsepol-devel-2.5-8.1.el7.x86_64.rpm             |  77 kB   00:00
(14/25): libzip5-1.5.1-1.el7.remi.x86_64.rpm               |  55 kB   00:00
(15/25): php56-php-pdo-5.6.36-1.el7.remi.x86_64.rpm        | 104 kB   00:00
(16/25): php56-php-common-5.6.36-1.el7.remi.x86_64.rpm     | 692 kB   00:00
(17/25): php56-php-pecl-jsonc-1.3.10-1.el7.remi.x86_64.rpm |  45 kB   00:00
(18/25): php56-php-pecl-zip-1.15.2-1.el7.remi.x86_64.rpm   |  43 kB   00:00
(19/25): php56-php-pgsql-5.6.36-1.el7.remi.x86_64.rpm      |  98 kB   00:00
(20/25): policycoreutils-python-2.5-22.el7.x86_64.rpm      | 454 kB   00:00
(21/25): php56-runtime-2.3-1.el7.remi.x86_64.rpm           | 1.1 MB   00:00
(22/25): python-IPy-0.75-6.el7.noarch.rpm                  |  32 kB   00:00
(23/25): scl-utils-20130529-18.el7_4.x86_64.rpm            |  24 kB   00:00
(24/25): policycoreutils-2.5-22.el7.x86_64.rpm             | 867 kB   00:00
(25/25): setools-libs-3.3.8-2.el7.x86_64.rpm               | 619 kB   00:00
--------------------------------------------------------------------------------
Total                                              2.7 MB/s | 6.1 MB  00:02
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Warning: RPMDB altered outside of yum.
  Updating   : libsepol-2.5-8.1.el7.x86_64                                 1/34
  Updating   : libselinux-2.5-12.el7.x86_64                                2/34
  Updating   : audit-libs-2.8.1-3.el7.x86_64                               3/34
  Updating   : libsemanage-2.5-11.el7.x86_64                               4/34
  Updating   : libselinux-utils-2.5-12.el7.x86_64                          5/34
  Updating   : policycoreutils-2.5-22.el7.x86_64                           6/34
  Installing : libsemanage-python-2.5-11.el7.x86_64                        7/34
  Installing : audit-libs-python-2.8.1-3.el7.x86_64                        8/34
  Installing : libselinux-python-2.5-12.el7.x86_64                         9/34
  Installing : setools-libs-3.3.8-2.el7.x86_64                            10/34
  Updating   : libsepol-devel-2.5-8.1.el7.x86_64                          11/34
  Installing : checkpolicy-2.5-6.el7.x86_64                               12/34
  Installing : libcgroup-0.41-15.el7.x86_64                               13/34
  Installing : python-IPy-0.75-6.el7.noarch                               14/34
  Installing : policycoreutils-python-2.5-22.el7.x86_64                   15/34
  Updating   : libzip5-1.5.1-1.el7.remi.x86_64                            16/34
  Installing : environment-modules-3.2.10-10.el7.x86_64                   17/34
  Installing : scl-utils-20130529-18.el7_4.x86_64                         18/34
  Installing : php56-runtime-2.3-1.el7.remi.x86_64                        19/34
  Installing : php56-php-pecl-zip-1.15.2-1.el7.remi.x86_64                20/34
  Installing : php56-php-common-5.6.36-1.el7.remi.x86_64                  21/34
  Installing : php56-php-pecl-jsonc-1.3.10-1.el7.remi.x86_64              22/34
  Installing : php56-php-pdo-5.6.36-1.el7.remi.x86_64                     23/34
  Installing : php56-php-pgsql-5.6.36-1.el7.remi.x86_64                   24/34
  Updating   : libselinux-devel-2.5-12.el7.x86_64                         25/34
  Cleanup    : policycoreutils-2.5-11.el7_3.x86_64                        26/34
  Cleanup    : libselinux-devel-2.5-6.el7.x86_64                          27/34
  Cleanup    : libsemanage-2.5-5.1.el7_3.x86_64                           28/34
  Cleanup    : libselinux-utils-2.5-6.el7.x86_64                          29/34
  Cleanup    : libsepol-devel-2.5-6.el7.x86_64                            30/34
  Cleanup    : libselinux-2.5-6.el7.x86_64                                31/34
  Cleanup    : libsepol-2.5-6.el7.x86_64                                  32/34
  Cleanup    : audit-libs-2.6.5-3.el7_3.1.x86_64                          33/34
  Cleanup    : libzip5-1.2.0-1.el7.remi.x86_64                            34/34
  Verifying  : scl-utils-20130529-18.el7_4.x86_64                          1/34
  Verifying  : libsemanage-python-2.5-11.el7.x86_64                        2/34
  Verifying  : php56-runtime-2.3-1.el7.remi.x86_64                         3/34
  Verifying  : libselinux-python-2.5-12.el7.x86_64                         4/34
  Verifying  : php56-php-pecl-zip-1.15.2-1.el7.remi.x86_64                 5/34
  Verifying  : audit-libs-2.8.1-3.el7.x86_64                               6/34
  Verifying  : environment-modules-3.2.10-10.el7.x86_64                    7/34
  Verifying  : php56-php-pgsql-5.6.36-1.el7.remi.x86_64                    8/34
  Verifying  : libzip5-1.5.1-1.el7.remi.x86_64                             9/34
  Verifying  : policycoreutils-2.5-22.el7.x86_64                          10/34
  Verifying  : libsemanage-2.5-11.el7.x86_64                              11/34
  Verifying  : libselinux-devel-2.5-12.el7.x86_64                         12/34
  Verifying  : policycoreutils-python-2.5-22.el7.x86_64                   13/34
  Verifying  : python-IPy-0.75-6.el7.noarch                               14/34
  Verifying  : setools-libs-3.3.8-2.el7.x86_64                            15/34
  Verifying  : php56-php-pdo-5.6.36-1.el7.remi.x86_64                     16/34
  Verifying  : libcgroup-0.41-15.el7.x86_64                               17/34
  Verifying  : php56-php-common-5.6.36-1.el7.remi.x86_64                  18/34
  Verifying  : php56-php-pecl-jsonc-1.3.10-1.el7.remi.x86_64              19/34
  Verifying  : libsepol-devel-2.5-8.1.el7.x86_64                          20/34
  Verifying  : audit-libs-python-2.8.1-3.el7.x86_64                       21/34
  Verifying  : libsepol-2.5-8.1.el7.x86_64                                22/34
  Verifying  : libselinux-2.5-12.el7.x86_64                               23/34
  Verifying  : libselinux-utils-2.5-12.el7.x86_64                         24/34
  Verifying  : checkpolicy-2.5-6.el7.x86_64                               25/34
  Verifying  : libzip5-1.2.0-1.el7.remi.x86_64                            26/34
  Verifying  : libsepol-2.5-6.el7.x86_64                                  27/34
  Verifying  : libsepol-devel-2.5-6.el7.x86_64                            28/34
  Verifying  : libselinux-devel-2.5-6.el7.x86_64                          29/34
  Verifying  : libselinux-utils-2.5-6.el7.x86_64                          30/34
  Verifying  : libsemanage-2.5-5.1.el7_3.x86_64                           31/34
  Verifying  : policycoreutils-2.5-11.el7_3.x86_64                        32/34
  Verifying  : libselinux-2.5-6.el7.x86_64                                33/34
  Verifying  : audit-libs-2.6.5-3.el7_3.1.x86_64                          34/34

Installed:
  php56-php-pgsql.x86_64 0:5.6.36-1.el7.remi

Or you can use this repo: http://rpms.famillecollet.com/enterprise/7/test/x86_64//php56-php-pgsql-5.6.30-2.el7.remi.x86_64.rpm

Then you will see 4 files

/opt/remi/php56/root/etc/php.d/20-pgsql.ini
/opt/remi/php56/root/etc/php.d/30-pdo_pgsql.ini
/opt/remi/php56/root/usr/lib64/php/modules/pdo_pgsql.so
/opt/remi/php56/root/usr/lib64/php/modules/pgsql.so

Step 4: Create symlinks

ln -sf /opt/remi/php56/root/usr/lib64/php/modules/pgsql.so /usr/lib64/php/modules/pgsql.so
ln -sf /opt/remi/php56/root/etc/php.d/20-pgsql.ini /etc/php.d/20-pgsql.ini

If you want to use PDO with PostgreSQL you create more symlinks:

ln -sf /opt/remi/php56/root/usr/lib64/php/modules/pdo_pgsql.so /usr/lib64/php/modules/pdo_pgsql.so
ln -sf /opt/remi/php56/root/etc/php.d/30-pdo_pgsql.ini /etc/php.d/30-pdo_pgsql.ini

Now restart your php-fpm service.

Recent search terms:

  • php 7 4 centos 7 php-pqsql

1 Comment

Leave a Reply