问题
I am trying to install Microsoft Drivers for PHP for SQL Server using the document provided by Microsoft. Link is https://github.com/Microsoft/msphpsql
It provides installation steps for Ubuntu and Redhat but not Amazon Linux. To install Microsoft Drivers on Amazon, I followed steps provided for Redhat ( not sure if it is correct). 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. But the updated/latest unixODBC package available for amazon is 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.
PHP7, Apache, and SQL server are already set up.
回答1:
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.
回答2:
If you are interested in msodbcsql17, you can follow this answer:
Install unixODBC >= 2.3.1 on Linux Redhat/CentOS for msodbcsql17
The steps are the following:
After a long time of research, I have figured out a solution:
- Download the unixODBC >= 2.3.1 from any source, as rpm (Example source)
- 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)
- Transfer the files via ftp (like FileZilla) to the EC2 instance
- Use EC2 terminal and go to the directory of the uploaded files
- 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)- Enter
sudo rpm -i msodbcsql17-17.1.0.1-1.x86_64.rpm
Enter
sudo rpm -i mssql-tools-17.1.0.1-1.x86_64.rpm
Follow the rest of the Microsoft instruction, like in your question.
- Now you should be able to use ODBC for example with pyodbc in python.
来源:https://stackoverflow.com/questions/44141081/how-to-install-microsoft-drivers-for-php-for-sql-server-on-amazon-linux-ami