Learn about Centmin Mod LEMP Stack today
Register Now

PHP-FPM Question about mssql or odbc or pdo drivers.

Discussion in 'Install & Upgrades or Pre-Install Questions' started by Indrit, Jul 1, 2016.

  1. Indrit

    Indrit New Member

    13
    4
    3
    Jun 30, 2016
    Ratings:
    +4
    Local Time:
    3:26 PM
    Hello
    I have installed the latest centmin mod and i have a question.
    The website that i have right now has php and mysql database. I have also a mssql driver (mssql_pconnect) that connects to a windows server with SQL Server. I retrieve from the SQL server products and their attributes.
    I checked that the mssql_pconnect functions is not installed and tried to install it through yum php-mssql. I didn't find the package. Anyway....
    I checked also the pdo drivers that are available and discovered that only mysql and sqlite are availabe.
    Is there a quick or easy way to install php-mssql extension or the pdo driver for sql databases?
    I find that the drivers for pdo to connect to sql server are the odbc or unixodbc or sqlsrv (only available for windows server).
    Thank your for your time.

     
  2. eva2000

    eva2000 Administrator Staff Member

    55,182
    12,251
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,829
    Local Time:
    10:26 PM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    Hi @Indrit, centmin mod source compiles php so yum php related packages won't work.

    I honestly haven't thought about folks wanting to connect to windows SQL servers ! I will need to look into this and add it into 123.09beta01 code. Thanks for the heads up.. some have something within next 24-48hrs for you to test out :)

    For centmin mod 123.09beta01 the current default php extensions loaded are
    Code (Text):
    php -m
    [PHP Modules]
    bcmath
    bz2
    calendar
    Core
    ctype
    curl
    date
    dom
    enchant
    ereg
    exif
    filter
    ftp
    gd
    geoip
    gettext
    gmp
    hash
    iconv
    igbinary
    imagick
    imap
    intl
    json
    libxml
    mailparse
    mbstring
    mcrypt
    memcache
    memcached
    mhash
    mysql
    mysqli
    mysqlnd
    openssl
    pcntl
    pcre
    PDO
    pdo_mysql
    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
    xsl
    Zend OPcache
    zip
    zlib
    
    [Zend Modules]
    Zend OPcache

    Code (Text):
    php-config
    Usage: /usr/local/bin/php-config [OPTION]
    Options:
      --prefix            [/usr/local]
      --includes          [-I/usr/local/include/php -I/usr/local/include/php/main -I/usr/local/include/php/TSRM -I/usr/local/include/php/Zend -I/usr/local/include/php/ext -I/usr/local/include/php/ext/date/lib]
      --ldflags           []
      --libs              [-lcrypt  -lc-client  -lz -lexslt -ltidy -lcrypt -ledit -lncurses -laspell -lpspell -lrt -lmcrypt -lltdl -lstdc++ -lcrypt -lpam -lgmp -lt1 -lX11 -lXpm -lpng -lz -ljpeg -lvpx -lenchant -lcurl -lbz2 -lz -lrt -lm -ldl -lnsl  -lrt -lxml2 -lz -lm -lgssapi_krb5 -lkrb5 -lk5crypto -lcom_err -lssl -lcrypto -lcurl -lxml2 -lz -lm -lssl -lcrypto -lfreetype -lgssapi_krb5 -lkrb5 -lk5crypto -lcom_err -lssl -lcrypto -licui18n -licuuc -licudata -lm -licuio -lxml2 -lz -lm -lnetsnmp -lxml2 -lz -lm -lcrypt -lxml2 -lz -lm -lxml2 -lz -lm -lxml2 -lz -lm -lxml2 -lz -lm -lxslt -lxml2 -lz -lm -lssl -lcrypto -lcrypt ]
      --extension-dir     [/usr/local/lib/php/extensions/no-debug-non-zts-20131226]
      --include-dir       [/usr/local/include/php]
      --man-dir           [/usr/local/php/man]
      --php-binary        [/usr/local/bin/php]
      --php-sapis         [ cli fpm cgi]
      --configure-options [--enable-fpm --enable-intl --enable-pcntl --with-mcrypt --with-snmp --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=lib64 --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=/usr --with-jpeg-dir=/usr --with-png-dir=/usr --with-xpm-dir=/usr --with-vpx-dir=/usr --with-t1lib=/usr --enable-pdo --with-pdo-sqlite --with-pdo-mysql=mysqlnd --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 --disable-fileinfo --with-config-file-scan-dir=/etc/centminmod/php.d --with-xsl CC=/usr/bin/gcc CFLAGS=-O3 -m64 -mtune=native CXX=/usr/bin/g++ CXXFLAGS=-O3 -m64 -mtune=native]
      --version           [5.6.22]
      --vernum            [50622]
     
  3. eva2000

    eva2000 Administrator Staff Member

    55,182
    12,251
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,829
    Local Time:
    10:26 PM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    Okay just added PDO_ODBC driver support to PHP in centmin mod 123.09beta01 branch. You'd need to update to 123.09beta01 latest code (see below for instructions) Beta Branch - Add MSSQL PHP driver support via PHPMSSQL variable 123.09beta01 | Centmin Mod Community

    If you're curious what was involved in added PHP PDO_ODBC driver support you can see the github commit for 123.09beta01 branch here Add MSSQL PHP driver support via PHPMSSQL variable 123.09beta01 · centminmod/centminmod@90a7878 · GitHub

    Upgrading Centmin Mod Code to Latest Version



    Getting Started Guide step 19 outlines also how to keep Centmin Mod code updated or how to switch version branches.

    Centmin Mod LEMP stack's script code is constantly updated for improvements, bug fixes and security fixes so keeping the Centmin Mod code up to date is important. With Centmin Mod 1.2.3-eva2000.08) (123.08stable) and higher releases, a newly added centmin.sh menu option 23 allows much easier code updates and version branch swicthing via Git backed environment you can setup. For full details read the following links:
    Upgrading Centmin Mod involves 2 parts.
    1. Upgrading the actual Centmin Mod code outlined at Upgrade Centmin Mod. This is heart of Centmin Mod where the code is the engine that runs centmin.sh shell based menu and all the automation you're accustomed to. You can easily update within a Centmin Mod version branch or switch version branches via centmin.sh menu option 23 outlined here.
    2. Upgrade software that Centmin Mod installed or manages. For this part following outline at How to upgrade Centmin Mod software installed on your server.
    So essentially, you can upgrade from .07 to .08 in place, but not everything is upgraded as some things like server initial environment setup isn't changed i.e. how swap, tmp setup and allocation are created etc. The main parts from part 2 above are what in place upgrades do i.e. Nginx and PHP-FPM compilation and config/settings parameters and MariaDB version from 5.5 to 10.0.x. If you want the full environment changed including tmp and swap setup to .08's configuration, then you would need a fresh OS install and fresh .08 initial install. You can think of it like upgrading Windows 7 to Windows 8. An in place upgrade will upgrade code but won't change your computer environment from when you installed Windows 7 i.e. disk configuration and partition sizes won't change from when you initially installed Windows 7. Only way to change that would be fresh Windows 8 install.
     
  4. Indrit

    Indrit New Member

    13
    4
    3
    Jun 30, 2016
    Ratings:
    +4
    Local Time:
    3:26 PM
    Thank you @eva2000 i just installed it. I will make some tests tomorrow because i have to change my code to pdo.
    I will inform you if that worked.
    Thank you again.
     
  5. Indrit

    Indrit New Member

    13
    4
    3
    Jun 30, 2016
    Ratings:
    +4
    Local Time:
    3:26 PM
    Hello @eva2000
    I just made some test with the odbc.
    I had some problems with the driver for the sql server because i had to install the FreeTDS and configure it to connect. I had a successfully connection bud i had some problems with my charset from the database.

    It is possible to enable the php-mssql extension from php?
     
  6. eva2000

    eva2000 Administrator Staff Member

    55,182
    12,251
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,829
    Local Time:
    10:26 PM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    Ah yes need to add freetds as well

    mssql i will see if I can add it optionally
     
  7. eva2000

    eva2000 Administrator Staff Member

    55,182
    12,251
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,829
    Local Time:
    10:26 PM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    hmmm mssql extension might be deprecated or removed in php 7 PHP 7 - MSSQL Removed? What's replacing? : PHP in favour of PDO method so might be best to stick with that ? I'm updating 123.09beta01 so PHPMSSQL='y' also installs freetds packages but you'd have to configure freetds yourself.
     
  8. Indrit

    Indrit New Member

    13
    4
    3
    Jun 30, 2016
    Ratings:
    +4
    Local Time:
    3:26 PM
    I have already installed FreeTDS and configured. I don't have any problem with the configuration.
    At the server that i have installed the old website has webmin and the php-mssql extension. There is no problem with the charset. I just wanted to test the php-mssql on the new server so i can see if there is or not the same problem as odbc.
    Maybe you can add the php-mssql extension if the php version is < 7.
     
  9. eva2000

    eva2000 Administrator Staff Member

    55,182
    12,251
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,829
    Local Time:
    10:26 PM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
  10. Indrit

    Indrit New Member

    13
    4
    3
    Jun 30, 2016
    Ratings:
    +4
    Local Time:
    3:26 PM
    When i run the query and get the results some of the results has the '?' character
    Example:
    There is a field with the text SMA and when i run the query the result is S??
    I tried everything and even created a stackoverflow question but no luck. php - Connect to MSSQL Server from linux with pdo (odbc driver) charset - Stack Overflow
    i also added the mssql.charset to the php.ini file and nothing happens.
    Right now i'm a little bit frustrated and maybe i'm not checking everything.
     
  11. eva2000

    eva2000 Administrator Staff Member

    55,182
    12,251
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,829
    Local Time:
    10:26 PM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    maybe Getting data with UTF-8 charset from MSSQL server using PHP FreeTDS extension - Stack Overflow
    from http://www.freetds.org/userguide/localization.htm

     
    Last edited: Jul 5, 2016
  12. eva2000

    eva2000 Administrator Staff Member

    55,182
    12,251
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,829
    Local Time:
    10:26 PM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    Added mssql + PDO_ODBC driver support in PHP 5.x only in 123.09beta01 latest code - you need to set 2 variables in persistent config as outlined at Beta Branch - add PHPMSSQL_ALWAYS variable for 123.09beta01+ | Centmin Mod Community and then recompile php via centmin.sh menu option 5

    One question should I auto configure and enable secure connections for mssql in setting ini file at
    /etc/centminmod/php.d/mssql.ini ?
    Code (Text):
    mssql.secure_connection = On
    
     
  13. eva2000

    eva2000 Administrator Staff Member

    55,182
    12,251
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,829
    Local Time:
    10:26 PM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    ah http://www.freetds.org/userguide/localization.htm
     
  14. Indrit

    Indrit New Member

    13
    4
    3
    Jun 30, 2016
    Ratings:
    +4
    Local Time:
    3:26 PM
    Thank you. I just tested the mssql_connect function with ini_set('mssql.charset', 'UTF-8'); and i got the correct result.
    thank you again :)
     
  15. eva2000

    eva2000 Administrator Staff Member

    55,182
    12,251
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,829
    Local Time:
    10:26 PM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
  16. eva2000

    eva2000 Administrator Staff Member

    55,182
    12,251
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,829
    Local Time:
    10:26 PM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    edit actually i might add that as default for mssql.ini settings instead in /etc/centminmod/php.d/mssql.ini
    Code (Text):
    extension=mssql.so
    mssql.charset=UTF-8

    Code (Text):
    php --ri mssql
    
    mssql
    
    MSSQL Support => enabled
    Active Persistent Links => 0
    Active Links => 0
    Library version => FreeTDS
    
    Directive => Local Value => Master Value
    mssql.allow_persistent => On => On
    mssql.max_persistent => Unlimited => Unlimited
    mssql.max_links => Unlimited => Unlimited
    mssql.min_error_severity => 10 => 10
    mssql.min_message_severity => 10 => 10
    mssql.compatability_mode => Off => Off
    mssql.compatibility_mode => Off => Off
    mssql.connect_timeout => 5 => 5
    mssql.timeout => 60 => 60
    mssql.textsize => Server default => Server default
    mssql.textlimit => Server default => Server default
    mssql.batchsize => 0 => 0
    mssql.datetimeconvert => On => On
    mssql.secure_connection => Off => Off
    mssql.max_procs => Unlimited => Unlimited
    mssql.charset => UTF-8 => UTF-8