1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Adding MSSQL support to PHP

Discussion in 'Database Discussions' started by DiscoBurgess, May 25, 2007.

  1. DiscoBurgess

    DiscoBurgess New Member

    Joined:
    May 25, 2007
    Messages:
    7
    Likes Received:
    0
    Trophy Points:
    1
    I've read around on this, and it seems to be a bit of a minefield, and none of the things I've read involve CPanel.

    So... any chance anyone could talk me through this? I have my Linux CPanel server, and I want to retrieve data from another of my servers that's running Windows Server 2003 with MS SQL. Linux isn't exactly my strong point, either.
     
  2. WebScHoLaR

    WebScHoLaR Member

    Joined:
    Dec 14, 2005
    Messages:
    511
    Likes Received:
    1
    Trophy Points:
    18
    Location:
    Planet Earth
    You need to first compile freetds and then compile PHP with freetds support. I have done it couple of times and prepared notes for it. You can try these notes.

    INSTALLING FREETDS

    1-. Download freetds -> www.freetds.org
    2-. tar -zxvf freetds-stable-tgz
    3-. cd freetds-*
    4-. ./configure --prefix=/usr/local/freetds --with-tdsver=8.0 --enable-msdblib --enable-dbmfix --with-gnu-ld

    Note: tdsver=8.0 if you use SQL 2000, tdsver=7.0 if you use SQL 7.0

    5-. make
    6-. make install
    7-. /usr/local/freetds/bin/tsql -S <ip of the server> -U <User SQL>

    Note: For default User SQL is sa and the it have not password
    For example: /usr/local/freetds/bin/tsql -S 198.168.100.2 -U sa

    8-. Add the next text in freetds.conf ( /usr/local/freetds/etc )
    [TDS]
    host = <ip of the Server with Sql>
    port = 1433
    tds version = 8.0

    Note: If you use SQL 2000 then tds version = 8.0
    if you use SQL 7.0 then tds version = 7.0

    9-. Add the following line in the file /etc/ld.so.conf and run ldconfig -v:
    /usr/local/freetds/lib

    10- Recompile PHP with --with-mssql=/usr/local/freetds flag.
     
    #2 WebScHoLaR, May 25, 2007
    Last edited: May 25, 2007
  3. DiscoBurgess

    DiscoBurgess New Member

    Joined:
    May 25, 2007
    Messages:
    7
    Likes Received:
    0
    Trophy Points:
    1
    Brilliant, thank you. I'm just starting to run through this now. Just one question so far:
    I was planning on using a specific user account that does have a password. Do I just use:
    ...to specify a password?
     
  4. WebScHoLaR

    WebScHoLaR Member

    Joined:
    Dec 14, 2005
    Messages:
    511
    Likes Received:
    1
    Trophy Points:
    18
    Location:
    Planet Earth
    I don't remember exactly that what are the parameters for /usr/local/freetds/bin/tsql. Once you compile and install Freetds, just run /usr/local/freetds/bin/tsql from command line to see its available options that how you can specify the password.
     
  5. DiscoBurgess

    DiscoBurgess New Member

    Joined:
    May 25, 2007
    Messages:
    7
    Likes Received:
    0
    Trophy Points:
    1
    Okay, it's going well so far. -P is indeed the parameter for the password. However, once I put in that line, I get this:
    Code:
    locale is "en_GB.UTF-8"
    locale charset is "UTF-8"
    1>
    
    Pressing enter gives me more prompts like this:
    Code:
    2>
    3>
    4>
    
    And typing 'exit' gets me out. What does it mean? Should I just 'exit' and carry on, or is this not supposed to happen?
     
  6. DiscoBurgess

    DiscoBurgess New Member

    Joined:
    May 25, 2007
    Messages:
    7
    Likes Received:
    0
    Trophy Points:
    1
    Apparently it means a successful connection and I should Ctrl-C and move on, so I did ;)
     
  7. kenhawkins

    kenhawkins New Member

    Joined:
    Jan 12, 2007
    Messages:
    5
    Likes Received:
    0
    Trophy Points:
    1
    hate to bring it up however post php rebuild there is a problem

    root and anyone that is NOT in a jailshell can use php from the command line. i'm sure it has to do with the fact that they cannot do the simplest of things like cd /usr/local/freetds.

    how can I modify the jailshell allowances to accommodate?

    thanks,
    ken;
     
  8. FAZO

    FAZO New Member

    Joined:
    Jan 11, 2006
    Messages:
    15
    Likes Received:
    0
    Trophy Points:
    1
    I followed all steps but when i try to recompile php i get this error :

    checking for alloca... (cached) yes
    checking for 8-bit clean memcmp... (cached) yes
    checking for mcrypt support... no
    checking for mhash support... no
    checking whether to include mime_magic support... no
    checking for MING support... no
    checking for mSQL support... no
    checking for MSSQL support via FreeTDS... yes
    configure: error: Directory /usr/local/freetds is not a FreeTDS installation directory
     
  9. FTNET

    FTNET New Member

    Joined:
    Oct 11, 2007
    Messages:
    6
    Likes Received:
    0
    Trophy Points:
    1
    Same error:

    checking for MSSQL support via FreeTDS... yes
    configure: error: Directory /usr/local/freetds is not a FreeTDS installation directory

    :eek:
     
  10. FTNET

    FTNET New Member

    Joined:
    Oct 11, 2007
    Messages:
    6
    Likes Received:
    0
    Trophy Points:
    1
    Problem FIXED!:p
     
  11. FAZO

    FAZO New Member

    Joined:
    Jan 11, 2006
    Messages:
    15
    Likes Received:
    0
    Trophy Points:
    1
    How could you fix it?:D
     
  12. FTNET

    FTNET New Member

    Joined:
    Oct 11, 2007
    Messages:
    6
    Likes Received:
    0
    Trophy Points:
    1
    Very simple.

    rm -fr / :p

    Follow the instructions of this post.

    INSTALLING FREETDS

    1-. Download freetds -> www.freetds.org
    2-. tar -zxvf freetds-stable-tgz
    3-. cd freetds-*
    4-. ./configure --prefix=/usr/local/freetds --with-tdsver=8.0 --enable-msdblib --enable-dbmfix --with-gnu-ld

    Note: tdsver=8.0 if you use SQL 2000, tdsver=7.0 if you use SQL 7.0

    5-. make
    6-. make install
    7-. /usr/local/freetds/bin/tsql -S <ip of the server> -U <User SQL>

    Note: For default User SQL is sa and the it have not password
    For example: /usr/local/freetds/bin/tsql -S 198.168.100.2 -U sa

    8-. Add the next text in freetds.conf ( /usr/local/freetds/etc )
    [TDS]
    host = <ip of the Server with Sql>
    port = 1433
    tds version = 8.0

    Note: If you use SQL 2000 then tds version = 8.0
    if you use SQL 7.0 then tds version = 7.0

    9-. Add the following line in the file /etc/ld.so.conf and run ldconfig -v:
    include /usr/local/freetds/lib

    10- Recompile PHP with --with-mssql=/usr/local/freetds flag.
    Create a file called all_php4 or all_php5 in:

    /var/cpanel/easy/apache/rawopts/

    The file doesnt exist by default, just create it and add the line to the file:
    --with-mssql=/usr/local/freetds

    11- Copy entire folder where you uncompress the Freetds in my case was /root to:

    /usr/local/freetds

    12- Go to /usr/local/freetds/src/tds/.libs/ and copy libtds.a to /usr/local/freetds/lib

    I do that, because when im trying Recompile PHP send me this error:

    checking for MSSQL support via FreeTDS... yes
    configure: error: Could not find /usr/local/freetds/lib/libtds.a

    13- Then go to WHM >> Main >> Software >> Apache Update
    Select: Previously Saved Config (** DEFAULT **)
    and press
    Build Profile Now.

    That's work for me.
    I hope you can make it, sorry for my bad english.
     
    #12 FTNET, May 14, 2008
    Last edited: May 14, 2008
  13. nocbr.com

    nocbr.com New Member

    Joined:
    May 1, 2006
    Messages:
    22
    Likes Received:
    0
    Trophy Points:
    1
    I want connect from my cpanel / linux / php to an externel ms sql database, do I need run the command?

    /usr/local/freetds/bin/tsql -S <ip of the server> -U <User SQL>

    thanks
     
  14. FAZO

    FAZO New Member

    Joined:
    Jan 11, 2006
    Messages:
    15
    Likes Received:
    0
    Trophy Points:
    1
    we are still having same problem on mssql, there are difference with 2
    dedicated but we did not solved it yet.
    for example, you can see on first screenshot, there is some character errors
    while it getting datas on mssql server and we think that, it will cause problem
    and not showing totals but we did not have any problem on old server without characters problems

    New server :
    http://img142.imageshack.us/img142/2091/newservercc8.jpg

    Old server :
    http://img362.imageshack.us/img362/4138/oldserverzz0.jpg


    Where is the problem ?
     
  15. hborin

    hborin New Member

    Joined:
    Jul 7, 2009
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    1
    Hi everybody,

    Please help me...I get the following error:

    checking for MSSQL support via FreeTDS... yes
    configure: error: Could not find /usr/local/freetds/lib64/libsybdb.a|so

    OS: CentOS 5.3 64bit
    PHP: 5.2.8
    Apach: 2.2

    Regards,
    Borin
     
  16. section31

    section31 Member

    Joined:
    Sep 3, 2003
    Messages:
    33
    Likes Received:
    0
    Trophy Points:
    6
    Location:
    San Antonio
  17. usercpanel

    usercpanel New Member

    Joined:
    Aug 30, 2007
    Messages:
    15
    Likes Received:
    0
    Trophy Points:
    1
    - If running a 64bit OS and get an error about

    you'll need to link a directory or two.

    In this example it was an easy fix.

    #cd /usr/local/freetds/
    #ln -s /usr/local/freetds/lib lib64
    #ll /usr/local/freetds/lib64/libsybdb.a
    #ll /usr/local/freetds/lib64/libsybdb.so
    #/scripts/easyapache

    :)
     

Share This Page