Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/240.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php Linux上的SQL Server 2005扩展_Php_Sql_Sql Server_Linux_Webserver - Fatal编程技术网

Php Linux上的SQL Server 2005扩展

Php Linux上的SQL Server 2005扩展,php,sql,sql-server,linux,webserver,Php,Sql,Sql Server,Linux,Webserver,有人知道如何在Linux Web服务器上安装Ms SQL extension 2005吗? Web服务器目前有FreeTDS库版本,我不知道这意味着什么。但当我尝试连接时,它并没有说mssql_connect不存在,而是说无法连接到服务器:xx.xx.xx.xx 我假设这是因为扩展的版本,因为我在使用ntwdblib.dll的windows上发生了此问题。但我不知道如何在Linux上解决这个问题 我只需要使用这些函数。数据库位于windows服务器上,因此我希望使用mssql_connect连接

有人知道如何在Linux Web服务器上安装Ms SQL extension 2005吗? Web服务器目前有FreeTDS库版本,我不知道这意味着什么。但当我尝试连接时,它并没有说mssql_connect不存在,而是说无法连接到服务器:xx.xx.xx.xx

我假设这是因为扩展的版本,因为我在使用ntwdblib.dll的windows上发生了此问题。但我不知道如何在Linux上解决这个问题


我只需要使用这些函数。数据库位于windows服务器上,因此我希望使用mssql_connect连接到它。

可以使用FreeTDS库在Linux上使用mssql_*函数,但支持需要编译为PHP二进制文件-使用mssql

可以使用FreeTDS库在Linux上使用mssql_*函数,但是需要将支持编译成PHP二进制文件-使用mssql

是否安装了unixODBC模块?sudo apt get安装unixodbc

您是否安装了对PHP的ODBC支持?sudo apt get安装php5 odbc

您是否在odbc.ini和odbcinst.ini文件中定义了与Microsoft Sequel服务器的连接

odbc.ini

# Define a connection to the MSSQL server.
# The Description can be whatever we want it to be.
# The Driver value must match what we have defined in /etc/odbcinst.ini
# The Database name must be the name of the database this connection will connect to.
# The ServerName is the name we defined in /etc/freetds/freetds.conf
# The TDS_Version should match what we defined in /etc/freetds/freetds.conf
[msft_sql_server]
Description             = The Microsoft Sequel Server
Driver                  = freetds
Database                = XXXXXXXXXX
ServerName              = msft_sql_server
TDS_Version             = 8.0

odbcinst.ini

# Define where to find the driver for the Free TDS connections.
[freetds]
Description     = MS SQL database access with Free TDS
Driver          = /usr/lib/i386-linux-gnu/odbc/libtdsodbc.so
Setup           = /usr/lib/i386-linux-gnu/odbc/libtdsS.so
UsageCount      = 1
然后,您的PHP连接将如下所示:

$db_connection = new PDO("dblib:dbname=$database_server;host=$database_server", $db_username, $db_password);
您可以使用iSQL程序测试上述设置,以确保可以建立连接


如果从Linux服务器连接到MSFT服务器时仍然有问题,是否有防火墙?你确定你有有效的用户凭据吗?MSFT服务器是否接受来自远程客户端的连接?

您是否安装了unixODBC模块?sudo apt get安装unixodbc

您是否安装了对PHP的ODBC支持?sudo apt get安装php5 odbc

您是否在odbc.ini和odbcinst.ini文件中定义了与Microsoft Sequel服务器的连接

odbc.ini

# Define a connection to the MSSQL server.
# The Description can be whatever we want it to be.
# The Driver value must match what we have defined in /etc/odbcinst.ini
# The Database name must be the name of the database this connection will connect to.
# The ServerName is the name we defined in /etc/freetds/freetds.conf
# The TDS_Version should match what we defined in /etc/freetds/freetds.conf
[msft_sql_server]
Description             = The Microsoft Sequel Server
Driver                  = freetds
Database                = XXXXXXXXXX
ServerName              = msft_sql_server
TDS_Version             = 8.0

odbcinst.ini

# Define where to find the driver for the Free TDS connections.
[freetds]
Description     = MS SQL database access with Free TDS
Driver          = /usr/lib/i386-linux-gnu/odbc/libtdsodbc.so
Setup           = /usr/lib/i386-linux-gnu/odbc/libtdsS.so
UsageCount      = 1
然后,您的PHP连接将如下所示:

$db_connection = new PDO("dblib:dbname=$database_server;host=$database_server", $db_username, $db_password);
您可以使用iSQL程序测试上述设置,以确保可以建立连接


如果从Linux服务器连接到MSFT服务器时仍然有问题,是否有防火墙?你确定你有有效的用户凭据吗?MSFT服务器会接受来自远程客户端的连接吗?

这无助于回答您的问题,但为什么不在Windows计算机上开发呢?您的开发环境与生产环境的相似程度越高,您就越不会感到头痛。您是否在PHP中使用MS SQL支持进行编译?@Matt也许他们的生产环境是这样设置的:Web服务器:Linux,数据库服务器:SQL Server。因此,他的发展环境类似于生产环境-@迈克尔本:说得好!问题是,linux服务器是一家网络主机公司。但我碰巧认识他们,他们正试图让mssql扩展版本2005为我工作,但他们没有mssql的经验,我也从来没有使用过linux。。我检查了phpinfo和mssql的版本,我认为它不是正确的版本。我们不知道该怎么改变。正如我在windows上所说,它只是ntwbdlib.DLL。这无助于回答您的问题,但为什么不在windows机器上开发呢?您的开发环境与生产环境的相似程度越高,您就越不会感到头痛。您是否在PHP中使用MS SQL支持进行编译?@Matt也许他们的生产环境是这样设置的:Web服务器:Linux,数据库服务器:SQL Server。因此,他的发展环境类似于生产环境-@迈克尔本:说得好!问题是,linux服务器是一家网络主机公司。但我碰巧认识他们,他们正试图让mssql扩展版本2005为我工作,但他们没有mssql的经验,我也从来没有使用过linux。。我检查了phpinfo和mssql的版本,我认为它不是正确的版本。我们不知道该怎么改变。就像我在windows上说的,它只是ntwbdlib.dll