Get the most out of your Centmin Mod LEMP stack
Become a Member

PHP-FPM Add pdo-pgsql PHP extension

Discussion in 'Centmin Mod Insights' started by jbElnas, Sep 19, 2015.

Tags:
  1. jbElnas

    jbElnas New Member

    4
    1
    3
    Sep 18, 2015
    Ratings:
    +1
    Local Time:
    5:48 PM
    1.9.4
    10.0.21
    Can i possible include pdo-pgsql in the configuration prior to centmin mod installation?
     
  2. eva2000

    eva2000 Administrator Staff Member

    30,178
    6,786
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +10,139
    Local Time:
    7:48 PM
    Nginx 1.13.x
    MariaDB 5.5
    The Centmin Mod Insights forum Centmin Mod Insights delves deeper into customising or extending your Centmin Mod installations yourself.

    Examples of adding additional PHP extensions include:

    I assume you know how to use PostgreSQL, admin and configure the databases etc so that is left up to you.

    For PHP: PostgreSQL (PDO) - Manual it seems it's as simple as adding to php configure line(s) (there's 2 instances) listed in inc/php_configure.inc, the following - you'll have to do this edit each time you upgrade Centmin Mod
    Code:
    --with-pdo-pgsql=/usr/pgsql-9.4
    after editing in inc/php_configure.inc and adding 4 instances of --with-pdo-pgsql=/usr/pgsql-9.4
    Code:
    if [[ "$MDB_INSTALL" == [yY] || "$MYSQL_INSTALL" == [yY] ]]; then
    
            echo "../configure --enable-fpm${OPCACHEOPT}${PHPINTLOPT}${PCNTLOPT}${MCRYPT}${RECODEOPT}${SNMPOPT} --with-mhash --with-zlib --with-gettext --enable-exif --enable-zip --with-bz2 --enable-soap --enable-sockets --enable-sysvmsg --enable-sysvsem --enable-sysvshm --enable-shmop --with-pear --enable-mbstring --with-openssl --with-mysql=mysqlnd --with-libdir=${LIBDIR} --with-mysqli=mysqlnd --with-mysql-sock=/var/lib/mysql/mysql.sock --with-curl --with-gd --with-xmlrpc --enable-bcmath --enable-calendar --enable-ftp --enable-gd-native-ttf --with-freetype-dir=${PLIBDIR} --with-jpeg-dir=${PLIBDIR} --with-png-dir=${PLIBDIR} --with-xpm-dir=${PLIBDIR}${LIBVPXOPT}${TLIBOPT} --enable-pdo --with-pdo-sqlite --with-pdo-mysql=mysqlnd --with-pdo-pgsql=/usr/pgsql-9.4 --enable-inline-optimization --with-imap --with-imap-ssl --with-kerberos --with-readline --with-libedit --with-gmp --with-pspell --with-tidy --with-enchant --with-fpm-user=nginx --with-fpm-group=nginx${FILEINFOOPT}${LDAPOPT} --with-config-file-scan-dir=${CONFIGSCANDIR}${PHPDEBUGOPT}"
    
    ../configure --enable-fpm${OPCACHEOPT}${PHPINTLOPT}${PCNTLOPT}${MCRYPT}${RECODEOPT}${SNMPOPT} --with-mhash --with-zlib --with-gettext --enable-exif --enable-zip --with-bz2 --enable-soap --enable-sockets --enable-sysvmsg --enable-sysvsem --enable-sysvshm --enable-shmop --with-pear --enable-mbstring --with-openssl --with-mysql=mysqlnd --with-libdir=${LIBDIR} --with-mysqli=mysqlnd --with-mysql-sock=/var/lib/mysql/mysql.sock --with-curl --with-gd --with-xmlrpc --enable-bcmath --enable-calendar --enable-ftp --enable-gd-native-ttf --with-freetype-dir=${PLIBDIR} --with-jpeg-dir=${PLIBDIR} --with-png-dir=${PLIBDIR} --with-xpm-dir=${PLIBDIR}${LIBVPXOPT}${TLIBOPT} --enable-pdo --with-pdo-sqlite --with-pdo-mysql=mysqlnd --with-pdo-pgsql=/usr/pgsql-9.4 --enable-inline-optimization --with-imap --with-imap-ssl --with-kerberos --with-readline --with-libedit --with-gmp --with-pspell --with-tidy --with-enchant --with-fpm-user=nginx --with-fpm-group=nginx${FILEINFOOPT}${LDAPOPT} --with-config-file-scan-dir=${CONFIGSCANDIR}${PHPDEBUGOPT}
    
    else
    
            echo "../configure --enable-fpm${OPCACHEOPT}${PHPINTLOPT}${PCNTLOPT}${MCRYPT}${RECODEOPT}${SNMPOPT} --with-mhash --with-zlib --with-gettext --enable-exif --enable-zip --with-bz2 --enable-soap --enable-sockets --enable-sysvmsg --enable-sysvsem --enable-sysvshm --enable-shmop --with-pear --enable-mbstring --with-openssl --with-mysql=mysqlnd --with-libdir=${LIBDIR} --with-mysqli=mysqlnd --with-mysql-sock=/var/lib/mysql/mysql.sock --with-curl --with-gd --with-xmlrpc --enable-bcmath --enable-calendar --enable-ftp --enable-gd-native-ttf --with-freetype-dir=${PLIBDIR} --with-jpeg-dir=${PLIBDIR} --with-png-dir=${PLIBDIR} --with-xpm-dir=${PLIBDIR}${LIBVPXOPT}${TLIBOPT} --enable-pdo --with-pdo-sqlite --with-pdo-mysql=mysqlnd --with-pdo-pgsql=/usr/pgsql-9.4 --enable-inline-optimization --with-imap --with-imap-ssl --with-kerberos --with-readline --with-libedit --with-gmp --with-pspell --with-tidy --with-enchant --with-fpm-user=nginx --with-fpm-group=nginx${FILEINFOOPT}${LDAPOPT} --with-config-file-scan-dir=${CONFIGSCANDIR}${PHPDEBUGOPT}"
    
    ../configure --enable-fpm${OPCACHEOPT}${PHPINTLOPT}${PCNTLOPT}${MCRYPT}${RECODEOPT}${SNMPOPT} --with-mhash --with-zlib --with-gettext --enable-exif --enable-zip --with-bz2 --enable-soap --enable-sockets --enable-sysvmsg --enable-sysvsem --enable-sysvshm --enable-shmop --with-pear --enable-mbstring --with-openssl --with-mysql=mysqlnd --with-libdir=${LIBDIR} --with-mysqli=mysqlnd --with-mysql-sock=/var/lib/mysql/mysql.sock --with-curl --with-gd --with-xmlrpc --enable-bcmath --enable-calendar --enable-ftp --enable-gd-native-ttf --with-freetype-dir=${PLIBDIR} --with-jpeg-dir=${PLIBDIR} --with-png-dir=${PLIBDIR} --with-xpm-dir=${PLIBDIR}${LIBVPXOPT}${TLIBOPT} --enable-pdo --with-pdo-sqlite --with-pdo-mysql=mysqlnd --with-pdo-pgsql=/usr/pgsql-9.4 --enable-inline-optimization --with-imap --with-imap-ssl --with-kerberos --with-readline --with-libedit --with-gmp --with-pspell --with-tidy --with-enchant --with-fpm-user=nginx --with-fpm-group=nginx${FILEINFOOPT}${LDAPOPT} --with-config-file-scan-dir=${CONFIGSCANDIR}${PHPDEBUGOPT}
    
    fi
    
    however, before you can run centmin.sh menu option 5 to recompile PHP with the new configure option --with-pdo-psql added, you need to install postgresql-devel yum package. CentOS default version is older 8.4 version
    Code:
    yum list postgresql-devel postgresql -q               
    Available Packages
    postgresql.x86_64              8.4.20-3.el6_6  updates
    postgresql-devel.x86_64   8.4.20-3.el6_6  updates
    postgresql 9.4 is latest so need to add a 3rd party Yum repo from http://yum.postgresql.org/. For 9.4 it's located at http://yum.postgresql.org/repopackages.php#pg94

    for CentOS 6.x 64bit
    Code:
    cd /svr-setup
    wget http://yum.postgresql.org/9.4/redhat/rhel-6-x86_64/pgdg-centos94-9.4-1.noarch.rpm
    rpm -ivh pgdg-centos94-9.4-1.noarch.rpm
    for CentOS 6.x 32bit
    Code:
    cd /svr-setup
    wget http://yum.postgresql.org/9.4/redhat/rhel-6-i386/pgdg-centos94-9.4-1.noarch.rpm
    rpm -ivh pgdg-centos94-9.4-1.noarch.rpm
    for CentOS 7.x 64bit
    Code:
    cd /svr-setup
    wget http://yum.postgresql.org/9.4/redhat/rhel-7-x86_64/pgdg-centos94-9.4-1.noarch.rpm
    rpm -ivh pgdg-centos94-9.4-1.noarch.rpm
    once you install the correct PostgresSQL yum repo for your OS you will have a installed yum repo file at /etc/yum.repos.d/pgdg-94-centos.repo

    Code:
    [pgdg94]
    name=PostgreSQL 9.4 $releasever - $basearch
    baseurl=http://yum.postgresql.org/9.4/redhat/rhel-$releasever-$basearch
    enabled=1
    gpgcheck=1
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-PGDG-94
    
    [pgdg94-source]
    name=PostgreSQL 9.4 $releasever - $basearch - Source
    failovermethod=priority
    baseurl=http://yum.postgresql.org/srpms/9.4/redhat/rhel-$releasever-$basearch
    enabled=0
    gpgcheck=1
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-PGDG-94
    So need to install PostgreSQL 9.4 yum packages as per http://yum.postgresql.org/howtoyum.php and for Centmin Mod add --disableplugin=priorities to override the protection of default CentOS repo's PostgreSQL 8.4

    to list
    Code:
    yum grouplist "PostgreSQL Database Server 9.4 PGDG" --disableplugin=priorities                                 
    Loaded plugins: fastestmirror, security
    Setting up Group Process
    Loading mirror speeds from cached hostfile
    * base: mirror.keystealth.org
    * epel: mirror.sfo12.us.leaseweb.net
    * extras: repos.lax.quadranet.com
    * rpmforge: mirror.hmc.edu
    * updates: mirrors.cat.pdx.edu
    base/group_gz                                                                                                                                                                                                                      | 219 kB     00:00   
    epel/group_gz                                                                                                                                                                                                                      | 149 kB     00:00   
    pgdg94/group_gz                                                                                                                                                                                                                    |  331 B     00:00   
    Available Groups:
       PostgreSQL Database Server 9.4 PGDG
    Done
    Code:
    yum list postgresql94-devel --disableplugin=priorities 
    Loaded plugins: fastestmirror, security
    Loading mirror speeds from cached hostfile
    * base: mirror.keystealth.org
    * epel: mirror.sfo12.us.leaseweb.net
    * extras: repos.lax.quadranet.com
    * rpmforge: mirror.hmc.edu
    * updates: mirrors.cat.pdx.edu
    Available Packages
    postgresql94-devel.x86_64          9.4.4-1PGDG.rhel6
    
    to install
    Code:
    yum groupinstall "PostgreSQL Database Server 9.4 PGDG" --disableplugin=priorities               
    Loaded plugins: fastestmirror, security
    Setting up Group Process
    Loading mirror speeds from cached hostfile
    * base: mirror.keystealth.org
    * epel: mirror.sfo12.us.leaseweb.net
    * extras: repos.lax.quadranet.com
    * rpmforge: mirror.hmc.edu
    * updates: mirrors.cat.pdx.edu
    Resolving Dependencies
    --> Running transaction check
    ---> Package postgresql94.x86_64 0:9.4.4-1PGDG.rhel6 will be installed
    ---> Package postgresql94-contrib.x86_64 0:9.4.4-1PGDG.rhel6 will be installed
    --> Processing Dependency: libxslt.so.1(LIBXML2_1.0.22)(64bit) for package: postgresql94-contrib-9.4.4-1PGDG.rhel6.x86_64
    --> Processing Dependency: libxslt.so.1(LIBXML2_1.0.18)(64bit) for package: postgresql94-contrib-9.4.4-1PGDG.rhel6.x86_64
    --> Processing Dependency: libxslt.so.1(LIBXML2_1.0.11)(64bit) for package: postgresql94-contrib-9.4.4-1PGDG.rhel6.x86_64
    --> Processing Dependency: libxslt.so.1()(64bit) for package: postgresql94-contrib-9.4.4-1PGDG.rhel6.x86_64
    ---> Package postgresql94-libs.x86_64 0:9.4.4-1PGDG.rhel6 will be installed
    ---> Package postgresql94-server.x86_64 0:9.4.4-1PGDG.rhel6 will be installed
    --> Running transaction check
    ---> Package libxslt.x86_64 0:1.1.26-2.el6_3.1 will be installed
    --> Finished Dependency Resolution
    
    Dependencies Resolved
    
    ==========================================================================================================================================================================================================================================================
    Package                                                             Arch                                                  Version                                                            Repository                                             Size
    ==========================================================================================================================================================================================================================================================
    Installing:
    postgresql94                                                        x86_64                                                9.4.4-1PGDG.rhel6                                                  pgdg94                                                1.0 M
    postgresql94-contrib                                                x86_64                                                9.4.4-1PGDG.rhel6                                                  pgdg94                                                529 k
    postgresql94-libs                                                   x86_64                                                9.4.4-1PGDG.rhel6                                                  pgdg94                                                193 k
    postgresql94-server                                                 x86_64                                                9.4.4-1PGDG.rhel6                                                  pgdg94                                                4.3 M
    Installing for dependencies:
    libxslt                                                             x86_64                                                1.1.26-2.el6_3.1                                                   base                                                  452 k
    
    Transaction Summary
    ==========================================================================================================================================================================================================================================================
    Install       5 Package(s)
    
    Total download size: 6.5 M
    Installed size: 26 M
    Is this ok [y/N]: 
    confirm packages installed
    Code:
    yum list installed postgresql94* -q
    Installed Packages
    postgresql94.x86_64                                9.4.4-1PGDG.rhel6                  @pgdg94
    postgresql94-contrib.x86_64                  9.4.4-1PGDG.rhel6                  @pgdg94
    postgresql94-libs.x86_64                         9.4.4-1PGDG.rhel6                  @pgdg94
    postgresql94-server.x86_64                    9.4.4-1PGDG.rhel6                  @pgdg94
    and devel package install
    Code:
    yum -y install postgresql94-devel --disableplugin=priorities       
    Loaded plugins: fastestmirror, security
    Setting up Install Process
    Loading mirror speeds from cached hostfile
    * base: mirror.keystealth.org
    * epel: mirror.sfo12.us.leaseweb.net
    * extras: repos.lax.quadranet.com
    * rpmforge: mirror.hmc.edu
    * updates: mirrors.cat.pdx.edu
    Resolving Dependencies
    --> Running transaction check
    ---> Package postgresql94-devel.x86_64 0:9.4.4-1PGDG.rhel6 will be installed
    --> Finished Dependency Resolution
    
    Dependencies Resolved
    
    ==========================================================================================================================================================================================================================================================
    Package                                                            Arch                                                   Version                                                           Repository                                              Size
    ==========================================================================================================================================================================================================================================================
    Installing:
    postgresql94-devel                                                 x86_64                                                 9.4.4-1PGDG.rhel6                                                 pgdg94                                                 1.5 M
    
    Transaction Summary
    ==========================================================================================================================================================================================================================================================
    Install       1 Package(s)
    
    Total download size: 1.5 M
    Installed size: 7.0 M
    Downloading Packages:
    postgresql94-devel-9.4.4-1PGDG.rhel6.x86_64.rpm                                                                                                                                                                                    | 1.5 MB     00:00   
    Running rpm_check_debug
    Running Transaction Test
    Transaction Test Succeeded
    Running Transaction
      Installing : postgresql94-devel-9.4.4-1PGDG.rhel6.x86_64                                                                                                                                                                                            1/1
      Verifying  : postgresql94-devel-9.4.4-1PGDG.rhel6.x86_64                                                                                                                                                                                            1/1
    
    Installed:
      postgresql94-devel.x86_64 0:9.4.4-1PGDG.rhel6                                                                                                                                                                                                         
    
    Complete!
    
    then run centmin.sh menu option 5 to recompile PHP after editing inc/php_configure.inc

    Code:
     ./centmin.sh           
    
    --------------------------------------------------------
    Centmin Mod 1.2.3-eva2000.08 - http://centminmod.com
    --------------------------------------------------------
                       Centmin Mod Menu                 
    --------------------------------------------------------
    1).  Centmin Install
    2).  Add Nginx vhost domain
    3).  NSD setup domain name DNS
    4).  Nginx Upgrade / Downgrade
    5).  PHP Upgrade / Downgrade
    6).  XCache Re-install
    7).  APC Cache Re-install
    8).  XCache Install
    9).  APC Cache Install
    10). Memcached Server Re-install
    11). MariaDB 5.2/5.5 & 10.x Upgrade Sub-Menu
    12). Zend OpCache Install/Re-install
    13). Install ioping.sh vbtechsupport.com/1239/
    14). SELinux disable
    15). Install/Reinstall ImagicK PHP Extension
    16). Change SSHD Port Number
    17). Multi-thread compression: pigz,pbzip2,lbzip2...
    18). Suhosin PHP Extension install
    19). Install FFMPEG and FFMPEG PHP Extension
    20). NSD Re-install
    21). Update - Nginx + PHP-FPM + Siege
    22). Add Wordpress Nginx vhost + WP Super Cache
    23). Update Centmin Mod Code Base
    24). Exit
    --------------------------------------------------------
    Enter option [ 1 - 24 ] 5
    --------------------------------------------------------
    
    Code:
    Do you want to run YUM install checks ?  [y/n]
    
    This will increase your upgrade duration time wise.
    Check the change log centminmod.com/changelog.html
    to see if any Nginx or PHP related new additions
    which require checking YUM prequisites are met.
    If no new additions made, you can skip the
    YUM install check to speed up upgrade time.
    
    [y/n]: n
    
    Code:
    PHP Upgrade - Would you like to continue? [y/n] y
    ----------------------------------------------------------------
    Install which version of PHP? (version i.e. 5.4.45, 7.0.0, NGDEBUG)
    PHP 7.0.0 is experimental in alpha status and may have broken PHP extensions.
    NGDEBUG is PHP 7.0.0 minus incompatible PHP extensions
    ----------------------------------------------------------------
    Enter PHP Version number you want to upgrade/downgrade to: 
    Enter PHP version you want to use on recompile i.e. 5.4.45 or 5.5.29 or 5.6.13

    At end of recompile, exit centmin.sh menu via option 24

    check if pdo-pgsql php extension has been installed via these commands

    Code:
    php -m
    Code:
    php --ri pdo_pgsql
    example output

    Code:
    php -m
    [PHP Modules]
    bcmath
    bz2
    calendar
    Core
    ctype
    curl
    date
    dom
    enchant
    ereg
    exif
    filter
    ftp
    gd
    geoip
    gettext
    gmp
    hash
    iconv
    imap
    intl
    json
    libxml
    mbstring
    mcrypt
    mhash
    mongo
    mysql
    mysqli
    mysqlnd
    openssl
    pcntl
    pcre
    PDO
    pdo_mysql
    pdo_pgsql
    pdo_sqlite
    Phar
    posix
    pspell
    readline
    redis
    Reflection
    session
    shmop
    SimpleXML
    snmp
    soap
    sockets
    SPL
    sqlite3
    standard
    sysvmsg
    sysvsem
    sysvshm
    tidy
    tokenizer
    xml
    xmlreader
    xmlrpc
    xmlwriter
    Zend OPcache
    zip
    zlib
    
    [Zend Modules]
    Zend OPcache
    
    Code:
    php --ri pdo_pgsql   
    
    pdo_pgsql
    
    PDO Driver for PostgreSQL => enabled
    PostgreSQL(libpq) Version => 9.4.4
    Module version => 1.0.2
    Revision =>  $Id: 8e4cc97fb53f418d98b489c3e9d722e48446e676 $
    
    or you can wait as I might add default pdo-pgsql PHP extension support as optional settting in centmin.sh by end of today - seems like something useful to have :)
     
    Last edited: Sep 19, 2015
  3. eva2000

    eva2000 Administrator Staff Member

    30,178
    6,786
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +10,139
    Local Time:
    7:48 PM
    Nginx 1.13.x
    MariaDB 5.5
    @jbElnas i've added optional support for postgresql and pdo-pgsql php extension via a new centmin.sh variable in the dev Centmin Mod 123.09beta01 branch at Beta Branch - Centmin Mod .09 beta branch Testing | Page 3 | Centmin Mod Community

    You'd have to switch from 123.08stable to 123.09beta01 branches to see the new centmin.sh option - switching instructions are in 1st post at Beta Branch - Centmin Mod .09 beta branch Testing | Centmin Mod Community or same instructions as outlined at Upgrade Centmin Mod - CentminMod.com LEMP Nginx web stack for CentOS if you use centmin.sh menu option 1 and then 3 to switch to 123.09beta01 branches + then exit centmin.sh via menu option 24 and change back into newer updated /usr/local/src/centminmod directory to re-run centmin.sh menu option 5.

    Then create persistent config file at /etc/centminmod/custom_config.inc and add to it the line:
    Code:
    POSTGRESQL=y
    
    and then run centmin.sh menu option 5 to recompile PHP

    then you can check if it's installed via command
    Code:
    php --ri pdo_pgsql
    i.e.
    Code:
    php --ri pdo_pgsql
    
    pdo_pgsql
    
    PDO Driver for PostgreSQL => enabled
    PostgreSQL(libpq) Version => 9.4.4
    Module version => 1.0.2
    Revision =>  $Id: 8e4cc97fb53f418d98b489c3e9d722e48446e676 $ 
    upload_2015-9-19_18-34-17.png
     
  4. jbElnas

    jbElnas New Member

    4
    1
    3
    Sep 18, 2015
    Ratings:
    +1
    Local Time:
    5:48 PM
    1.9.4
    10.0.21
    Thank you so much @eva2000. I'm so excited to try both options. :)
     
  5. eva2000

    eva2000 Administrator Staff Member

    30,178
    6,786
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +10,139
    Local Time:
    7:48 PM
    Nginx 1.13.x
    MariaDB 5.5
    let me know how it goes :)

    i don't use postgresql myself so interested to see the perspective from a postgresql user :)
     
  6. RoldanLT

    RoldanLT Well-Known Member

    3,901
    949
    113
    May 25, 2014
    Phillipines
    Ratings:
    +1,298
    Local Time:
    5:48 PM
    1.11
    10.2
    I have POSTGRESQL=n set on /etc/centminmod/custom_config.inc.
    But still it's being installed:
    [​IMG]
     
  7. jbElnas

    jbElnas New Member

    4
    1
    3
    Sep 18, 2015
    Ratings:
    +1
    Local Time:
    5:48 PM
    1.9.4
    10.0.21
    by default the pdo for postgresql is not installed/enabled only pdo's for mysql and sqlite
     
    • Like Like x 1
  8. eva2000

    eva2000 Administrator Staff Member

    30,178
    6,786
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +10,139
    Local Time:
    7:48 PM
    Nginx 1.13.x
    MariaDB 5.5
    yup :)