Mac In Microsoft Sql Server
2018-5-8 最近在学数据库,老师用的是Microsoft sql server2008,请问用navicat premium设计的数据库分离出来老师 最近在学数据库,老师用的是Microsoft sql server2008,请问用navicat premium设计的数据库分离出来老师能用Microsoft sql server查看吗 显示全部. Jun 21, 2016 I am having trouble connecting to a SQL Server via the new Excel 2016 for Mac SQL Server ODBC New Database Query feature. I tried to follow the Office Support info available on this link. Get started with SQL Server 2019 on Azure Virtual Machines in minutes with preconfigured images on Linux and Windows. Take advantage of unique built-in security and manageability to automate tasks like patching and backups, and save with Azure Hybrid Benefit by reusing your existing on-premises licenses. 2020-4-3 使用 SQL Server 2019 大数据群集查询所有类型的数据 使用大数据群集更轻松地管理大数据环境。它们提供了数据湖的关键元素(Hadoop 分布式文件系统 (HDFS)、Apache Spark 和分析工具),与 SQL Server 深度集成,并得到 Microsoft 的完全支持。. 2019-9-26 When I wrote that, SQL Server 2017 was the latest version of SQL Server, and it had just been made available for Linux and Docker (which means that you can also install it on MacOS systems). In late 2018, Microsoft announced SQL Server 2019 Preview, and subsequently announced general release in late 2019. Microsoft sql server 2008 free download - Microsoft Office 2008 update, Actual ODBC SQL Server driver, MySQL Database Server, and many more programs.
Install the Microsoft ODBC driver for SQL Server (macOS); 2 minutes to read; In this article. This article explains how to install the Microsoft ODBC Driver for SQL Server on macOS. It also includes instructions for the optional command-line tools for SQL Server (bcp and sqlcmd) and the unixODBC development headers.
-->以下说明假定一个干净的环境,并演示如何在 Ubuntu 16.04、18.04 和 19.10、RedHat 7 和 8、Debian 8、9 和 10、Suse 12 和 15、Alpine 3.11(实验版)以及 macOS 10.13、10.14 和 10.15 上安装 PHP 7.x、Microsoft ODBC 驱动程序、Apache Web 服务器和 Microsoft Drivers for PHP for SQL Server。The following instructions assume a clean environment and show how to install PHP 7.x, the Microsoft ODBC driver, the Apache web server, and the Microsoft Drivers for PHP for SQL Server on Ubuntu 16.04, 18.04, and 19.10, RedHat 7 and 8, Debian 8, 9, and 10, Suse 12 and 15, Alpine 3.11 (experimental), and macOS 10.13, 10.14, and 10.15.这些说明建议使用 PECL 安装驱动程序,但也可以从 Microsoft Drivers for PHP for SQL Server GitHub 项目页下载预生成的二进制文件,并按照下载 Microsoft Drivers for PHP for SQL Server 中的说明安装它们。These instructions advise installing the drivers using PECL, but you can also download the prebuilt binaries from the Microsoft Drivers for PHP for SQL Server GitHub project page and install them following the instructions in Loading the Microsoft Drivers for PHP for SQL Server.有关扩展加载以及为什么不将扩展添加到 php.ini 的说明,请参阅加载驱动程序部分。For an explanation of extension loading and why we do not add the extensions to php.ini, see the section on loading the drivers.
默认情况下,这些说明安装 PHP 7.4。These instructions install PHP 7.4 by default.注意,一些受支持的 Linux 发行版默认为 PHP 7.1 或更早版本,而 SQL Server 的 PHP 驱动程序的最新版本不支持这些版本,请参阅每一节开头的说明,以安装 PHP 7.2 或 7.3。Note that some supported Linux distros default to PHP 7.1 or earlier, which is not supported for the latest version of the PHP drivers for SQL Server -- please see the notes at the beginning of each section to install PHP 7.2 or 7.3 instead.
还包括有关在 Ubuntu 上安装 PHP FastCGI 进程管理器 (PHP-FPM) 的说明。Also included are instructions for installing the PHP FastCGI Process Manager, PHP-FPM, on Ubuntu.如果使用的是 nginx Web 服务器而不是 Apache,则需要此服务。This is needed if using the nginx web server instead of Apache.
此页的内容:Contents of this page:
在 Ubuntu 16.04、18.04 和 19.10 上安装驱动程序Installing the drivers on Ubuntu 16.04, 18.04, and 19.10
备注
若要安装 PHP 7.2 或 7.3,请使用以下命令将 7.4 替换为 7.2 或 7.3。To install PHP 7.2 or 7.3, replace 7.4 with 7.2 or 7.3 in the following commands.
步骤 1。Step 1.安装 PHPInstall PHP
步骤 2.Step 2.安装先决条件Install prerequisites
按照“Linux 安装”一文中的说明安装适用于 Ubuntu 的 ODBC 驱动程序。Install the ODBC driver for Ubuntu by following the instructions on the Linux installation article.
步骤 3.Step 3.安装适用于 Microsoft SQL Server 的 PHP 驱动程序Install the PHP drivers for Microsoft SQL Server
如果系统中只有一个 PHP 版本,则可以将最后一个步骤简化为 phpenmod sqlsrv pdo_sqlsrv
。If there is only one PHP version in the system, then the last step can be simplified to phpenmod sqlsrv pdo_sqlsrv
.
步骤 4.Step 4.安装 Apache 并配置驱动程序加载Install Apache and configure driver loading
步骤 5。Step 5.重启 Apache 并测试示例脚本Restart Apache and test the sample script
若要测试安装,请参阅本文档末尾的测试安装。To test your installation, see Testing your installation at the end of this document.
在 Ubuntu 上安装带有 PHP-FPM 的驱动程序Installing the drivers with PHP-FPM on Ubuntu
备注
若要安装 PHP 7.2 或 7.3,请使用以下命令将 7.4 替换为 7.2 或 7.3。To install PHP 7.2 or 7.3, replace 7.4 with 7.2 or 7.3 in the following commands.
步骤 1。Step 1.安装 PHPInstall PHP
通过运行验证 PHP-FPM 服务的状态Verify the status of the PHP-FPM service by running
步骤 2.Step 2.安装先决条件Install prerequisites
按照“Linux 安装”一文中的说明安装适用于 Ubuntu 的 ODBC 驱动程序。Install the ODBC driver for Ubuntu by following the instructions on the Linux installation article.
步骤 3.Step 3.安装适用于 Microsoft SQL Server 的 PHP 驱动程序Install the PHP drivers for Microsoft SQL Server
如果系统中只有一个 PHP 版本,则可以将最后一个步骤简化为 phpenmod sqlsrv pdo_sqlsrv
。If there is only one PHP version in the system, then the last step can be simplified to phpenmod sqlsrv pdo_sqlsrv
.
验证 sqlsrv.ini
和 pdo_sqlsrv.ini
是否位于 /etc/php/7.4/fpm/conf.d/
:Verify that sqlsrv.ini
and pdo_sqlsrv.ini
are located in /etc/php/7.4/fpm/conf.d/
:
重新启动 PHP-FPM 服务:Restart the PHP-FPM service:
步骤 4.Step 4.安装并配置 nginxInstall and configure nginx
若要配置 nginx,必须编辑 /etc/nginx/sites-available/default
文件。To configure nginx, you must edit the /etc/nginx/sites-available/default
file.将 index.php
添加到指示 # Add index.php to the list if you are using PHP
的部分下的列表中:Add index.php
to the list below the section that says # Add index.php to the list if you are using PHP
:
接下来,修改以下 # pass PHP scripts to FastCGI server
部分,如下所示:Next, modify the section following # pass PHP scripts to FastCGI server
as follows:
步骤 5。Step 5.重启 nginx 并测试示例脚本Restart nginx and test the sample script
若要测试安装,请参阅本文档末尾的测试安装。To test your installation, see Testing your installation at the end of this document.
在 Red Hat 7 和 8 上安装驱动程序Installing the drivers on Red Hat 7 and 8
步骤 1。Step 1.安装 PHPInstall PHP
若要在 Red Hat 7 上安装 PHP,请运行以下命令:To install PHP on Red Hat 7, run the following:
备注
若要安装 PHP 7.2 或 7.3,请在以下命令中分别用 remi- php72 或 remi-php73 替换 remi-php74。To install PHP 7.2 or 7.3, replace remi-php74 with remi-php72 or remi-php73 respectively in the following commands.
若要在 Red Hat 8 上安装 PHP,请运行以下命令:To install PHP on Red Hat 8, run the following:
备注
若要安装 PHP 7.2 或7.3,请在以下命令中分别用 remi-7.2 或 remi-7.3 替换 remi-7.4。To install PHP 7.2 or 7.3, replace remi-7.4 with remi-7.2 or remi-7.3 respectively in the following commands.
步骤 2.Step 2.安装先决条件Install prerequisites
按照“Linux 安装”一文中的说明安装适用于 Red Hat 7 或 8 的 ODBC 驱动程序。Install the ODBC driver for Red Hat 7 or 8 by following the instructions on the Linux installation article.
步骤 3.Step 3.安装适用于 Microsoft SQL Server 的 PHP 驱动程序Install the PHP drivers for Microsoft SQL Server
也可以从 Remi 存储库进行安装:You can alternatively install from the Remi repo:
步骤 4.Step 4.安装 ApacheInstall Apache
默认安装 SELinux,并在强制模式下运行。SELinux is installed by default and runs in Enforcing mode.若要允许 Apache SELinux 通过连接到数据库,请运行以下命令:To allow Apache to connect to databases through SELinux, run the following command:
步骤 5。Step 5.重启 Apache 并测试示例脚本Restart Apache and test the sample script
若要测试安装,请参阅本文档末尾的测试安装。To test your installation, see Testing your installation at the end of this document.
在 Debian 8、9 和 10 上安装驱动程序Installing the drivers on Debian 8, 9, and 10
备注
若要安装 PHP 7.2 或 7.3,请使用以下命令将 7.4 替换为 7.2 或 7.3。To install PHP 7.2 or 7.3, replace 7.4 in the following commands with 7.2 or 7.3.
步骤 1。Step 1.安装 PHPInstall PHP
步骤 2.Step 2.安装先决条件Install prerequisites
按照“Linux 安装”一文中的说明安装适用于 Debian 的 ODBC 驱动程序。Install the ODBC driver for Debian by following the instructions on the Linux installation article.
可能还需要生成正确的区域设置,以使 PHP 输出在浏览器中正确显示。You may also need to generate the correct locale to get PHP output to display correctly in a browser.例如,对于 en_US UTF-8 区域设置,运行以下命令:For example, for the en_US UTF-8 locale, run the following commands:
可能需要将 /usr/sbin
添加到 $PATH
中,因为 locale-gen
可执行文件位于该位置。You may need to add /usr/sbin
to your $PATH
, as the locale-gen
executable is located there.
步骤 3.Step 3.安装适用于 Microsoft SQL Server 的 PHP 驱动程序Install the PHP drivers for Microsoft SQL Server
如果系统中只有一个 PHP 版本,则可以将最后一个步骤简化为 phpenmod sqlsrv pdo_sqlsrv
。If there is only one PHP version in the system, then the last step can be simplified to phpenmod sqlsrv pdo_sqlsrv
.与 locale-gen
一样,phpenmod
位于 /usr/sbin
中,因此可能需要将此目录添加到 $PATH
。As with locale-gen
, phpenmod
is located in /usr/sbin
so you may need to add this directory to your $PATH
.
步骤 4.Step 4.安装 Apache 并配置驱动程序加载Install Apache and configure driver loading
步骤 5。Step 5.重启 Apache 并测试示例脚本Restart Apache and test the sample script
若要测试安装,请参阅本文档末尾的测试安装。To test your installation, see Testing your installation at the end of this document.
在 Suse 12 和 15 上安装驱动程序Installing the drivers on Suse 12 and 15
备注
在下面的说明中,将 <SuseVersion>
替换为 Suse 版本,如果使用的是 Suse Enterprise Linux 15,它将是 SLE_15 或 SLE_15_SP1。In the following instructions, replace <SuseVersion>
with your version of Suse - if you are using Suse Enterprise Linux 15, it will be SLE_15 or SLE_15_SP1.对于 Suse 12,请使用 SLE_12_SP4(或更高版本,如果适用)。For Suse 12, use SLE_12_SP4 (or above if applicable).并不是所有版本的 PHP 都适用于所有版本的 Suse Linux,请参阅 http://download.opensuse.org/repositories/devel:/languages:/php
以查看哪些版本的 Suse 具有默认版本的 PHP 可用,或者参阅 http://download.opensuse.org/repositories/devel:/languages:/php:/
查看哪些其他版本的 PHP 可用于哪些版本的 Suse。Not all versions of PHP are available for all versions of Suse Linux - please refer to http://download.opensuse.org/repositories/devel:/languages:/php
to see which versions of Suse have the default version PHP available, or to http://download.opensuse.org/repositories/devel:/languages:/php:/
to see which other versions of PHP are available for which versions of Suse.
备注
PHP 7.4 的包不可用于 Suse 12。Packages for PHP 7.4 are not available for Suse 12.若要安装 PHP 7.2,用以下 URL 替换下面的存储库 URL:https://download.opensuse.org/repositories/devel:/languages:/php:/php72/<SuseVersion>/devel:languages:php:php72.repo
。To install PHP 7.2, replace the repository URL below with the following URL: https://download.opensuse.org/repositories/devel:/languages:/php:/php72/<SuseVersion>/devel:languages:php:php72.repo
.若要安装 PHP 7.3,用以下 URL 替换下面的存储库 URL:https://download.opensuse.org/repositories/devel:/languages:/php:/php73/<SuseVersion>/devel:languages:php:php73.repo
。To install PHP 7.3, replace the repository URL below with the following URL: https://download.opensuse.org/repositories/devel:/languages:/php:/php73/<SuseVersion>/devel:languages:php:php73.repo
.
步骤 1。Step 1.安装 PHPInstall PHP
步骤 2.Step 2.安装先决条件Install prerequisites
按照“Linux 安装”一文中的说明安装适用于 Suse 的 ODBC 驱动程序。Install the ODBC driver for Suse by following the instructions on the Linux installation article.
步骤 3.Step 3.安装适用于 Microsoft SQL Server 的 PHP 驱动程序Install the PHP drivers for Microsoft SQL Server
备注
如果收到错误消息 Connection to 'pecl.php.net:443' failed: Unable to find the socket transport 'ssl'
,请编辑 /usr/bin/pecl 中的 pecl 脚本并删除最后一行的 -n
开关。If you get an error message saying Connection to 'pecl.php.net:443' failed: Unable to find the socket transport 'ssl'
, edit the pecl script at /usr/bin/pecl and remove the -n
switch in the last line.此开关可防止 PECL 在调用 PHP 时加载 ini 文件,从而防止加载 OpenSSL 扩展。This switch prevents PECL from loading ini files when PHP is called, which prevents the OpenSSL extension from loading.
步骤 4.Step 4.安装 Apache 并配置驱动程序加载Install Apache and configure driver loading
步骤 5。Step 5.重启 Apache 并测试示例脚本Restart Apache and test the sample script
Sql On Mac
若要测试安装,请参阅本文档末尾的测试安装。To test your installation, see Testing your installation at the end of this document.
在 Alpine 3.11 上安装驱动程序Installing the drivers on Alpine 3.11
备注
PHP 的默认版本为 7.3。The default version of PHP is 7.3.Alpine 3.11 的其他存储库中不提供 PHP 的备用版本。Alternate versions of PHP are not available from other repositories for Alpine 3.11.可以改为从源编译 PHP。You can instead compile PHP from source.
步骤 1。Step 1.安装 PHPInstall PHP
edge/community
存储库中提供了用于 Alpine 的 PHP 包。PHP packages for Alpine are found in the edge/community
repository.将以下行添加到 /etc/apt/repositories
,并将 <mirror>
替换为 Alpine 存储库镜像的 URL:Add the following line to /etc/apt/repositories
, replacing <mirror>
with the URL of an Alpine repository mirror:
然后运行:Then run:
步骤 2.Step 2.安装先决条件Install prerequisites
按照“Linux 安装”一文中的说明安装适用于 Alpine 的 ODBC 驱动程序。Install the ODBC driver for Alpine by following the instructions on the Linux installation article.
步骤 3.Step 3.安装适用于 Microsoft SQL Server 的 PHP 驱动程序Install the PHP drivers for Microsoft SQL Server
可能需要定义区域设置:You may need to define a locale:
步骤 4.Step 4.安装 Apache 并配置驱动程序加载Install Apache and configure driver loading
步骤 5。Step 5.重启 Apache 并测试示例脚本Restart Apache and test the sample script
若要测试安装,请参阅本文档末尾的测试安装。To test your installation, see Testing your installation at the end of this document.
在 macOS High Sierra、Mojave 和 Catalina 上安装驱动程序Installing the drivers on macOS High Sierra, Mojave, and Catalina
如果还没有安装 brew,请按照以下步骤安装:If you do not already have it, install brew as follows:
备注
若要安装 PHP 7.2 或 7.3,请在以下命令中分别用 php@7.4 或 php@7.2 替换 php@7.3。To install PHP 7.2 or 7.3, replace php@7.4 with php@7.2 or php@7.3 respectively in the following commands.
步骤 1。Step 1.安装 PHPInstall PHP
PHP 现应在路径中 - 运行 php -v
以验证正在运行正确版本的 PHP。PHP should now be in your path -- run php -v
to verify that you are running the correct version of PHP.如果 PHP 不在路径中或版本不正确,则运行以下命令:If PHP is not in your path or it is not the correct version, run the following:
步骤 2.Step 2.安装先决条件Install prerequisites
按照“Linux 安装”一文中的说明安装适用于 macOS 的 ODBC 驱动程序。Install the ODBC driver for macOS by following the instructions on the macOS installation article.
此外,可能需要安装 GNU make 工具:In addition, you may need to install the GNU make tools:
步骤 3.Step 3.安装适用于 Microsoft SQL Server 的 PHP 驱动程序Install the PHP drivers for Microsoft SQL Server
步骤 4.Step 4.安装 Apache 并配置驱动程序加载Install Apache and configure driver loading
若要查找用于 Apache 安装的 Apache 配置文件 httpd.conf
,请运行To find the Apache configuration file, httpd.conf
, for your Apache installation, run
以下命令将所需的配置追加到 httpd.conf
。The following commands append the required configuration to httpd.conf
.请确保用上一个命令返回的路径替换 /usr/local/etc/httpd/httpd.conf
:Be sure to substitute the path returned by the preceding command in place of /usr/local/etc/httpd/httpd.conf
:
步骤 5。Step 5.重启 Apache 并测试示例脚本Restart Apache and test the sample script
若要测试安装,请参阅本文档末尾的测试安装。To test your installation, see Testing your installation at the end of this document.
测试安装Testing Your Installation
若要测试此示例脚本,请在系统的文档根目录中创建名为“testsql.php”的文件。To test this sample script, create a file called testsql.php in your system's document root.这在 Ubuntu、Debian 和 Redhat 上为 /var/www/html/
,在 SUSE 上为 /srv/www/htdocs
,在 macOS 上为 /var/www/localhost/htdocs
,在 macOS 上为 /usr/local/var/www
。This is /var/www/html/
on Ubuntu, Debian, and Redhat, /srv/www/htdocs
on SUSE, /var/www/localhost/htdocs
on Alpine, or /usr/local/var/www
on macOS.将以下脚本复制到其中,酌情替换服务器、数据库、用户名和密码。Copy the following script to it, replacing the server, database, username, and password as appropriate.在 Alpine 3.11 上,你可能还需要在 数组中将 CharacterSet$connectionOptions
指定为“UTF-8”。On Alpine 3.11, you may also need to specify the CharacterSet as 'UTF-8' in the $connectionOptions
array.
将浏览器指向 https://localhost/testsql.php (macOS 上的 https://localhost:8080/testsql.php )。Point your browser to https://localhost/testsql.php (https://localhost:8080/testsql.php on macOS).现在应能够连接到 SQL Server/Azure SQL 数据库。You should now be able to connect to your SQL Server/Azure SQL database.
另请参阅See Also
-->The following instructions assume a clean environment and show how to install PHP 7.x, the Microsoft ODBC driver, the Apache web server, and the Microsoft Drivers for PHP for SQL Server on Ubuntu 16.04, 18.04, and 19.10, RedHat 7 and 8, Debian 8, 9, and 10, Suse 12 and 15, Alpine 3.11 (experimental), and macOS 10.13, 10.14, and 10.15. These instructions advise installing the drivers using PECL, but you can also download the prebuilt binaries from the Microsoft Drivers for PHP for SQL Server GitHub project page and install them following the instructions in Loading the Microsoft Drivers for PHP for SQL Server. For an explanation of extension loading and why we do not add the extensions to php.ini, see the section on loading the drivers.
These instructions install PHP 7.4 by default. Note that some supported Linux distros default to PHP 7.1 or earlier, which is not supported for the latest version of the PHP drivers for SQL Server -- please see the notes at the beginning of each section to install PHP 7.2 or 7.3 instead.
Also included are instructions for installing the PHP FastCGI Process Manager, PHP-FPM, on Ubuntu. This is needed if using the nginx web server instead of Apache.
Contents of this page:
Installing the drivers on Ubuntu 16.04, 18.04, and 19.10
Note
To install PHP 7.2 or 7.3, replace 7.4 with 7.2 or 7.3 in the following commands.
Step 1. Install PHP
Step 2. Install prerequisites
Install the ODBC driver for Ubuntu by following the instructions on the Linux installation article.
Step 3. Install the PHP drivers for Microsoft SQL Server
If there is only one PHP version in the system, then the last step can be simplified to phpenmod sqlsrv pdo_sqlsrv
.
Step 4. Install Apache and configure driver loading
Step 5. Restart Apache and test the sample script
To test your installation, see Testing your installation at the end of this document.
Installing the drivers with PHP-FPM on Ubuntu
Note
To install PHP 7.2 or 7.3, replace 7.4 with 7.2 or 7.3 in the following commands.
Step 1. Install PHP
Verify the status of the PHP-FPM service by running
Step 2. Install prerequisites
Install the ODBC driver for Ubuntu by following the instructions on the Linux installation article.
Step 3. Install the PHP drivers for Microsoft SQL Server
If there is only one PHP version in the system, then the last step can be simplified to phpenmod sqlsrv pdo_sqlsrv
.
Verify that sqlsrv.ini
and pdo_sqlsrv.ini
are located in /etc/php/7.4/fpm/conf.d/
:
Restart the PHP-FPM service:
Step 4. Install and configure nginx
To configure nginx, you must edit the /etc/nginx/sites-available/default
file. Add index.php
to the list below the section that says # Add index.php to the list if you are using PHP
:
Next, modify the section following # pass PHP scripts to FastCGI server
as follows:
Step 5. Restart nginx and test the sample script
To test your installation, see Testing your installation at the end of this document.
Installing the drivers on Red Hat 7 and 8
Step 1. Install PHP
To install PHP on Red Hat 7, run the following:
Note
To install PHP 7.2 or 7.3, replace remi-php74 with remi-php72 or remi-php73 respectively in the following commands.
To install PHP on Red Hat 8, run the following:
Note
To install PHP 7.2 or 7.3, replace remi-7.4 with remi-7.2 or remi-7.3 respectively in the following commands.
Step 2. Install prerequisites
Install the ODBC driver for Red Hat 7 or 8 by following the instructions on the Linux installation article.
Step 3. Install the PHP drivers for Microsoft SQL Server
You can alternatively install from the Remi repo:
Step 4. Install Apache
SELinux is installed by default and runs in Enforcing mode. To allow Apache to connect to databases through SELinux, run the following command:
Step 5. Restart Apache and test the sample script
To test your installation, see Testing your installation at the end of this document.
Installing the drivers on Debian 8, 9, and 10
Note
To install PHP 7.2 or 7.3, replace 7.4 in the following commands with 7.2 or 7.3.
Step 1. Install PHP
Step 2. Install prerequisites
Install the ODBC driver for Debian by following the instructions on the Linux installation article.
You may also need to generate the correct locale to get PHP output to display correctly in a browser. For example, for the en_US UTF-8 locale, run the following commands:
You may need to add /usr/sbin
to your $PATH
, as the locale-gen
executable is located there.
Step 3. Install the PHP drivers for Microsoft SQL Server
If there is only one PHP version in the system, then the last step can be simplified to phpenmod sqlsrv pdo_sqlsrv
. As with locale-gen
, phpenmod
is located in /usr/sbin
so you may need to add this directory to your $PATH
.
Step 4. Install Apache and configure driver loading
Step 5. Restart Apache and test the sample script
To test your installation, see Testing your installation at the end of this document.
Installing the drivers on Suse 12 and 15
Note
In the following instructions, replace <SuseVersion>
with your version of Suse - if you are using Suse Enterprise Linux 15, it will be SLE_15 or SLE_15_SP1. For Suse 12, use SLE_12_SP4 (or above if applicable). Not all versions of PHP are available for all versions of Suse Linux - please refer to http://download.opensuse.org/repositories/devel:/languages:/php
to see which versions of Suse have the default version PHP available, or to http://download.opensuse.org/repositories/devel:/languages:/php:/
to see which other versions of PHP are available for which versions of Suse.
Note
Packages for PHP 7.4 are not available for Suse 12.To install PHP 7.2, replace the repository URL below with the following URL:https://download.opensuse.org/repositories/devel:/languages:/php:/php72/<SuseVersion>/devel:languages:php:php72.repo
.To install PHP 7.3, replace the repository URL below with the following URL:https://download.opensuse.org/repositories/devel:/languages:/php:/php73/<SuseVersion>/devel:languages:php:php73.repo
.
Step 1. Install PHP
Step 2. Install prerequisites
Install the ODBC driver for Suse by following the instructions on the Linux installation article.
Step 3. Install the PHP drivers for Microsoft SQL Server
Note
If you get an error message saying Connection to 'pecl.php.net:443' failed: Unable to find the socket transport 'ssl'
, edit the pecl script at /usr/bin/pecl and remove the -n
switch in the last line. This switch prevents PECL from loading ini files when PHP is called, which prevents the OpenSSL extension from loading.
Step 4. Install Apache and configure driver loading
Step 5. Restart Apache and test the sample script
To test your installation, see Testing your installation at the end of this document.
Installing the drivers on Alpine 3.11
Note
The default version of PHP is 7.3. Alternate versions of PHP are not available from other repositories for Alpine 3.11. You can instead compile PHP from source.
Step 1. Install PHP
PHP packages for Alpine are found in the edge/community
repository. Add the following line to /etc/apt/repositories
, replacing <mirror>
with the URL of an Alpine repository mirror:
Then run:
Step 2. Install prerequisites
Install the ODBC driver for Alpine by following the instructions on the Linux installation article.
Step 3. Install the PHP drivers for Microsoft SQL Server
You may need to define a locale:
Step 4. Install Apache and configure driver loading
Step 5. Restart Apache and test the sample script
To test your installation, see Testing your installation at the end of this document.
Installing the drivers on macOS High Sierra, Mojave, and Catalina
Microsoft Sql Server Tutorial
If you do not already have it, install brew as follows:
Note
To install PHP 7.2 or 7.3, replace php@7.4 with php@7.2 or php@7.3 respectively in the following commands.
Step 1. Install PHP
PHP should now be in your path -- run php -v
to verify that you are running the correct version of PHP. If PHP is not in your path or it is not the correct version, run the following:
Step 2. Install prerequisites
Install the ODBC driver for macOS by following the instructions on the macOS installation article.
In addition, you may need to install the GNU make tools:
Step 3. Install the PHP drivers for Microsoft SQL Server
Step 4. Install Apache and configure driver loading
To find the Apache configuration file, httpd.conf
, for your Apache installation, run
The following commands append the required configuration to httpd.conf
. Be sure to substitute the path returned by the preceding command in place of /usr/local/etc/httpd/httpd.conf
:
Step 5. Restart Apache and test the sample script
To test your installation, see Testing your installation at the end of this document.
Testing Your Installation
To test this sample script, create a file called testsql.php in your system's document root. This is /var/www/html/
on Ubuntu, Debian, and Redhat, /srv/www/htdocs
on SUSE, /var/www/localhost/htdocs
on Alpine, or /usr/local/var/www
on macOS. Copy the following script to it, replacing the server, database, username, and password as appropriate. On Alpine 3.11, you may also need to specify the CharacterSet as 'UTF-8' in the $connectionOptions
array.
Point your browser to https://localhost/testsql.php (https://localhost:8080/testsql.php on macOS). You should now be able to connect to your SQL Server/Azure SQL database.