Wednesday, August 15, 2007

Ubuntu 6.10 - Building MSSQL module in PHP5

This is a tutorial on how to add MSSQL module in PHP under Ubuntu 6.10.

I assumed that you have already installed PHP5 in Ubuntu 6.10. MSSQL module for PHP5 is not available in apt-get. So we need to manually install mssql module for PHP5 in our linux box.

Step 1: Install freetds-dev package

#sudo apt-get install freetds-dev

Step 2: Get the php5 source

#sudo apt-get source php5

//assuming you are in your home directory (i.e. /home/yourname)
//the command in step 2 will download the php5 source files and it will be placed in your current directory. New directory will be created after issuing the command in step 2. Name of new directory that will be created is php5-5.1.6

Step 3: Build MSSQL module

#cd php5-5.1.6/ext/mssql
#sudo phpize
#./configure --with-mssql

//after executing the commands in step 3, new directory will be created. name of new directory is modules.

//assuming you're in your home directory. absolute path of new directory created is ~/php5-5.1.6/ext/mssql/modules

Step 4: Copy new module to php extension directory

since your current working directory is in ~/php5-5.1.6/ext/mssql, you need to change directory to modules

#cd modules
#cp /usr/lib/php5/20051025

Step 5: Modify php.ini

//your php.ini can found in /etc/php5/apache2/php.ini
//you can use vi editor to edit the file

#sudo vi /etc/php5/apache2/php.ini

add the following line:

extension =

Step 6: Restart your Apache Server

#sudo /etc/init.d/apache2 restart

//to confirm if MSSQL support is available, create a new php file and execute phpinfo() function. Run the php file to your browser and you can see the information about your PHP.



Blogger roychri said...

In step #3, make sure to run "sudo make" after "sudo ./configure --with-mssql"

In gutsy (7.10) I created a file called /etc/php5/conf.d/mssql.ini instead of modifying php.ini and in that new file I put the "".

June 17, 2008 at 8:27 AM  
Blogger mahalie said...

Thank you, thank you, thank you! Finally got my test connection PHP on LAMP to SQL on Win2K server working after trying many instructions.

One thing to add for others - if phpize 'command not found', sudo apt-get php5-dev.

November 18, 2008 at 5:48 PM  

Post a Comment

Subscribe to Post Comments [Atom]

<< Home