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