如何在 Elastic Beanstalk 上为 SQL 服务器安装 Microsoft ODBC 驱动程序
How to Install Microsoft ODBC Driver for SQL Server on Elastic Beanstalk
我是这个云服务的新手,最近我正在尝试使用 Microsoft SQL 服务器在 Elastic Beanstalk 上部署我的 PHP 项目。当我 运行 它时,它说:
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
我已经尝试使用我放在 .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 上为 SQL 服务器安装 ODBC?
感谢@Marcin,我可以解决这个问题。
为了解决这个问题,我只需要ssh实例并手动执行配置中的命令即可。
我是这个云服务的新手,最近我正在尝试使用 Microsoft SQL 服务器在 Elastic Beanstalk 上部署我的 PHP 项目。当我 运行 它时,它说:
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
我已经尝试使用我放在 .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 上为 SQL 服务器安装 ODBC?
感谢@Marcin,我可以解决这个问题。
为了解决这个问题,我只需要ssh实例并手动执行配置中的命令即可。