如何在 Elastic Beanstalk 上安装适用于 SQL Server 的 Microsoft ODBC 驱动程序
我是这个云服务的新手,最近我尝试在 Elastic Beanstalk 上使用 Microsoft SQL Server 部署我的 PHP 项目。当我运行它时,它说:
此扩展需要 Microsoft ODBC Driver for SQL Server。访问以下 URL 以下载适用于 x64 的 SQL Server 的 ODBC 驱动程序:https://go。 microsoft.com/fwlink/?LinkId=163712
我已经尝试使用放在 .ebextensions/pdo_sqlsrv.config 中的配置来安装 ODBC。
###################################################################################################
#### Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
####
#### Permission is hereby granted, free of charge, to any person obtaining a copy of this
#### software and associated documentation files (the "Software"), to deal in the Software
#### without restriction, including without limitation the rights to use, copy, modify,
#### merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
#### permit persons to whom the Software is furnished to do so.
###################################################################################################
###################################################################################################
#### THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
#### INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
#### PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
#### HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
#### OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
#### SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
###################################################################################################
commands:
install_mssql:
command: |
#!/bin/bash
# 0. EXIT if pdo_sqlsrv is already installed
if php -m | grep -q 'pdo_sqlsrv'
then
echo 'pdo_sqlsrv is already installed'
else
# 1. Register the Microsoft Linux repository
wget https://packages.microsoft.com/config/rhel/8/prod.repo -O /etc/yum.repos.d/msprod.repo
# 2. Install MSSQL and tools
ACCEPT_EULA=N yum install mssql-tools msodbcsql17 unixODBC-devel -y --disablerepo=amzn*
sudo yum install unixODBC-utf16
# The license terms for this product can be downloaded from http://go.microsoft.com/fwlink/?LinkId=746949 and found in /usr/share/doc/mssql-tools/LICENSE.txt . By changing "ACCEPT_EULA=N" to "ACCEPT_EULA=Y", you indicate that you accept the license terms.
echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bash_profile
echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bashrc
source ~/.bashrc
# 3. Install SQLSRV and its PDO extension, and stop pecl/pecl7 from overwriting php.ini
cp -f "/etc/php.ini" "/tmp/php.ini.bk"
pecl7 install sqlsrv pdo_sqlsrv || pecl install sqlsrv pdo_sqlsrv
cp -f "/tmp/php.ini.bk" "/etc/php.ini"
# 4. Manually add the extensions to the proper php.ini.d file and fix parameters
sqlvar=$(php -r "echo ini_get('extension_dir');") && chmod 0755 $sqlvar/sqlsrv.so && chmod 0755 $sqlvar/pdo_sqlsrv.so
echo extension=pdo_sqlsrv.so >> `php --ini | grep "Scan for additional .ini files" | sed -e "s|.*:\s*||"`/30-pdo_sqlsrv.ini
echo extension=sqlsrv.so >> `php --ini | grep "Scan for additional .ini files" | sed -e "s|.*:\s*||"`/20-sqlsrv.ini
fi
curl https://packages.microsoft.com/config/rhel/7/prod.repo | sudo tee /etc/yum.repos.d/msprod.repo1
sudo yum remove unixODBC-utf16 unixODBC-utf16-devel
sudo yum info unixODBC*
sudo yum install mssql-tools unixODBC-devel
echo 'export PATH="$PATH:/opt/mssql-tools/bin"' | tee -a ~/.bash_profile && source ~/.bash_profile
我一直在搜索并尝试任何命令来安装 ODBC,但仍然不起作用。有没有办法在 Elastic Beanstalk 上安装 ODBC for SQL Server?
I'm new to this cloud services and recently I'm trying to deploy my PHP project using Microsoft SQL Server on Elastic Beanstalk. When I run it, it says :
This extension requires the Microsoft ODBC Driver for SQL Server. Access the following URL to download the ODBC Driver for SQL Server for x64: https://go.microsoft.com/fwlink/?LinkId=163712
I already tried to install ODBC with config that I put at .ebextensions/pdo_sqlsrv.config.
###################################################################################################
#### Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
####
#### Permission is hereby granted, free of charge, to any person obtaining a copy of this
#### software and associated documentation files (the "Software"), to deal in the Software
#### without restriction, including without limitation the rights to use, copy, modify,
#### merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
#### permit persons to whom the Software is furnished to do so.
###################################################################################################
###################################################################################################
#### THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
#### INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
#### PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
#### HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
#### OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
#### SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
###################################################################################################
commands:
install_mssql:
command: |
#!/bin/bash
# 0. EXIT if pdo_sqlsrv is already installed
if php -m | grep -q 'pdo_sqlsrv'
then
echo 'pdo_sqlsrv is already installed'
else
# 1. Register the Microsoft Linux repository
wget https://packages.microsoft.com/config/rhel/8/prod.repo -O /etc/yum.repos.d/msprod.repo
# 2. Install MSSQL and tools
ACCEPT_EULA=N yum install mssql-tools msodbcsql17 unixODBC-devel -y --disablerepo=amzn*
sudo yum install unixODBC-utf16
# The license terms for this product can be downloaded from http://go.microsoft.com/fwlink/?LinkId=746949 and found in /usr/share/doc/mssql-tools/LICENSE.txt . By changing "ACCEPT_EULA=N" to "ACCEPT_EULA=Y", you indicate that you accept the license terms.
echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bash_profile
echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bashrc
source ~/.bashrc
# 3. Install SQLSRV and its PDO extension, and stop pecl/pecl7 from overwriting php.ini
cp -f "/etc/php.ini" "/tmp/php.ini.bk"
pecl7 install sqlsrv pdo_sqlsrv || pecl install sqlsrv pdo_sqlsrv
cp -f "/tmp/php.ini.bk" "/etc/php.ini"
# 4. Manually add the extensions to the proper php.ini.d file and fix parameters
sqlvar=$(php -r "echo ini_get('extension_dir');") && chmod 0755 $sqlvar/sqlsrv.so && chmod 0755 $sqlvar/pdo_sqlsrv.so
echo extension=pdo_sqlsrv.so >> `php --ini | grep "Scan for additional .ini files" | sed -e "s|.*:\s*||"`/30-pdo_sqlsrv.ini
echo extension=sqlsrv.so >> `php --ini | grep "Scan for additional .ini files" | sed -e "s|.*:\s*||"`/20-sqlsrv.ini
fi
curl https://packages.microsoft.com/config/rhel/7/prod.repo | sudo tee /etc/yum.repos.d/msprod.repo1
sudo yum remove unixODBC-utf16 unixODBC-utf16-devel
sudo yum info unixODBC*
sudo yum install mssql-tools unixODBC-devel
echo 'export PATH="$PATH:/opt/mssql-tools/bin"' | tee -a ~/.bash_profile && source ~/.bash_profile
I've been searching and trying any command to install the ODBC, but still not working. Is there any way to install ODBC for SQL Server on Elastic Beanstalk?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
感谢@Marcin,我可以解决这个问题。
为了解决这个问题,我只需要 ssh 实例并手动执行配置中的命令即可。
Thanks to @Marcin, I can solve this.
To solve this problem, I just need to ssh the instance and execute the command in the config manually.
我有同样的问题,手动运行。不幸的是,如果AWS建立了一个新服务器,这将不会被保存,所以仍然试图找出如何自动化它,因为“配置”文件不起作用
I had the same issue, ran this manually. Unfortunately this wont be saved if AWS stands up a new server so still trying to figure out how to automate it as a "config" file doesn't work