3 回答
TA贡献2016条经验 获得超9个赞
Merlin Liang 的回答对我来说是一个很大的启发,但我仍然努力让 SQLSRV 被 Composer 接受。
首先,我必须修改一些像 David Legatt 提到的路径。第二个问题是我试图修改并重新启动 FPM。关键是删除重启部分并修改 CLI,而不是 FPM。
试试这个,对我有用:
- script: sudo apt-get update
displayName: 'Update apt package tool'
- script: |
curl -s https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add -
sudo bash -c "curl -s https://packages.microsoft.com/config/ubuntu/16.04/prod.list > /etc/apt/sources.list.d/mssql-release.list"
sudo ACCEPT_EULA=Y apt-get -y install msodbcsql17 mssql-tools
sudo apt-get -y install unixodbc-dev
displayName: 'SqlSrv prerequisites install'
- script: |
sudo apt-get -y install gcc g++ make autoconf libc-dev pkg-config
sudo apt-get install php-pear php-dev
sudo pecl config-set php_ini /etc/php/7.3/fpm/php.ini
displayName: 'PECL install'
- script: |
sudo pecl install sqlsrv
sudo pecl install pdo_sqlsrv
displayName: 'SqlSrv extension install'
- script: |
sudo bash -c "echo extension=/usr/lib/php/20180731/sqlsrv.so > /etc/php/7.3/cli/conf.d/sqlsrv.ini"
sudo bash -c "echo extension=/usr/lib/php/20180731/pdo_sqlsrv.so > /etc/php/7.3/cli/conf.d/pdo_sqlsrv.ini"
displayName: 'SQLSRV modify ini files'
TA贡献1851条经验 获得超4个赞
如何配置我的 azure-pipelines.yml 脚本以包含它?
作为atymic说,你需要安装PHP Extension Community Library(pecl)有PEAR第一。请尝试在Use PHP version $(phpVersion)任务之前运行以下脚本:
- script: |
curl -s https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add -
sudo bash -c "curl -s https://packages.microsoft.com/config/ubuntu/16.04/prod.list > /etc/apt/sources.list.d/mssql-release.list"
sudo apt-get update
sudo ACCEPT_EULA=Y apt-get -y install msodbcsql17 mssql-tools
sudo apt-get -y install unixodbc-dev
- script: |
sudo apt-get -y install gcc g++ make autoconf libc-dev pkg-config
sudo apt-get install php-pear php-dev
sudo pecl install sqlsrv
sudo pecl install pdo_sqlsrv
- script: |
sudo bash -c "echo extension=sqlsrv.so > /etc/php7.X-sp/conf.d/sqlsrv.ini"
sudo bash -c "echo extension=pdo_sqlsrv.so > /etc/php7.X-sp/conf.d/pdo_sqlsrv.ini"
sudo service php7.X-fpm-sp restart
第一个脚本用于安装先决条件sqlsrv。第二个用于安装扩展。然后,一旦安装,运行第三个脚本任务来为这个扩展创建配置文件,并重新启动你的 PHP。
TA贡献1852条经验 获得超7个赞
对于那些正在寻找正在运行的 yaml 文件来执行带有 sqlsrv 扩展名的 php 单元测试的人。选择 phpVersion 7.4 很重要。因为最新的 sqlsrv 模块是用比 php 7.3 更新的 php api 编译的。
stages:
- stage: Build
displayName: Build stage
variables:
phpVersion: '7.4'
jobs:
- job: BuildJob
pool:
vmImage: $(vmImageName)
steps:
- script: |
sudo update-alternatives --set php /usr/bin/php$(phpVersion)
sudo update-alternatives --set phar /usr/bin/phar$(phpVersion)
sudo update-alternatives --set phpdbg /usr/bin/phpdbg$(phpVersion)
sudo update-alternatives --set php-cgi /usr/bin/php-cgi$(phpVersion)
sudo update-alternatives --set phar.phar /usr/bin/phar.phar$(phpVersion)
php -version
workingDirectory: $(rootFolder)
displayName: 'Use PHP version $(phpVersion)'
- script: php -i | grep "Loaded Configuration File"
workingDirectory: $(rootFolder)
displayName: 'Get Ini location'
- script: composer install --no-interaction --prefer-dist
workingDirectory: $(rootFolder)
displayName: 'Composer install'
- script: sudo apt-get update
displayName: 'Update apt package tool'
- script: |
curl -s https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add -
sudo bash -c "curl -s https://packages.microsoft.com/config/ubuntu/18.04/prod.list > /etc/apt/sources.list.d/mssql-release.list"
sudo ACCEPT_EULA=Y apt-get -y install msodbcsql17 mssql-tools
sudo apt-get -y install unixodbc-dev
displayName: 'SqlSrv prerequisites install'
- script: |
sudo apt-get -y install gcc g++ make autoconf libc-dev pkg-config
sudo apt-get install php-pear php-dev
sudo pecl config-set php_ini /etc/php/7.4/fpm/php.ini
displayName: 'PECL install'
- script: |
sudo pecl install sqlsrv
sudo pecl install pdo_sqlsrv
displayName: 'SqlSrv extension install'
- script: |
sudo bash -c "echo extension=/usr/lib/php/20190902/sqlsrv.so > /etc/php/7.4/cli/conf.d/99-sqlsrv.ini"
sudo bash -c "echo extension=/usr/lib/php/20190902/pdo_sqlsrv.so > /etc/php/7.4/cli/conf.d/99-sqlsrv.ini"
displayName: 'SQLSRV modify ini files'
- script: vendor/bin/phpunit
workingDirectory: $(rootFolder)
displayName: 'Run PHP tests with phpunit'
- 3 回答
- 0 关注
- 169 浏览
添加回答
举报