2

Ms SQL 拡張機能 2005 を Linux Web サーバーにインストールする方法を知っている人はいますか? 現在、Web サーバーには FreeTDS ライブラリ バージョンがありますが、それが何を意味するのかわかりません。しかし、接続しようとすると、「mssql_connect() が存在しません」とは表示されませんが、「サーバーに接続できません: xx.xx.xx.xx」と表示されます

ntwdblib.dll を使用する Windows でこの問題が発生したため、これは拡張機能のバージョンが原因であると想定しています。しかし、Linuxでこれを修正する方法がわかりません。

関数を使用するだけです。データベースは Windows サーバー上にあるため、mssql_connect() を使用して接続したいと考えています。

4

2 に答える 2

0

FreeTDSライブラリを使用してLinuxで関数を使用することは可能ですmssql_*が、サポートをPHPバイナリにコンパイルする必要があります(--with-mssql

于 2012-10-22T13:11:33.473 に答える
0

unixODBC モジュールをインストールしましたか? sudo apt-get install unixodbc

PHP の ODBC サポートをインストールしましたか? sudo apt-get インストール php5-odbc

odbc.ini および odbcinst.ini ファイルで Microsoft Sequel Server への接続を定義しましたか?

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 サーバーはリモート クライアントからの接続を受け入れますか?

于 2012-10-22T13:24:58.880 に答える