(1) Download the latest FreeTDS from the official website : http://www.freetds.org
(2) Using compiler is better. Even though there are some binary package that you can download, it is sometimes not working. Compiling the driver often work perfectly.
(2.1) Compile FreeTDS (take version 0.82 as an example)
Extract the package:
tar zxvf freetds-0.82.tar.gz
Go to the directory:
cd freetds-0.82
./configure --prefix=/usr/local/freetds --with-tdsver=8.0
make
make install
- with-tdsver = 8.0 refers to the tds 8.0 version ( if this parameter is not used, according to the default compiler, it compiles to 5.0 and 5.0 connection to the database is 4000 , not SQLServer default port 1433 . )
(2.2) Compile PHP Module
To support for MSSQL, adding compiler parameters -- with-mssql = /usr/local/freetds.
Enter the php source directory, MSSQL module's source directory:
cd /home/wxw/gd/php-5.4.17/ext/mssql/
Generate compile profiles
/usr/local/php/bin/phpize
./configure --with-php-config=/usr/local/php/bin/php-config --with-mssql=/usr/local/freetds/
make
make install
Add the mssql.so into php.ini, the path will be prompted after installation
vim /usr/local/php/lib/php.ini
extension = "/usr/local/php/lib/php/extensions/no-debug-non-zts-20060613/mssql.so"
Restart Apache server
/usr/local/apache2/bin/apachectl restart
/usr/local/apache2/bin/apachectl restart
During the compilation, if we encounter an error of not being able to find FreeTDS, like the following.
configure: error: Directory /usr/local/freetds is not a FreeTDS installation directory
You need to create two emtpy files.
touch /usr/local/freetds/include/tds.h
touch /usr/local/freetds/lib/libtds.a
touch /usr/local/freetds/include/tds.h
touch /usr/local/freetds/lib/libtds.a
phpize
./configure--with-php-config=/usr/bin/php-config--with-pdo-dblib=/usr/local/freetds/
make
sudo cpmodules/pdo_dblib.so/usr/lib/php/extensions/no-debug-non-zts-20100525/
We need to edit is php.ini so open php.ini in your text editor with root privileges.
Search for the line ; extension_dir = "./"
Replace the above line with extension_dir = "/usr/lib/php/extensions/no-debug-non-zts-20100525/"
Adding the extensions.
extension=pdo_dblib.so
./configure--with-php-config=/usr/bin/php-config--with-pdo-dblib=/usr/local/freetds/
make
sudo cpmodules/pdo_dblib.so/usr/lib/php/extensions/no-debug-non-zts-20100525/
We need to edit is php.ini so open php.ini in your text editor with root privileges.
Search for the line ; extension_dir = "./"
Replace the above line with extension_dir = "/usr/lib/php/extensions/no-debug-non-zts-20100525/"
Adding the extensions.
extension=pdo_dblib.so
Save the file and exit
No comments:
Post a Comment