cannot create mssql.so on ubuntu 16.04 and php5.6

using php5.6 with freetds installed, and use ubuntu server 16.04

sudo add-apt-repository ppa:ondrej/php
sudo apt-get update
sudo apt-get install apache2 mysql-server php5.6 php5.6-mbstring php5.6-mcrypt php5.6-mysql php5.6-xml php5.6-cli libapache2-mod-php5.6 php5.6-gd freetds-common freetds-bin unixodbc php5.6-sybase php5.6-odbc cifs-utils php5.6-curl

how i know which mssql not working ???

  • try with phpinfo
    sudo nano /var/www/html/info.php
    # paste this code
    <?php phpinfo(); ?>

    open with browser, but i can find mssql there

  • try with php code
    sudo nano /var/www/html/ms.php
    # paste this code
    <?php
    $connection = mssql_connect('mssql-host', 'mssql-user', 'mssql-pass');
    if (!$connection) { die('Unable to connect!'); }
    if (!mssql_select_db('mssql-db', $connection)) { die('Unable to select database!');}
    $result = mssql_query('SELECT * FROM CAPACITY_INFO');
    while ($row = mssql_fetch_array($result)) { var_dump($row); }
    mssql_free_result($result);
    ?>
    # then try
    php /var/www/html/ms.php

    php-mssql

  • success try with tsql

tsql

  • cannot find mssql.so in /usr/lib/php/20131226/
    ls /usr/lib/php/20131226/ | grep mssql

 how to solve

# download the mssql.so
# this mssql get from ubuntu server 64 bit and php 5.6
https://drive.google.com/open?id=0BxV3_TI0LIeYT2pzVzBXRG1sVWM

#upload to your server
scp mssql.so user@server:/home/youruserhome

# move mssql.so to /usr/lib/php/20131226/
sudo mv /home/youruserhome/mssql.so /usr/lib/php/20131226/

# create mssql.ini
sudo nano sudo /etc/php/5.6/mods-available/mssql.ini

# insert this code
extension=mssql.so
# save and close

# copy config mssql.ini 
cd /etc/php/5.6/apache2/conf.d
sudo ln -s /etc/php/5.6/mods-available/mssql.ini 20-mssql.ini
cd /etc/php/5.6/cli/conf.d
sudo ln -s /etc/php/5.6/mods-available/mssql.ini 20-mssql.ini

# restart service apache2
sudo service apache2 restart

test again with phpinfo and script

mssql-phpinfo

success

Published by

G3n1k

just to remember what i had known :)

2 thoughts on “cannot create mssql.so on ubuntu 16.04 and php5.6”

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s