Forums

Resolved
0 votes
Anyone know how to get the sqlsrv extension installed for php?

what yum packages do I need so I can enable it in the php.ini located at:

/etc/opt/rh/rh-php73/php.ini

extension=sqlsrv

Also its sort of confusing

The system has php 5.4 installed

And the webites uses the php package deal so you can select different versions for each website, cool but how in the world do you install extensions to those?

I found this

https://github.com/Microsoft/msphpsql/releases

sudo pecl install sqlsrv-5.9.0preview1
sudo pecl install pdo_sqlsrv-5.9.0preview1

But it errors out and says php 5.4 installed and you need 7.x or greater

Should I uninstall the PHP package thing and upgrade the php on the system to 7.x?

Will that break things?
Friday, October 09 2020, 12:56 AM
Share this post:
Responses (8)
  • Accepted Answer

    Wednesday, October 14 2020, 03:34 PM - #Permalink
    Resolved
    0 votes
    Nick Howitt wrote:

    I'm afraid I am not qualified to comment.


    Same here it was a discovery process of going down the rabbit hole.

    I will play around with the VM clone some more and see if it affects anything

    All my existing php scripts seem to run and the webconfig seems to be okay
    The reply is currently minimized Show
  • Accepted Answer

    Wednesday, October 14 2020, 09:10 AM - #Permalink
    Resolved
    0 votes
    I'm afraid I am not qualified to comment.
    The reply is currently minimized Show
  • Accepted Answer

    Wednesday, October 14 2020, 02:27 AM - #Permalink
    Resolved
    0 votes
    Nick Howitt wrote:

    I'd recommend you don't try to remove 5.4 and replace it with 7.x. I've no idea how safe it would be.

    Here are instructions for PHP7.2 software collection but 7.3 should be pretty much the same. It may just be a case of running:
    scl enable rh-php73 bash
    pecl install sqlsrv-5.9.0preview1
    But I don't know. It is your system and if it breaks, it is your system to fix. I'd try it first in a VM.


    Here is what I have done in a cloned vm

    scl enable rh-php73 bash

    yum install rh-php73-php-devel

    yum install gcc-c++
    yum install unixODBC-devel

    pecl install sqlsrv
    /etc/opt/rh/rh-php73/php.ini

    extension=sqlsrv

    cd /opt/rh/rh-php73/root/usr/lib64/php/modules

    chmod +x sqlsrv.so

    But I get this

    Tuesday 13th of October 2020 09:19:58 PM: Failed to connect MySQL: Array ( [0] => Array ( [0] => IMSSP [SQLSTATE] => IMSSP [1] => -49 [code] => -49 [2] => This extension requires the Microsoft ODBC Driver for SQL Server. Access the following URL to download the ODBC Driver for SQL Server for x64: https://go.microsoft.com/fwlink/?LinkId=163712 [message] => This extension requires the Microsoft ODBC Driver for SQL Server. Access the following URL to download the ODBC Driver for SQL Server for x64: https://go.microsoft.com/fwlink/?LinkId=163712 ) )
    Warning: sqlsrv_close() expects parameter 1 to be resource, bool given in /var/www/html/work/location.php on line 64

    Okay I got it to work by doing this

    curl https://packages.microsoft.com/config/rhel/7/prod.repo > /etc/yum.repos.d/mssql-release.repo
    sudo ACCEPT_EULA=Y yum install msodbcsql17

    This was helpful

    https://docs.microsoft.com/en-us/sql/connect/odbc/linux-mac/installing-the-microsoft-odbc-driver-for-sql-server?view=sql-server-ver15

    Please look over what I did and see if all that was necessary...

    I have not found anything broke yet
    The reply is currently minimized Show
  • Accepted Answer

    Friday, October 09 2020, 02:01 PM - #Permalink
    Resolved
    0 votes
    Did not know m$ was removed from market place
    The reply is currently minimized Show
  • Accepted Answer

    Friday, October 09 2020, 02:00 PM - #Permalink
    Resolved
    0 votes
    https://wiki.centos-webpanel.com/mssql-extension-for-php7

    I found this

    However what is this the >>>> line is what I am talking about

    ACCEPT_EULA=Y yum install msodbcsql17 unixODBC unixODBC-devel

    >>>>>>># After the above installation go to php switcher/selector/php-fpm selector and build the php 7.xx with sqlsrv, you can enable sqlsrv from PHP "Options"
    The reply is currently minimized Show
  • Accepted Answer

    Friday, October 09 2020, 12:59 PM - #Permalink
    Resolved
    0 votes
    I thought the M$ SQL server was broken and withdrawn from the marketplace years ago.

    Feel free to write a howto and I will put into the right format.
    The reply is currently minimized Show
  • Accepted Answer

    Friday, October 09 2020, 12:31 PM - #Permalink
    Resolved
    0 votes
    Since Clearos in the market place has MS SQL server it would be nice if we had the MS SQL stuff enabled in PHP like mysql or a how to.
    The reply is currently minimized Show
  • Accepted Answer

    Friday, October 09 2020, 09:14 AM - #Permalink
    Resolved
    0 votes
    I'd recommend you don't try to remove 5.4 and replace it with 7.x. I've no idea how safe it would be.

    Here are instructions for PHP7.2 software collection but 7.3 should be pretty much the same. It may just be a case of running:
    scl enable rh-php73 bash
    pecl install sqlsrv-5.9.0preview1
    But I don't know. It is your system and if it breaks, it is your system to fix. I'd try it first in a VM.
    The reply is currently minimized Show
Your Reply