FreeTDS and PHP with MSSQL Support Built In, Please?

Can we get this built into the distribution? This would really help set it apart from other distributions that don’t have this included.

And it would most likely make a lot of PHP developer lives a bit easier.


Since mysql with work with Access, you can use mysql rather than MSSQL; that is probably why no one has implemented what you are requesting.

Actually - the whole point would be to provide it during the install so PHP developers, such as myself, can utilize it without having to really modify the installation. It’s not a big package. I’d rather not have to recompile PHP onto the distro if I don’t have to.

See what I’m saying? I’m sure I’m not the ONLY person that is kinda forced to use MSSQL.

Yes, I use MySQL. But the important ERP data I’d like to get to sits on an MSSQL server, and the ERP application isn’t something I have control of. Having to recompile PHP just for that is a complete pain. I’d rather just have it installed out of the box.

I support you, also ask for the same in 11.3 milestone-5 just to hear that the “request for features” are closed. Took me days to get is working - lucky the community assisted. We are in a position where we have to work in both environments. RAD programs are a reality and we have to move past the OS to the Application level. I don’t want to “compile” and change from the defaults.

In the same token this applies also “Connecting to the Windows Network” by Active Directory or to Workgroup.

Well after days of searching for the answer…

Install Apache2 and PHP from SuSE using YaST. Be sure to include the *-devel packages.

Download the source code for the latest version of freeTDS from and install it. I was able to compile it with the following commands:

make install

Now edit the file /usr/local/etc/freetds.conf

Add a new section for your database(s) following the examples already in the file.

Execute the tsql command to verify that you can connect to the database from FreeTDS. Note that server-name must match the name you entered in freetds.conf.

tsql -S <server-name> -U <user-name> -P <password>
1> select count(*) from <tablename>;
2> go

123456 <- should be the number of records in <tablename>.
(1 row affected)
1> quit

NOTE: Replace <server-name>, <user-name>, <password> and <table-name> with the proper values for your database. Do not include < or >.

Create a script to run phpinfo() to verify the current version of PHP. Run the script to verify the version of PHP that you are running. On a stock OpenSuSE installation this will go into the /srv/www/htdocs directory.




Download the same version of PHP from the php web site.

For the latest version: PHP: Downloads

For earlier versions: PHP: Releases

Untar the downloaded php source file, and cd to the ext/mssql directory within the resulting directory tree.

Run the following commands to compile just the mssql module:


On my 64 bit SuSE system I had to move the resulting .so file to /usr/lib64/php5/extensions on a 32 bit system I suspect it would be /usr/lib/php5/extensions but I have not tried it.

Now move to the php5 configuration directory and allow PHP to include your new extension:

cd /etc/php5/conf.d directory.
cp mysql.ini mssql.ini

Now edit the mssql.ini file and change to

Restart Apache.

Create a php file to test your new installation:


mssql_connect( ‘<server-name>’, ‘<user-name>’, ‘<password>’ );

$Result = mssql_query( “select count(*) from <table-name>” );

print_r( mssql_fetch_array( $Result ));


NOTE: Replace <server-name>, <user-name>, <password> and <table-name> with the proper values for your database. Do not include < or >.

This query should work, and if it does you have access to Ms SQL databases on your OpenSuSE machine.

Thank you for this post rwidmer! It just works!

Welcome here, remember where you found this :slight_smile:

found your post here, did like you said - but it doesn’t work for me…
I’ve took clean just installed openSuSE 11.3 machine, setup FreeTDS 0.83 on it. Tests with tsql is ok. Successfully compiled extension. But when running test from php, it never connects to sql server, showing “Unable to connect to server <ipaddress:port>” in apache’s error log.
Any ideas where to check?

Thanks and best regards,