php - 需要在 linux(centos) 中托管 php-sqlsrv 应用程序的解决方案

标签 php sql-server linux

<分区>

我们在windows环境下开发了一个远程连接sql server的php webapplication。现在,如果我们尝试在 linux 环境 (Centos) 中托管相同的应用程序,它不会通过我的 php 应用程序连接到 sql server。请找到以下配置..

window :

应用程序:PHP(版本:5.3.8)

服务器:Wamp服务器

数据库:远程连接到SQL Server 2008 R2

用于连接的代码:sqlsrv_connect(安装和连接的 SQL 驱动程序)

使用的 DLL:所有 php_sqlsrv_53_ts.dll 文件

还安装了 SQL Server 2012 native 客户端

现在我如何使用上述(配置)提到的 php 应用程序在 centos 中托管我的网站???

Linux(Centos):

甚至我们在 centos 中尝试使用免费的 TDS。这有助于远程联系 SQL 服务器,但我们的 php 应用程序不支持此功能。我知道 dll 文件和激活这些激活在远程连接 sql server 和 php 应用程序方面起着重要作用。但 DLL 文件不能用于 linux 环境。那么有什么解决这个问题的建议吗?

任何建议/解决方案将不胜感激。谢谢。

最佳答案

Microsoft 的 php_sqlsrv 驱动程序不存在 Linux 驱动程序。来自文档:

Supported Operating Systems: Windows 2000 Service Pack 4; Windows Server 2003 Service Pack 2; Windows Server 2008; Windows Small Business Server 2003 ; Windows Vista Service Pack 1; Windows XP Service Pack 2

虽然驱动程序的源代码可用,但尚未移植到 Linux。您可以通过以下方式将 Web 应用程序移植到 Linux:

  • 尝试使用 mssql 驱动程序(如果可能)
  • 尝试使用 odbc 驱动程序(如果可能)
  • 迁移到不同的数据库,如 mysql、postgres ...
  • 自己将驱动程序移植到 Linux(硬)
  • 使用 Windows ;)

另一种(非常hacky)的方法(如果你真的需要这个)可能是:在 CentOS 上安装 wine 并以 fcgi 的形式运行 php,其中解释器是一个 wine 应用程序.然后你可以使用 php_sqlsrv Windows dll。我没有对此进行测试,但它可能会起作用。

关于php - 需要在 linux(centos) 中托管 php-sqlsrv 应用程序的解决方案,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14250924/

相关文章:

php - Wordpress 中的 Animate.css

sql-server - 如何将表 1 中的几列复制到表 2 中,同时还在表 2 中定义某些静态行?

javascript - 使用 Nodejs 7.7.4 从源代码构建 Atom 时出错

linux - 这个 x86 Hello World using 32-bit int 0x80 Linux system calls from _start 的解释是什么?

PHP 5.5 : accessing a static class member of a dynamic class stored in an object

php - 特定文件的mod_rewrite异常

php - Apache/PHP 多请求处理和调度?

c# - Visual Studio 2008 无法连接到 SQL Server 2008

c# - 在主键中创建带有 DateTime 的实体

java - 在 Linux 上从 Java 使用 Matlab parpool 时出错