Reputation: 1243
I have installed php-mssql package in Centos 6 for MSSql connection. I want to connect remote MSSql server from PHP 5.3.3.
My code:
$link = mssql_connect("192.168.*.*", 'username', 'password') or die ("Could not connect to database: ".mssql_get_last_message());
if (!$link) {
die('Something went wrong while connecting to MSSQL');
}
But I am getting below error,
Warning: mssql_connect(): Unable to connect to server: 192.168.*.* in /var/www/html/test.php on line 22
If I use through freetds
, it is working.
tsql -S192.168.*.* -Uusername -Ppassword
Please help me.
Upvotes: 3
Views: 901
Reputation: 12085
try this and set network connect is 1 i.e on
setsebool -P httpd_can_network_connect 1
setsebool -P httpd_can_network_connect_db 1
Upvotes: 4
Reputation: 66
It seems like you are being blocked by SELinux. If I'm right, executing these commands should solve your problem:
$ sudo -i
Password:
# setsebool -P httpd_can_network_connect 1
# setsebool -P httpd_can_network_connect_db 1
Upvotes: 2