A very strange project was created just a few days before the title was proposed. our company developed a set of SP short message service software based on the SGIP Protocol of China Unicom to provide China Unicom's 130 short-term services. This system is in windows, and the database uses Microsoft SQLSe
Raise title
A few days ago, I made a very strange project. our company developed a set of SP-side short message service software based on the SGIP Protocol of China Unicom to provide China Unicom's 130 short-term services. This system is in Windows 2000, and the database uses Microsoft SQLServer2000, and has been running normally for a while. Recently, to provide short message user information on the WEB, you need to read and write the SQL Server database from the WEB. The original SQL Server database's best error should be the Microsoft IIS ASP server script, however, my company has always believed that the stability and security of iis asp are not satisfactory. I hope to use PHP scripts to read and write SQLServer in Linux.
Analysis title
There is no title for PHP scripts to read and write SQLServer. it works well in Apache for windows and Windows IIS. generally, it can be connected through ODBC or SQLServer Client, which are all ready-made in Windows. However, ODBC and SQLServer Client are not available in Linux. we need to install them on our own.
Resolution title
1. coherent software
Freetds origin: ftp://ftp.ibiblio.org/pub/Linux/ALPHA/freetds/freetds-0.53.tgz
This software can use Linux and Unix to connect MS SQLServer and Sybase databases.
II. installation and configuration steps
Step 1: compile and install freetds:
Get the freetds-0.53.tgz
Cp freetds-0.53.tgz/tmp/. (copy the freetds package to the/tmp directory)
Cd/tmp (in directory)
Tar zxvf freetds-0.53.tgz (extract)
Cd freetds-0.53 (directory after decompression)
./Configure-prefix =/usr/local/freetds -- with-tdsver = 7.0
Gmake)
Gmake install (installation)
For more information about configure, -- prefix =/usr/local/freetds indicates that it is installed in the/usr/local/freetds directory, -- with-tdsver = 7.0 refers to the installation of the tds 7.0 version (the most open is that I did not add this compilation parameter, and the result is compiled as 5.0 by default. 5.0 the port connecting to the database is 4000, not 1433 of SQLServer)
Step 2: re-compile PHP4
./Configure [-- with-apxs -- with-mysql...] -- with-sybase =/usr/local/freetds (be careful with sybase)
Make
Make install
Step 3: Configure freetds
Vi/usr/local/freetds/etc/freetds. conf
For detailed configuration, see the description in this file.
Example: (typical configuration)
[Sqlserver]
Host = SQL _server_name_or_host_ip (your SQLServer machine name or IP address)
Port = 1433
Tds version = 7.0
You can configure Windows domain login or SQLServer account login in this configuration file.
Step 4: configure the php. ini file
Find; extension = mssql70.so
Comments; dropped
Extension = mssql70.so
Step 5: create a database connection in php
$ Link = mssql_connect ('sqlserver ', $ your_username, $ your_password) or die ("can't Connect to Database ");
Echo $ link;
Run the above script in the browser. if you get a link number, congratulations. you have configured it. if the Call to undefined function: mssql_connect () is displayed () then let's clarify which step is not correct if you carefully check the installation and configuration process above.