I'm new to Linux. I have provisioned a new Ubuntu 16.04 server, added LAMP via Tasksel, and added PhpMyAdmin. I added my web app to the html folder, and ran my MySQL scripts. This part works fine. I have a PHP page that queries a remote SQL Server. This is where my issue is:
I installed the SQL Server ODBC Driver per instructions:
https://msdn.microsoft.com/en-us/library/hh568454(v=sql.110).aspx
udo su
sh -c 'echo "deb [arch=amd64]
https://apt-mo.trafficmanager.net/repos/mssql-ubuntu-xenial-release/xenial main" > /etc/apt/sources.list.d/mssqlpreview.list'
sudo apt-key adv --keyserver apt-mo.trafficmanager.net --recv-keys 417A0893
apt-get update
apt-get install msodbcsql unixodbc-dev-utf16
SQL Server ODBC is not listed in PhpInfo().
When I hit the page with the remote SQL Server query, I find an error in my Apache2 error log:
[Tue Nov 01 04:42:52.651772 2016] [:error] [pid 1306] [client ::1:33146]
PHP Fatal error: Uncaught Error: Call to undefined function odbc_connect() in /var/www/html/xxxxxxx.php:67\n
Stack trace:\n#0 {main}\n thrown in /var/www/html/xxxxxxx.php on line 67
What am I missing?
Best Answer
I had the same issue with the repo linked in MSDN.
You would need to install the php-odbc package which needs a library that conflicts with the one from the microsoft repo.
I installed the driver manually with the following commands:
You can enter your connections now in /etc/odbc.ini and replace IP and password. e.g.:
and access with PDO: