我有一个使用mssql
与freetds
相关联的代码。当我从命令行运行时它完美地工作。当我通过浏览器使用nginx
php-fmp
运行时失败。代码如下:
<?php
$host = "myhost";
$user = "username";
$pass = "password";
$db = "database";
$table = "user";
try {
$conn = mssql_connect($host, $user, $pass);
mssql_select_db( $db, $conn );
$query = "SELECT COUNT(*) FROM [".$db."].[dbo].[".$table."]";
$query_result = mssql_query( $query , $conn );
echo "The count of ".$table." is: ";
$result = mssql_result ($query_result,0,0);
var_export($result);
mssql_close($conn); // close connection
} catch (Exception $e) {
throw new Exception("The script exited with an exception ===========================".PHP_EOL." ERROR TYPE ------------> ".$e);
}
?>
答案 0 :(得分:0)
好的,就我而言,问题是SELinux
确保这两个变量为ON:
# getsebool -a | grep httpd_can_network_connect
httpd_can_network_connect --> on
httpd_can_network_connect_db --> on
并在未启用时启用它们:
setsebool -P httpd_can_network_connect 1
setsebool -P httpd_can_network_connect_db 1