我正在尝试在platform.sh上设置Microsoft驱动程序,以便我可以使用PDO_SQLSRV和SQLSRV扩展。apt和其他sudo命令是有限的。但是,在构建过程中,我可以设置环境变量,如LD_LIBRARY_PATH。
以下是我迄今所尝试过的。
export LD_LIBRARY_PATH="($pwd):$LD_LIBRARY_PATH"和LD_LIBRARY_PATH="($pwd):$LD_LIBRARY_PATH" /usr/sbin/php-fpm7.0尽管如此,我还是得到了以下错误:
SQLSTATE[IMSSP]: This extension requires the Microsoft ODBC Driver 13
for SQL Server to communicate with SQL Server. Access the following
URL to download the ODBC Driver 13 for SQL Server for x86:
http://go.microsoft.com/fwlink/?LinkId=163712更新
当我执行LD_LIBRARY_PATH=$(pwd) ldd libmsodbcsql-13.1.so.4.0时,所有依赖项都会满足。但是,当我使用LD_LIBRARY_PATH="$(pwd):$LD_LIBRARY_PATH" /usr/sbin/php-fpm7.0启动时,我仍然会看到上面显示的错误。
发布于 2017-02-09 16:57:43
我猜你的扩展链接到了错误的库。
也就是说,您不需要自定义扩展。您可以将此添加到您的.platform.app.yaml中。
runtime:
extensions:
- mssql有关详细信息,请参阅此页。
发布于 2017-02-22 12:11:18
将FreeTDS用于MSSQL驱动程序。理想情况下,您将需要sudo特权。尽管有特定于用户的ODBC配置文件是可能的,但如果还没有安装基本软件,则仍然需要安装它。
sudo apt-get install freetds-common freetds-bin unixodbc tdsodbc php5-odbc php5-sybase将连接添加到:/etc/freetds/freetds.conf
[global]
text size = 64512
[my_connection]
host = SQL_HOSTNAME
port = SQL PORT - possibly 1433
tds_version = 7.2
encryption = required将FreeTDS添加到ODBC驱动程序列表:/etc/odbcinst.ini
[odbc]
Description = ODBC driver
Driver = /usr/lib/x86_64-linux-gnu/odbc/libtdsodbc.so
Setup = /usr/lib/x86_64-linux-gnu/odbc/libtdsS.so
[FreeTDS]
Description = FreeTDS
Driver = /usr/lib/x86_64-linux-gnu/odbc/libtdsodbc.so最后,将FreeTDS连接添加到ODBC配置中:/etc/odbc.ini,ServerName必须与FreeTDS中使用的连接匹配
[my_connection]
Driver = FreeTDS
Description = Uses FreeTDS configuration settings defined in /etc/freetds/freetds.conf
Servername = my_connection
TDS_Version = 7.2
[Default]
Driver = FreeTDS现在,您将能够在ODBC或FreeTDS驱动程序中使用PDO。
直接使用FreeTDS
$pdo = new PDO($'dblib:host=my_connection', 'username', 'password');或通过FreeTDS使用ODBC
$pdo = new PDO('odbc=my_connection', 'username', 'password');您可能会发现这两个驱动程序的特性略有不同,所以请使用最适合您所使用的查询的驱动程序。
https://stackoverflow.com/questions/42095009
复制相似问题