반응형


https://g3n1k.wordpress.com/2016/10/03/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


반응형

'Program > PHP' 카테고리의 다른 글

php, mysql_fetch_assoc 결과를 json 문자열로 만들기  (0) 2017.10.28
API  (0) 2017.02.21
PHP7 에서 PHP5.6 사용하기  (0) 2016.11.11
SQL Relay php connection  (0) 2016.07.17
PHP PHP EXCEL (PHP 엑셀 읽기 쓰기)  (0) 2016.01.21

+ Recent posts