Msphpsql: Fedora

Created on 15 Nov 2018  路  4Comments  路  Source: microsoft/msphpsql

Hi,

I don't do this often but ... I've been waiting since Fedora 17 to use the new sqlsrv with php. And still cannot install it on on a fedora box. Here are the details of what I've read and tried.

+## PHP Driver version or file name

  • They are up to 7.2 that installs by default now on fedora 29

+## SQL Server version

  • Not important, but sure: um, the latest 2016 developer version and also a 2008, external on windows boxes. Currently used by php 5.4ish and sql studio manager.

+## Client operating system

  • Fedora 27,28,29 server - Fresh ISO's from getfedora.org

+## PHP version

  • 7.0, 7.1, 7.2

+## Microsoft ODBC Driver version

  • 13 or 17 or whatever the guides I try say, I've made so many vbox copies I really can't recall how many times I've done whatever.

+## Problem description

  • I just want it to work. Can nobody post a guide that actually works? I used to be able to type "yum install php-mssql" and I was done. Now I have 10 page guides with trouble shoot guides and issues if you're doing this and not that and depending on what version you want and yada yada, I don't care what version I just want it to work. Like any of them. Pick One!

+## Expected behavior and actual behavior

  • Expect a simple script with the commands that all work, in order, without error, and result in a successful install message. Then a simple php script to connect that doesn't give some random message I have to google. Expect to download fedora 28 or 29 server and run this script...and then I can run "php testsql.php" and it just works. Like a magic hat trick only from the guys pushing the software and not some random dude on stackoverflow.

+## Repro code or steps to reproduce
Copy default Fedora Server 29 install to another VM. Pick another random guide that I have to pick and guess my way through to get the commands to work on fedora. Get frustrated at the circular BS, wait another year to see if it anything actually works yet. Ponder if everyone is using ubuntu because that's the only system that works with this stuff nowadays. Is fedora dead? Is that the reason? Should I stop using fedora?

configuration

Most helpful comment

I've figured it out this morning. Probably my 8th try in the last 5 years.

Suppose I could post my answer here ..I'm not sure this is the right place for this. Just needed a shoulder to cry on for a bit, thought maybe you'd have an unofficial guide. PHP 5 is pretty old now and it's hard to upgrade when the php extension (that's been out for..quite some time) isn't officially supported for the distro we use and nobody can say how to install it in a simple short list without linking 5 web pages to go to (ms, github and 2 or so pages on each side with 10 page guides on each webpage) with guides and examples that don't work for fedora.

Suppose it was the mssqlodbc* that kept tripping me up along with all the yum usage and non-fedora commands mixed with random repo listings and repo errors when finally added. It just seemed like a mess and I kept waiting for someone to straighten it out and nobody has yet. At least I figured out how to do it on fc29.

Anyway, Your "fedora isn't supported officially" and what you said helped me try a littler harder and give up hope on the guides. So here's how to do it on fc29-server. If there's a place for this anywhere..otherwise I'm not sure I care enough to come back to this aside from keeping this somewhere.

Do a default fc29-server install - then do this

dnf install php php-devel php-pdo unixODBC-devel make php-pear
#chose rehl rpm because I think fc is very similar to rhel, but I have no idea why it worked.
wget https://packages.microsoft.com/rhel/7/prod/msodbcsql17-17.2.0.1-1.x86_64.rpm
dnf install msodbcsql17-17.2.0.1-1.x86_64.rpm
wget https://packages.microsoft.com/rhel/7/prod/mssql-tools-17.2.0.2-1.x86_64.rpm
dnf install mssql-tools-17.2.0.2-1.x86_64.rpm

pecl required make and sql.h from unixodbc-devel

pecl install sqlsrv
pecl install pdo_sqlsrv

And the default attempt in all the guides to concat to the bottom of /etc/php.ini doesn't work for some reason. Had to move to php.d ini directory with the rest of them.

echo "extension=pdo_sqlsrv.so" > /etc/php.d/20-sqlsrv.ini
echo "extension=sqlsrv.so" > /etc/php.d/20-pdo_sqlsrv.ini

for selinux

setsebool -P httpd_can_network_connect_db 1

And then your php samples will work. Anyway...back to work. Feel free to close/delete this whole thing or do whatever with this. I'm sure this solution probably works with fedora-server 25-29 and maybe more. Of course you guys just refer to microsofts website now for the guides so.. guess that's that. Cya.

All 4 comments

Also, to note, the internet is covered in people having issues about getting php and sqlsrv installed and talking to an ms sql server. And it's because between you and microsoft, I believe you guys just don't want anyone using each others software. So you're making it like this on purpose. Post a bunch of guides, pretend to look like it should work. But in the end, if you follow it through all the way, it doesn't work.

@Grglrglrg It would help if you describe exactly what you did and what the resulting error message was. If you're looking for a simple way to install the sqlsrv driver, you can try a packaged version of sqlsrv for Fedora available from the Remi repo but bear in mind that 1. We do not control that build, and 2. Fedora is not officially supported (but Red Hat Enterprise Linux and CentOS are supported).

I've figured it out this morning. Probably my 8th try in the last 5 years.

Suppose I could post my answer here ..I'm not sure this is the right place for this. Just needed a shoulder to cry on for a bit, thought maybe you'd have an unofficial guide. PHP 5 is pretty old now and it's hard to upgrade when the php extension (that's been out for..quite some time) isn't officially supported for the distro we use and nobody can say how to install it in a simple short list without linking 5 web pages to go to (ms, github and 2 or so pages on each side with 10 page guides on each webpage) with guides and examples that don't work for fedora.

Suppose it was the mssqlodbc* that kept tripping me up along with all the yum usage and non-fedora commands mixed with random repo listings and repo errors when finally added. It just seemed like a mess and I kept waiting for someone to straighten it out and nobody has yet. At least I figured out how to do it on fc29.

Anyway, Your "fedora isn't supported officially" and what you said helped me try a littler harder and give up hope on the guides. So here's how to do it on fc29-server. If there's a place for this anywhere..otherwise I'm not sure I care enough to come back to this aside from keeping this somewhere.

Do a default fc29-server install - then do this

dnf install php php-devel php-pdo unixODBC-devel make php-pear
#chose rehl rpm because I think fc is very similar to rhel, but I have no idea why it worked.
wget https://packages.microsoft.com/rhel/7/prod/msodbcsql17-17.2.0.1-1.x86_64.rpm
dnf install msodbcsql17-17.2.0.1-1.x86_64.rpm
wget https://packages.microsoft.com/rhel/7/prod/mssql-tools-17.2.0.2-1.x86_64.rpm
dnf install mssql-tools-17.2.0.2-1.x86_64.rpm

pecl required make and sql.h from unixodbc-devel

pecl install sqlsrv
pecl install pdo_sqlsrv

And the default attempt in all the guides to concat to the bottom of /etc/php.ini doesn't work for some reason. Had to move to php.d ini directory with the rest of them.

echo "extension=pdo_sqlsrv.so" > /etc/php.d/20-sqlsrv.ini
echo "extension=sqlsrv.so" > /etc/php.d/20-pdo_sqlsrv.ini

for selinux

setsebool -P httpd_can_network_connect_db 1

And then your php samples will work. Anyway...back to work. Feel free to close/delete this whole thing or do whatever with this. I'm sure this solution probably works with fedora-server 25-29 and maybe more. Of course you guys just refer to microsofts website now for the guides so.. guess that's that. Cya.

Thank you or sharing your experience. Glad you figured out how to make it work, others will surely benefit from what you did.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

lwohlhart picture lwohlhart  路  6Comments

dkrdj8989 picture dkrdj8989  路  3Comments

sirio3mil picture sirio3mil  路  6Comments

arunchandarQA picture arunchandarQA  路  3Comments

Jeeppler picture Jeeppler  路  4Comments