We find that our customers commonly need to an MSSQL database from PHP on a server running cPanel. However, cPanel doesn't have an option for installing FreeTDS or PDO_DBLIB in
Step 1: Getting Started
- You will need ROOT access to your cPanel server.
- You will need SSH credentials as well (this is a command line install, not something done through WHM)
Step 2: SSH Into Your Server
- SSH into your server
- Elevate your permissions to root (using
Step 3: Install FreeTDS
Note that if the latest stable is a different version, you will have a different path to cd to, just look at the path that is made when the tarball is extracted
cd /usr/local/src/ wget ftp://ftp.freetds.org/pub/freetds/stable/freetds-patched.tar.gz tar xvzf freetds-patched.tar.gz cd freetds-0.95.87/
Step 4: Edit
freedts.conf to make it MS SQL friendly
Now edit /
[global] # TDS protocol version tds version = 8.0 client charset = UTF-8 port = 1433
Step 5: Add
fteeds to /etc/ ld.so.conf and make FreeTDS PHP friendly.
echo "include /usr/local/freetds/lib" >> /etc/ld.so.conf ln -s /usr/local/freetds/lib/libsybdb.so.5 /usr/lib64/libsybdb.so.5 mkdir /usr/local/freetds/lib64 ln -s /usr/local/freetds/lib/libsybdb.so.5 /usr/local/freetds/lib64/libsybdb.so ldconfig -v
Step 6: Recompile PHP5 with FreeTDS using EasyApache & Verify
You should see '
echo "--with-mssql=/usr/local/freetds" >> /var/cpanel/easy/apache/rawopts/all_php5 /scripts/easyapache php -m | grep mssql
Step 7: Compile PDO_DBLIB
Make sure you know your PHP version to change to the correct directory. NB: You will need to run these steps again if/when your PHP version changes.
cd /home/cpeasyapache/src/php-5.5.32/ext/pdo_dblib phpize ./configure --with-pdo-dblib=/usr/local/freetds/ make make install
Step 8: Add pdo_dblib to php.ini
Step 9: Verify you see the pdo_dblib module
Run this command:
$ php -m | grep dblib
The output of the command should be 'pdo_dblib'
All done! Enjoy using MSSQL DB's with PHP on a cPanel server! Honestly, I don't see a valid reason why this isn't an option in