简体   繁体   English

如何在Amazon Linux AMI上为PHP for SQL Server安装Microsoft驱动程序

[英]How to install Microsoft Drivers for PHP for SQL Server on Amazon Linux AMI

I am trying to install Microsoft Drivers for PHP for SQL Server using the document provided by Microsoft. 我正在尝试使用Microsoft提供的文档为SQL Server安装Microsoft Drivers for PHP。 Link is https://github.com/Microsoft/msphpsql 链接是https://github.com/Microsoft/msphpsql

It provides installation steps for Ubuntu and Redhat but not Amazon Linux. 它为Ubuntu和Redhat提供安装步骤,但不为Amazon Linux提供安装步骤。 To install Microsoft Drivers on Amazon, I followed steps provided for Redhat ( not sure if it is correct). 要在Amazon上安装Microsoft驱动程序,我按照为Redhat提供的步骤(不确定它是否正确)。 When I run the command 当我运行命令

sudo ACCEPT_EULA=Y yum install msodbcsql mssql-tools

got the below error 得到以下错误

Error: Package: msodbcsql-13.1.7.0-1.x86_64 (packages-microsoft-com-prod)
           Requires: unixODBC >= 2.3.1
           Available: unixODBC-2.2.14-14.7.amzn1.i686 (amzn-main)
               unixODBC = 2.2.14-14.7.amzn1

The error clearly says that to install msodbcsql, unixODBC version should be >= 2.3.1. 错误清楚地表明要安装msodbcsql,unixODBC版本应该> = 2.3.1。 But the updated/latest unixODBC package available for amazon is unixODBC-2.2.14. 但是亚马逊的更新/最新unixODBC软件包是unixODBC-2.2.14。

I need some help to install Microsoft Drivers for PHP on Amazon Linux so that I can use Sqlsrv PHP functions to connect SQL server. 我需要一些帮助来在Amazon Linux上安装Microsoft Drivers for PHP,以便我可以使用Sqlsrv PHP函数连接SQL服务器。

PHP7, Apache, and SQL server are already set up. 已经设置了PHP7,Apache和SQL服务器。

After googling and trying all the ways, I found the answer to my own question. 在谷歌上搜索并尝试了所有方法之后,我找到了自己问题的答案。

Instead of using 而不是使用

sudo ACCEPT_EULA=Y yum install msodbcsql mssql-tools

I used 我用了

sudo ACCEPT_EULA=Y yum install msodbcsql-13.0.1.0-1 mssql-tools-14.0.2.0-1

and the issue fixed. 并解决了这个问题。

If you are interested in msodbcsql17, you can follow this answer: 如果您对msodbcsql17感兴趣,可以按照以下答案操作:

Install unixODBC >= 2.3.1 on Linux Redhat/CentOS for msodbcsql17 在Linux Redhat / CentOS上为msodbcsql17安装unixODBC> = 2.3.1

The steps are the following: 步骤如下:

After a long time of research, I have figured out a solution: 经过长时间的研究,我找到了一个解决方案:

  1. Download the unixODBC >= 2.3.1 from any source, as rpm ( Example source ) 从任何来源下载unixODBC> = 2.3.1,如rpm( 示例源
  2. Download the msodbcsql17 and mssql-tool as rpm from Microsoft ( Link to Repo ) ( msodbcsql17-17.1.0.1-1.x86_64.rpm and mssql-tools-17.1.0.1-1.x86_64.rpm in my case) 从Microsoft下载msodbcsql17和mssql-tool作为rpm( 链接到Repo )(在我的情况下为msodbcsql17-17.1.0.1-1.x86_64.rpmmssql-tools-17.1.0.1-1.x86_64.rpm
  3. Transfer the files via ftp (like FileZilla) to the EC2 instance 通过ftp(如FileZilla)将文件传输到EC2实例
  4. Use EC2 terminal and go to the directory of the uploaded files 使用EC2终端并转到上传文件的目录
  5. Enter sudo rpm -i unixODBC-2.3.1-11.el7.x86_64.rpm to install the necessary version (Perhaps, you have to change the version number to the version number of the uploaded file) 输入sudo rpm -i unixODBC-2.3.1-11.el7.x86_64.rpm以安装必要的版本(也许,您必须将版本号更改为上载文件的版本号)
  6. Enter sudo rpm -i msodbcsql17-17.1.0.1-1.x86_64.rpm 输入sudo rpm -i msodbcsql17-17.1.0.1-1.x86_64.rpm
  7. Enter sudo rpm -i mssql-tools-17.1.0.1-1.x86_64.rpm 输入sudo rpm -i mssql-tools-17.1.0.1-1.x86_64.rpm

  8. Follow the rest of the Microsoft instruction, like in your question. 按照Microsoft指令的其余部分进行操作,就像您的问题一样。

  9. Now you should be able to use ODBC for example with pyodbc in python. 现在你应该可以在python中使用ODBC和pyodbc了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM