How to compile MSSQL support into PHP in Ubuntu Dapper Drake
Tuesday, May 30th, 2006This information is specific to Ubuntu Dapper Drake, but it may work on other versions of the software. This will allow you to connect to Microsoft’s SQL Server 2000 to use Apache and PHP to connect to a MSSQL database.
- Install support packages
sudo aptitude install freetds-dev
sudo aptitude install tdsodbc
- Modify the Freetds file to access the server: sudo nano /etc/freetds/freetds.conf (not sure if this is necessary)
# Our SQL Server [FSData] host = 192.168.x.x port = 1433 tds version = 8.0
- Tell UnixODBC where to find the FreeTDS driver and give it a name:
- Modify /etc/odbcinst.ini
[FreeTDS] Description = FreeTDS 0.61-5 Deb Driver = /usr/lib/odbc/libtdsodbc.so Setup = /usr/lib/odbc/libtdsS.so FileUsage = 1 CPTimeout = 5 CPReuse = 5
-
- Modify the odbc.ini file: sudo nano /etc/odbc.ini
[Products] Description = Products on Our MSSQL Server Driver = FreeTDS Servername = FSData Database = Products
- Download dpkg
sudo aptitude install dpkg-dev
- Download php-src
sudo aptitude source php5
- Go into the new php5 directory
- Edit the debian/rules file - add the following to the common config sudo nano debian/rules
--with-mssql
- build dependencies
sudo aptitude build-dep php5
- build the package
sudo dpkg-buildpackage
- install the new PHP w/ MSSQL
sudo dpkg -i php5_5*.deb
- copy the new libphp5.so to the correct directory (otherwise it will still use the old one)
sudo cp ~/php5-*/apache2-build/libs/libphp5.so /usr/lib/apache2/modules/libphp5.so
- restart Apache
sudo /etc/init.d/apache2 restart