分类:PHP 发布时间:2024-06-10 22:04:48
## Version Ubuntu 20.04.5 LTS Microsoft SQL Server 2012–11.0.2100.60 (X64) OpenSSL 1.1.1f ## Install PHP ``` sudo su add-apt-repository ppa:ondrej/php -y apt-get update apt-get install php8.1 php8.1-dev php8.1-cli php8.1-fpm php8.1-xml -y --allow-unauthenticated ``` ## Install the Microsoft ODBC driver for SQL Server ``` #!/bin/bash if ! [[ "18.04 20.04 22.04" == *"$(lsb_release -rs)"* ]]; then echo "Ubuntu $(lsb_release -rs) is not currently supported."; exit; fi sudo curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add - sudo curl https://packages.microsoft.com/config/ubuntu/$(lsb_release -rs)/prod.list > /etc/apt/sources.list.d/mssql-release.list sudo apt-get update sudo ACCEPT_EULA=Y apt-get install -y msodbcsql18 # optional: for bcp and sqlcmd sudo ACCEPT_EULA=Y apt-get install -y mssql-tools18 echo 'export PATH="$PATH:/opt/mssql-tools18/bin"' >> ~/.bashrc source ~/.bashrc # optional: for unixODBC development headers sudo apt-get install -y unixodbc-dev ``` ## Install the PHP drivers for Microsoft SQL Server ``` sudo pecl config-set php_ini /etc/php/8.1/fpm/php.ini sudo pecl install sqlsrv sudo pecl install pdo_sqlsrv sudo printf "; priority=20\nextension=sqlsrv.so\n" > /etc/php/8.1/mods-available/sqlsrv.ini sudo printf "; priority=30\nextension=pdo_sqlsrv.so\n" > /etc/php/8.1/mods-available/pdo_sqlsrv.ini sudo phpenmod -v 8.1 sqlsrv pdo_sqlsrv ```
搜索
文章分类
最新文章