一、cd /path/to/php-5.6.16/ 進入PHP源碼目錄
二、cd ext/Sybase_ct
三、修改PHP_Sybase_ct.c把涉及到mssql_等函數的代碼注釋掉(否則mssql模塊不能同時加載),具體修改如下
/*
#if !defined(PHP_WIN32) && !defined(HAVE_MSSQL)
PHP_FALIAS(mssql_connect, sybase_connect, arginfo_Sybase_connect)
PHP_FALIAS(mssql_pconnect, sybase_pconnect, arginfo_Sybase_pconnect)
PHP_FALIAS(mssql_close, sybase_close, arginfo_Sybase_close)
PHP_FALIAS(mssql_select_db, sybase_select_db, arginfo_Sybase_select_db)
PHP_FALIAS(mssql_query, sybase_query, arginfo_Sybase_query)
PHP_FALIAS(mssql_unbuffered_query, sybase_unbuffered_query, arginfo_Sybase_unbuffered_query)
PHP_FALIAS(mssql_free_result, sybase_free_result, arginfo_Sybase_free_result)
PHP_FALIAS(mssql_get_last_message, sybase_get_last_message, arginfo_Sybase_get_last_message)
PHP_FALIAS(mssql_num_rows, sybase_num_rows, arginfo_Sybase_num_rows)
PHP_FALIAS(mssql_num_fields, sybase_num_fIElds, arginfo_Sybase_num_fIElds)
PHP_FALIAS(mssql_fetch_row, sybase_fetch_row, arginfo_Sybase_fetch_row)
PHP_FALIAS(mssql_fetch_array, sybase_fetch_array, arginfo_Sybase_fetch_array)
PHP_FALIAS(mssql_fetch_assoc, sybase_fetch_assoc, arginfo_Sybase_fetch_assoc)
PHP_FALIAS(mssql_fetch_object, sybase_fetch_object, arginfo_Sybase_fetch_object)
PHP_FALIAS(mssql_data_seek, sybase_data_seek, arginfo_Sybase_data_seek)
PHP_FALIAS(mssql_fetch_field, sybase_fetch_fIEld, arginfo_Sybase_fetch_fIEld)
PHP_FALIAS(mssql_field_seek, sybase_fIEld_seek, arginfo_Sybase_fIEld_seek)
PHP_FALIAS(mssql_result, sybase_result, arginfo_Sybase_result)
PHP_FALIAS(mssql_affected_rows, sybase_affected_rows, arginfo_Sybase_affected_rows)
PHP_FALIAS(mssql_min_client_severity, sybase_min_clIEnt_severity, arginfo_Sybase_min_clIEnt_severity)
PHP_FALIAS(mssql_min_server_severity, sybase_min_server_severity, arginfo_Sybase_min_server_severity)
PHP_FALIAS(mssql_set_message_handler, sybase_set_message_handler, arginfo_Sybase_set_message_handler)
PHP_FALIAS(mssql_deadlock_retry_count, sybase_deadlock_retry_count, arginfo_Sybase_deadlock_retry_count)
#endif
*/
如果無需通過mssql.o模塊用PHP訪問msSQL Server則可忽略這一步(用dblib pdo訪問不受次影響)
Linux下PHP訪問遠程mssq可參考本人的如下博文
http://weibo.com/p/23041854dd80920102v76c
四、/opt/php/bin/PHPize生成編譯配置文件
五、./configure --with-php-config=/opt/php/bin/PHP-config -with-sybase-ct=/opt/Sybase/OCS-16_0
六、make&sudo make install
編譯完成在/opt/php/lib/PHP/extensions/no-debug-zts-20131226/目錄下生成Sybase_ct.so
七、修改PHP.ini,將該模塊載入:
extension=Sybase_ct.so
八、重啟apache服務
sudo service apachectl stop
sudo service apachectl start
九、測試代碼
<?PHP /* connect to database */ sybase_connect('MYMOTIFVOSTRO145480', 'sa', 'wxwpxh') or dIE("Could not connect"); sybase_select_db("testdb"); $result=sybase_query("SELECT * FROM STUDENT"); while($row=Sybase_fetch_array($result)) { echo $row[0]; echo '::'; echo $row[1]; echo "<br>"; } ?>