LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 10-06-2007, 07:23 PM   #1
shafey
Member
 
Registered: Aug 2005
Posts: 47

Rep: Reputation: 15
how to enable mssql on linux


Dear all
I will explain here how to run mssql from linux
1-Install TDS
wget http://www.ibiblio.org/pub/Linux/ALP...tds-stable.tgz
tar freetds-stable.tgz
cd freetds-0.64
./configure --with-tdsver=4.2 --prefix=/usr/local/freetds
make
make install
2-make modification on freetds.conf
vi /usr/local/freetds/etc/freetds.conf
[server]
host = <server mssql >
port = 1433
tds version = 4.2
3-Install php or recompile php
./configure' '--with-apxs=/usr/local/apache/bin/apxs' '--prefix=/usr/local' '--with-xml' '--enable-bcmath' '--enable-calendar' '--enable-ftp' '--with-gd' '--with-jpeg-dir=/usr/local' '--with-png-dir=/usr' '--with-xpm-dir=/usr/X11R6' '--with-gettext' '--enable-mbstring' '--enable-mbstr-enc-trans' '--enable-mbregex' '--enable-magic-quotes' '--with-mysqli' '--with-mysql=/usr' '--enable-discard-path' '--with-pear' '--enable-safe-mode' '--enable-sockets' '--enable-track-vars' '--with-ttf' '--with-freetype-dir=/usr' '--enable-gd-native-ttf' '--with-zlib' '--with-mssql=/usr/local/freetds'
make
make install
4-Restart apache
5-To check mssql make this page

<?php

$db = @mssql_connect("server","username","password") or die("Unable to connect to server");
mssql_select_db("dbname");
echo "<br>"."Thanks";
?>
 
Old 08-27-2008, 04:56 PM   #2
Evancool
LQ Newbie
 
Registered: Aug 2008
Distribution: RHEL, SuSE
Posts: 7

Rep: Reputation: 0
Actually this will not work for me. At the ./configure line, I keyed in exactly as stated with the --with-mssql=/usr/local/freetds and it errors out that /usr/local/freetds is not a freetds installation directory.
 
Old 08-27-2008, 09:55 PM   #3
sin0nyx
LQ Newbie
 
Registered: Aug 2008
Distribution: Gentoo, Fedora, CentOS, Ubuntu
Posts: 15

Rep: Reputation: 0
The configure script is looking for tds.h header file. Its trying to find this file in

--with-mssql=/usr/local/freetds/

/usr/local/freetds/include/tds.h
or
/usr/local/freetds/include/freetds/tds.h

Locate the tds.h file on your system and then set --with-mssql accordingly.

PS: Its a lot easier to use the packing system with your distro to install this as a module then to compile it directly into PHP.
 
Old 08-28-2008, 11:49 PM   #4
Evancool
LQ Newbie
 
Registered: Aug 2008
Distribution: RHEL, SuSE
Posts: 7

Rep: Reputation: 0
Interesting, your right, but I cannot find tds.h anywhere. I did a ./configure, make, and make install of the latest stable version into /usr/local/freetds, is this not where the tds.h file is? How do I find it?

My goal is to create the mssql.so extension so I can add mssql support to PHP. I know once I copy the .so file to the extension directory or wherever it goes, then I add the extension=mssql.so to the php.ini file.

I really don't want to recompile PHP because I would lose all my other vital settings to it.

Our web server uses Redhat enterprise 4 but I don't know what the packing system is for it. Yeah I know I'm kinda dumb with this.
 
Old 08-29-2008, 03:04 PM   #5
sin0nyx
LQ Newbie
 
Registered: Aug 2008
Distribution: Gentoo, Fedora, CentOS, Ubuntu
Posts: 15

Rep: Reputation: 0
RHEL uses up2date as a package manager. I don't believe RHEL includes mssql support but I would try up2date anyway to make sure.

Code:
up2date --install php-mssql
If that fails you can still use up2date to install freetds and then continue with the how to above.

Code:
up2date --install freetds
However, if I were you I would just compile the mssql support as a module. Here is a quick and dirty how to.

Code:
up2date --install freetds
up2date --install php-devel
Download and extract the same version of PHP you currently are running from php.net.

Code:
cd /path_to_source/ext/mssql/
phpize
./configure
make
Locate the other PHP modules on your system and copy the new mssql.so to that directory. An easy way to check this is with "grep extension_dir /etc/php.ini". /usr/lib/php4/ may or may not be correct for your server so make sure to check.

Code:
cp module/mssql.so /usr/lib/php4/
echo 'extension=mssql.so' > /etc/php.d/mssql.ini
service httpd restart
Good luck
 
Old 08-30-2008, 08:22 PM   #6
Evancool
LQ Newbie
 
Registered: Aug 2008
Distribution: RHEL, SuSE
Posts: 7

Rep: Reputation: 0
Hi SinOnyx,

Thanks for posting that help. I tried the up2date commands for each and got these results:

php-mssql was not found
freetds was not found
php-devel was skipped for reason: name/pattern

Was there a prerequisite step to prevent the "not found" and "skipped" errors?
 
Old 08-30-2008, 08:27 PM   #7
Evancool
LQ Newbie
 
Registered: Aug 2008
Distribution: RHEL, SuSE
Posts: 7

Rep: Reputation: 0
I forgot the mention that I'm running PHP 5.2.6 currently and I downloaded it's source for the phpize step. That's where the "FreeTDS not installed error" occurred when trying to make the MSSQL module via the ./configure step.

Last edited by Evancool; 08-30-2008 at 08:29 PM.
 
Old 08-30-2008, 09:20 PM   #8
Evancool
LQ Newbie
 
Registered: Aug 2008
Distribution: RHEL, SuSE
Posts: 7

Rep: Reputation: 0
ok I made some progress, the 0.82 version of freetds doesn't seem to work here so I went back to 0.63, and I was able to make the mssql.so file and it copied to the php extensions directory. Upon adding it to the php.ini file with extension=mssql.so it seemed to have no effect. The phpinfo() does not show MSSQL support and the test page still shows mssql_connect as an undefined function. And of course I did restart apache.

Last edited by Evancool; 08-31-2008 at 01:59 AM.
 
Old 08-31-2008, 02:42 AM   #9
Evancool
LQ Newbie
 
Registered: Aug 2008
Distribution: RHEL, SuSE
Posts: 7

Rep: Reputation: 0
crap. ok I got past that error and now php recognizes mssql support. but I can't connect to my mssql server. I have to access it by it's ip address and I already have port 1433 open.
 
Old 09-03-2008, 02:12 PM   #10
morroida
LQ Newbie
 
Registered: Sep 2008
Posts: 1

Rep: Reputation: 0
Quote:
Originally Posted by Evancool View Post
ok I made some progress, the 0.82 version of freetds doesn't seem to work here so I went back to 0.63, and I was able to make the mssql.so file and it copied to the php extensions directory. Upon adding it to the php.ini file with extension=mssql.so it seemed to have no effect. The phpinfo() does not show MSSQL support and the test page still shows mssql_connect as an undefined function. And of course I did restart apache.


im stuck exactly on that part, how did you solve it?
 
Old 09-07-2008, 08:30 PM   #11
Evancool
LQ Newbie
 
Registered: Aug 2008
Distribution: RHEL, SuSE
Posts: 7

Rep: Reputation: 0
Quote:
Originally Posted by morroida View Post
im stuck exactly on that part, how did you solve it?
I really had to fight it. What I did was download the source of the 0.63 version of FreeTDS. The higher versions seem to require different instructions not available anywhere. Also, I am using SQL Server 2005 Express for this and connecting to it from Redhat Enterprise 4.

Anyways, After doing the tar extraction of the 0.63 source, go to that 0.63 directory, then:

Code:
./configure --with-tdsver=8.0 --prefix=/usr/local/freetds
make
make install
Then make the appropriate modifications to the freetds.conf file.

Next, download the PHP source files from php.net that matches your current PHP version to your /root directory. tar extract the php source, then change to its directory like you did with FreeTDS above, except this time you'll go a step further by changing to the php-source/ext/mssql directory.

In that directory, do this:

Code:
phpize
./configure --with-mssql
make
make install
This should automatically add mssql.so to your php extension directory. If it did not, be sure to copy it to the right place. Last, go to your current php.ini file which is usually in /usr/local/lib and add to it this line:
Code:
extension=mssql.so
Restart apache as indicated in the instructions. Also, like the others said, do a phpinfo(); on a test page to make sure the MSSQL functions are working, and then finally be sure that you have port 1433 open on your SQL server and firewall and that MSSQL is configured to listen on TCP.

Last edited by Evancool; 09-07-2008 at 08:38 PM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How can i connect mssql server from linux apache sachitanandpandey Linux - Software 1 10-25-2006 06:04 PM
Accessing MSSQL database through C++ on linux using freetds nidhi Programming 2 07-07-2006 01:25 PM
Running mssql server in linux ? dextermovies Linux - Newbie 1 01-31-2006 02:43 PM
Connecting to MSSQL Server 7 from Linux vil Linux - Software 3 07-07-2004 12:46 PM
MSSQL Enterprise for Linux aliensub Linux - Software 2 02-04-2003 08:43 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 10:36 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration