HOWTO: FreeTDS for Newbies (almost complete)
From: Google Mike (googlemike_at_hotpop.com)
Date: 11/21/03
- Next message: jpm: "Phpnuke y php 4.3.4"
- Previous message: Pham Nuwen: "Re: postgres vs Mysql"
- Next in thread: Jochen Daum: "Re: HOWTO: FreeTDS for Newbies (almost complete)"
- Reply: Jochen Daum: "Re: HOWTO: FreeTDS for Newbies (almost complete)"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 21 Nov 2003 11:34:19 -0800
You may want to connect Linux/PHP to a remote MS SQL Server
eventually. One way to do that is to install FreeTDS, recompile PHP,
and then use the mssql_* API within PHP. That API is well documented
on php.net.
Note that my instructions here cover PHP 4.2.2 that ships with RH9. If
you have an earlier or later version, this might not synchronize 100%.
Also note on my RH9 system that I installed EVERYTHING in the
Add/Remove Programs because that's my preference.
So what is FreeTDS? Well, TDS (Tads, you might say) is the native MS
SQL Server protocol served up on port 1433. FreeTDS is a free API for
*nix to connect you to that.
You can go to freetds.org and install the RPMs on Unix or Linux
(*nix). This will create an executable called tsql, which you can use
to verify whether this was installed properly or not.
Let's start using that testing tool:
tsql -S ip.ip.ip.ip -H windows01 -p 1433 -U sa -P ''
This connects to ip address "ip.ip.ip.ip", server named "windows01",
port 1433
(the default port for mssql), user "sa", and no password (specified
with two
tick marks). If I had a password, I'd replace the two tick marks with
the
password.
If you're firewall and net configuration is set up correctly, and
FreeTDS is installed properly, you'll see something like:
1>
What the heck is that? That's similar to an old Oracle command line
interface I once saw. It gives you numbers for every line you type up
until you type GO. Then it starts over again. So, type this:
use pubs
go
select * from authors
go
quit
You'll see a table of authors from the MS SQL Server's pubs database.
That proves that your Linux system has FreeTDS configured correctly.
Now you just need to get PHP to talk to it. The php.net website says
(paraphrased):
You enable the MSSQL extension by adding...
extension=mssql.so
...to php.ini. (You may have to use Search in GNOME or KDE to find
php.ini on your system.) (The website says it as php_mssql.dll, but
that's incorrect on *nix! I've also not confirmed this filename
exactly, but I assume I am correct from other documentation on the
php.net site.)
Next you must recompile PHP with...
--with-mssql=<dir>
...where <dir> is the place where the FreeTDS *.so libraries are. On
RH9, that's /usr/lib.
Once you have this recompiled, you can use the mssql_* API that's
documented on php.net.
Enjoy!
THE END
{
I'm stuck. When I try to compile PHP, I tried to download some tar
file (that php.net redirected me for retrieval) called
php-4.2.2.tar.gz and then followed the instructions from "aissam at
yahoo dot com" at this URL:
http://www.php.net/manual/en/function.mssql-connect.php
However, what happens for me is that it runs configure (had to chmod
a+rwx it first, strangely) but then that never generates a make file
so that I can type "make", then "make install".
What's the trick? Where did I go wrong?
}
- Next message: jpm: "Phpnuke y php 4.3.4"
- Previous message: Pham Nuwen: "Re: postgres vs Mysql"
- Next in thread: Jochen Daum: "Re: HOWTO: FreeTDS for Newbies (almost complete)"
- Reply: Jochen Daum: "Re: HOWTO: FreeTDS for Newbies (almost complete)"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|