php - Ubuntu-16.04 + PHP-7.0.22 + ODBC 不工作

标签 php linux odbc unixodbc

我一直在尝试从我的 ubantu 16.04 连接 MSSQL,我使用了以下教程:

https://askubuntu.com/questions/578934/mssql-connection-from-ubuntu

当我在终端下运行命令时出现一个问题是:

sudo apt install php7.0-odbc php7.0-sybase tdsodbc

它显示以下错误:

The following packages have unmet dependencies:
php7.0-odbc : Depends: php7.0-common (= 7.0.4-7ubuntu2) but 7.0.22-0ubuntu0.16.04.1 is to be installed
php7.0-sybase : Depends: php7.0-common (= 7.0.4-7ubuntu2) but 7.0.22-0ubuntu0.16.04.1 is to be installed
E: Unable to correct problems, you have held broken packages.

我也遵循以下链接答案给出的说明: https://serverfault.com/questions/812509/ubuntu-16-04-php-7-microsoft-odbc-driver-for-sql-server-on-linux-odbc-connec

但我很无奈,当我在我的 ubantu-16.04 中检查 phpifo 时,没有启用 ODBC 驱动程序。 我正在使用 php7.0.22。

谁能指导我在 apache 中启用 ODBC 驱动程序,因为我被卡住了??

提前致谢。

最佳答案

我通过以下努力进一步调试并解决了问题,

1) 我在我的 Ubuntu 16.04 中将 PHP 从 7.0.22 更新到 7.0.23。

2) 从我的 Ubuntu 中删除 freetds 和当前安装的 ODBC。

3) 按照 URL 中提到的所有步骤重新安装:

https://askubuntu.com/questions/578934/mssql-connection-from-ubuntu

4) 设置值到freetds.conf, odbc.ini, odbcinst.ini

5)然后尝试命令:telnet 192.168.0.1 1433(你的本地IP和端口)

6) 也试试命令:tsql -S 'DNS name' -U devuser/isql -v DNS Name User 'Password'

(In my case in tsql and isql IP was not working and DNS name working and connect to  SQL server so check alternate for connection)

7) 成功连接到MSSQL服务器并获取数据并显示到浏览器中。

谢谢。

关于php - Ubuntu-16.04 + PHP-7.0.22 + ODBC 不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46040497/

相关文章:

.net - 是否有可能出现 PHP.NET?

php - 如何使用 BuildMaster 仅复制已修改的文件到我的服务器?

php - Ajax 文件上传并预览

php - 搜索结果后如何更新库存数量?

c++ - 线程安全的 vector 和字符串容器?

linux - Linux 中的核心转储

sql-server - SQL Server : How to make a transaction commit fail?

python - 将自动提交设置为 true 是否比批量提交需要更长的时间?

Java Linux : java.net.BindException: 地址已被使用

c++ - 使用 ODBC 连接到 SQL SERVER 2008