<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>How to get it done &#187; php mssql</title>
	<atom:link href="http://howtogetitworking.com/tag/php-mssql/feed/" rel="self" type="application/rss+xml" />
	<link>http://howtogetitworking.com</link>
	<description>get things workin</description>
	<lastBuildDate>Tue, 01 Jun 2010 04:45:41 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
<xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" />
		<item>
		<title>How To: Install mssql extension for php on unix</title>
		<link>http://howtogetitworking.com/2008/02/26/how-to-install-mssql-extension-for-php-on-unix/</link>
		<comments>http://howtogetitworking.com/2008/02/26/how-to-install-mssql-extension-for-php-on-unix/#comments</comments>
		<pubDate>Tue, 26 Feb 2008 09:52:57 +0000</pubDate>
		<dc:creator>Steven</dc:creator>
				<category><![CDATA[php]]></category>
		<category><![CDATA[software]]></category>
		<category><![CDATA[unix]]></category>
		<category><![CDATA[freetds]]></category>
		<category><![CDATA[isql]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[mssql.so]]></category>
		<category><![CDATA[php extension]]></category>
		<category><![CDATA[php mssql]]></category>
		<category><![CDATA[php pecl]]></category>
		<category><![CDATA[tsql]]></category>
		<category><![CDATA[txt2man]]></category>
		<category><![CDATA[unixodbc]]></category>

		<guid isPermaLink="false">http://howtogetitworking.com/?p=8</guid>
		<description><![CDATA[woh! okie.. this installation is gng to be long a tough.. took me a few days of google crawling and testing before i finally get it to work. okie, why will u need to install mssql extension on php? possibly becos u need to connect to a ms sql server of ur vendor or something [...]]]></description>
			<content:encoded><![CDATA[<p>woh! okie.. this installation is gng to be long a tough.. took me a few days of google crawling and testing before i finally get it to work.</p>
<p>okie, why will u need to install mssql extension on php? possibly becos u need to connect to a ms sql server of ur vendor or something like that. for integration i hope. cos unix works best w php and mysql, ie, installation, it is almost already thr. correct me if i m wrong.</p>
<p><strong>so wad you need?</strong><br />
if your server is jus fresh out of the box or say u had installed whm/cpanel there will be quite a far bit of stuff u will need.</p>
<p>1. Txt2man<br />
2. unixODBC<br />
3. freeTDS<br />
4. PHP mssql.so</p>
<p>if this point if you are wondering if i m using any rpm for installation?<br />
sorry,i m not, cos my server centos installed w whm/cpanel seems to be poorly equipped or configured for rpm installation, too many dependencies required. so jus download all the binary and upload them onto ur server.</p>
<p><strong>Setup 1: Install unixODBC package</strong></p>
<p>Install unixODBC first. Download the software in your home directory or anywhere you like and uncompress and untar the software.</p>
<p>You can do this by using following command</p>
<div style="background-color:#CCCCCC"># tar -xvzf unixODBC-2.2.12.tar.gz</div>
<p>Once it is done, go to the unixODBCxxxx dir and run the configure command.</p>
<div style="background-color:#CCCCCC"># ./configure -prefix=/usr/local -enable-gui=no</div>
<p>Note: If you dont use enable-gui option and dont have Qt package, you will get the error. So make sure you use it if no Qt is installed.</p>
<p>After configure is successfully completed, run the make and then make install commands.</p>
<div style="background-color:#CCCCCC"># make</div>
<p>Install it</p>
<div style="background-color:#CCCCCC"># make install</div>
<p><strong>Step 1.1: Installing Txt2man</strong><br />
this step is optional if your server already have txt2man installed.<br />
txt2man is required by freeTDS to man it documentation, i do find this portion pretty useless though.<br />
else jus download the package, and run the make</p>
<div style="background-color:#CCCCCC"># make</div>
<p>Install it</p>
<div style="background-color:#CCCCCC"># make install</div>
<p><strong>Step 2: Install freeTDS package</strong></p>
<p>Download the freeTDS package and untar and uncompress it.</p>
<div style="background-color:#CCCCCC"># tar -xvzf freetds-stable.tgz</div>
<p>Run the configure.</p>
<div style="background-color:#CCCCCC"># ./configure -with-tdsver=8.0 -with-unixODBC=/usr/local</div>
<p>Run the make</p>
<div style="background-color:#CCCCCC"># make</div>
<p>Install it</p>
<div style="background-color:#CCCCCC"># make install</div>
<p><strong>Step 3: Configuration freeTDS</strong><br />
Start configuration with freeTDS. Look for the freetds.conf file and add the entry for the MS SQL server.</p>
<div style="background-color:#CCCCCC">[MSHOSTNAME]<br />
host = MSHOSTNAME<br />
port = 1433<br />
tds version = 8.0</div>
<p>Sql server standard port is the 1433. The tds version for MS SQL server 2000 is 8. You can try 8.0 with new version as well.<br />
Important: the host need to be the same as the declaration. ie<br />
if you have [mssql.hostname.com], ur host will be = mssql.hostname.com</p>
<p><strong>Step 4: Configuration &#8211; unixODBC</strong></p>
<p>The unixODBC need two main configuration files called odbcinst.ini and odbc.ini. These files should be in the /etc/ dir.</p>
<p><strong>I.</strong> The first file odbcinst.ini contain the definition of ODBC driver.</p>
<div style="background-color:#CCCCCC">[TDS]<br />
Description = FreeTDS driver<br />
Driver = /usr/local/lib/libtdsodbc.so<br />
Setup = /usr/local/lib/libtdsodbc.so<br />
Trace = Yes<br />
TraceFile = /tmp/freetds.log<br />
FileUsage = 1</div>
<p>Note: Before making above entries, make sure libtdsodbc.so exists in the /usr/local/lib dir.<br />
In the above configuration, we have define TDS as driver.</p>
<p><strong>II.</strong> The second file is odbc.ini. This file has information about your MS SQL database.</p>
<div style="background-color:#CCCCCC">[MSHOSTNAME]<br />
Driver = TDS<br />
Description = MS SQL Test<br />
Trace = Yes<br />
TraceFile = /tmp/mstest.log<br />
Servername = 192.168.1.100<br />
Database = testdb<br />
Port = 1433</div>
<p>You can notice above that the freeTDS driver is the name defined in odbcinst.ini while servername is the one defined in freetds.conf.</p>
<p><strong>Step 5: Test MS SQL connectivity from Linux box</strong><br />
Check if you can connect to MS SQL database using unixODBC tool called isql.</p>
<div style="background-color:#CCCCCC"># isql -v mstest satest satest<br />
+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;+<br />
| Connected!                            |<br />
|                                       |<br />
| sql-statement                         |<br />
| help [tablename]                      |<br />
| quit                                  |<br />
|                                       |<br />
+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;+<br />
SQL&gt; select * from &#8220;sysObjects&#8221;;</div>
<p>If you see the results, you are connected.</p>
<p><strong>Step 6: Getting your mssql.so file</strong><br />
<strong>Update:</strong> I came back to follow this to create an .so file and realise, mmm, this instruction wasn&#8217;t too clear. So here it goes. From <a href="php.net/downloads.php">PHP.net Download</a> page, download the source code, then if you unzip, you will find a folder &#8220;ext&#8221; and &#8220;mssql&#8221; in the &#8220;ext&#8221; folder. tat&#8217;s the folder i m referring to, &#8216;cd&#8217; to this folder and then run phpize as below mentioned.</p>
<p><strong id="mssql.so">Add: </strong> for the benefits of those who just need the .so file, you can download the <a href="http://www.howtogetitworking.com/downloads/mssql.so.zip">mssql.so</a> from here. however, i don&#8217;t assure, compatibility with you php version. is built with php 5.2.10 binaries.</p>
<p>php.net is not distrubuting the binary version of php package for *nix server, so you will have to create the .so extension file yourself. download the source file for php and upload the folder /ext/mssql/ into your server<br />
then</p>
<div style="background-color:#CCCCCC"># cd /uploaded_path/mssql/<br />
# phpize<br />
# ./configure<br />
# make<br />
# make install</div>
<p>this commands will automatically create a copy of mssql.so in the installed extension folder.<br />
you can check your extension folder from</p>
<div style="background-color:#CCCCCC">&lt;?php<br />
phpinfo();<br />
?&gt;</div>
<p><strong>Step 7: Enabling the extension</strong></p>
<div style="background-color:#CCCCCC"># echo &#8220;extension=mssql.so&#8221; &gt; /usr/local/lib/php.ini</div>
<p>or you can use a texteditor and add that value manually into php.ini</p>
<p><strong>Step 8: Restarting Apache Server!</strong><br />
dependin on version installed and location</p>
<div style="background-color:#CCCCCC"># /etc/init.d/httpd restart</div>
<p>and you are done!<br />
do drop me an email should you face any problem at any step!<br />
i know the pain in gettin this extension installed on unix. and considering rpm fails to work in the first place.<br />
i will say, this is the best way to get it installed, cos u have full control over it. and didn&#8217;t fail me, of cos, after hell lots of googling around.</p>
<p>Source:<br />
<a href="http://www.dbapool.com/articles/06280701.html">dpacool.com</a><br />
<a href="http://www.unixodbc.org/doc/FreeTDS.html">unixodbc.org</a><br />
<a href="http://www.scottdavey.net/blogger/2008/02/connecting-to-ms-sql-server-from-php.html">Scott&#8217;s Blog</a><br />
<a href="http://php.mirrors.ilisys.com.au/manual/en/install.pecl.phpize.php">PHP PECL</a></p>
]]></content:encoded>
			<wfw:commentRss>http://howtogetitworking.com/2008/02/26/how-to-install-mssql-extension-for-php-on-unix/feed/</wfw:commentRss>
		<slash:comments>67</slash:comments>
		</item>
	</channel>
</rss>
