webserver: Debian8 with Apache, PHP, unixODBC, FreeTDS (current versions installed with apt-get last week)

dataserver: Windows Server 2008 with MS SQL Server 2008

Opening this in webbrowser: (variables are set and right)

    $connect = odbc_connect($db_server,$db_user,$db_password);

I get:

Warning: odbc_connect(): SQL error: [unixODBC][FreeTDS][SQL Server]Unable to connect to data source, SQL state S1000 in SQLConnect in /var/www/html/test/index.php on line 11 bool(false)

Running the same file/code in command line results in:

resource(4) of type (odbc link)

Since i've read this could have something to do with SElinux i tried typing sestatus in command line resulting in

bash: sestatus: Command not found.

tsql/isql is also working.

Where do i have to make adjustments to allow apache to connect to the MSSQL Server?


To allow apache to communicate with the MSSQL, you should do the following:

setsebool -P httpd_can_network_connect on
setsebool -P httpd_can_network_connect_db on

In a couple of seconds you will be connected.

  • bash: setsebool: Command not found. – user3665396 Oct 29 '15 at 15:48
  • Worked for me after running around for days. – Omari Victor Omosa Nov 19 '17 at 20:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.