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 mssql.so /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 = mssql.so


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.

Thanks.