Executing Microsoft SQL Server Stored Procedure from PHP on Linux - Installing FreeTDS
(Page 5 of 9 )
From the /public folder, issue:
cd FreeTDS-0.61.2
This will change our working directory to FreeTDS. According to the PHP documentation, if we want to use FreeTDS to connect to a MS SQL Server, we need to append --enable-msdblib to the configure command. For detailed information, you can issue the following command:
./configure --help
This is what I used for the installation of FreeTDS:
./configure --prefix=/usr/local/freetds --sysconfdir=/usr/local/ freetds --with-tdsver=7.0 --enable-msdblib --enable-threadsafe --enable-sybase-compat
Since there is less dependency on the operating system, it is easy to pass this step without any error. Next, we compile the module tree, issue the following:
make
And install FreeTDS by issuing:
make install
After these 2 steps, you will find a new folder /usr/local/freetds, which contains the new files we’ve just installed. Let’s test our installation, change directory to this folder, and issue:
cd /usr/local/freetds
Edit freetds.conf:
gedit freetds.conf
I have a windows box running MS SQL Server 2000 on it. The machine name is home2k with IP address 192.168.0.212. Append the following part to FreeTDS.conf, and save it:
[home2k]
host = 192.168.0.212
port =1433
tds version = 7.0
Change to the bin folder under /usr/local/freetds, and issue:
tsql –S ‘home2k’ –U ‘sa’ –P ‘’
If you see 1> coming out, that means the connection to MS SQL Server is established, you can test further via sending an SQL statement to the SQL Server like the following screen, then exit using the tsql command.
Next: Modify the PHP Source Code >>
More PHP Articles
More By Jack Zhang