Quantcast
Channel: Active questions tagged ubuntu - Stack Overflow
Viewing all articles
Browse latest Browse all 5956

Unable to connect to SQL Server using ODBC through PHP

$
0
0

I am trying to replicate a cloud web-server to on-prem. The cloud version works fine, but having followed the same steps to create the server I'm running into an issue with it's ability to connect to a remote database.

I have an Apache web-server running on Ubuntu with PHP & ODBC Installed.

The database server's firewall is configured to allow connections over 1433 from the web-server's IP address. The credentials are correct.

I am receiving the following error:

Warning: odbc_connect(): SQL error: [Microsoft][ODBC Driver 17 for SQL Server]Client unable to establish connection, SQL state 08001 in SQLConnect in /var/www/cb-db-conn/index.phpon line17

Occasionally, a different error is received:

Warning: odbc_connect(): SQL error: [Microsoft][ODBC Driver 17 for SQL Server]SSL Provider: [OpenSSL library could not be loaded, make sure OpenSSL 1.0 or 1.1 is installed], SQL state 08001 in SQLConnect in var/www/cb-db-conn/index.phpon line17

Line 17 for reference:

$conn = odbc_connect("Driver={ODBC Driver 17 for SQL Server};Server=$serverName,1433;Database=$dbName;Uid={$connectionOptions['Uid']};PWD={$connectionOptions['PWD']}", '', '');

I have confirmed:

  • Both OpenSSL and ODBC are installed.
  • The credentials are correct.
  • Port 1433 on the database server is open to the web-server.
  • SQL Server is listening on port 1433.
  • Pinging the database from the web-server is successful
  • The cloud web server does not have any issue connecting

Viewing all articles
Browse latest Browse all 5956

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>