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?
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?
Share this post:
Responses (8)
-
Accepted Answer
-
Accepted Answer
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:
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.scl enable rh-php73 bash
pecl install sqlsrv-5.9.0preview1
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 -
Accepted Answer
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" -
Accepted Answer
-
Accepted Answer
-
Accepted Answer
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:
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.scl enable rh-php73 bash
pecl install sqlsrv-5.9.0preview1
Please login to post a reply
You will need to be logged in to be able to post a reply. Login using the form on the right or register an account if you are new here.
Register Here »