markdown 在MacOS中安装PHP MSSQL驱动程序(Mojave)

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了markdown 在MacOS中安装PHP MSSQL驱动程序(Mojave)相关的知识,希望对你有一定的参考价值。

Installing Brew

```
$ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
```

Installing  MSSQL Tools

```
brew tap microsoft/mssql-release https://github.com/Microsoft/homebrew-mssql-release
brew update
brew install msodbcsql17 mssql-tools
```

If you installed this formula with the registration option (default), you'll
need to manually remove [ODBC Driver 17 for SQL Server] section from
odbcinst.ini after the formula is uninstalled. This can be done by executing
the following command:

```
$ odbcinst -u -d -n "ODBC Driver 17 for SQL Server"
```

Install dependencies:

```
$ brew install autoconf automake libtool
```

Install PHP Drivers for MSSQL

```
$ sudo pecl install sqlsrv
$ sudo pecl install pdo_sqlsrv
```

In case your MSSQL `.so` files didn't load properly, you can find the exact location of the files with following command:

```
$ find . -name pdo_sqlsrv.so -print
$ find . -name sqlsrv.so -print
```

In my case I got the following path for the files. Now 

```
/usr/local/lib/php/pecl/20170718/sqlsrv.so
/usr/local/lib/php/pecl/20170718/pdo_sqlsrv.so
```

Next, just copy the files to your respective PHP Version lib directory:

```
cp /usr/local/lib/php/pecl/20170718/sqlsrv.so /usr/local/Cellar/php@7.2/7.2.13/lib/php/20170718/
cp /usr/local/lib/php/pecl/20170718/pdo_sqlsrv.so /usr/local/Cellar/php@7.2/7.2.13/lib/php/20170718/
```

Then make sure the following extensions is loaded in `php.ini`

```
extension="pdo_sqlsrv.so"
extension="sqlsrv.so"
```

Use `php -m | grep sqlsrv` to check the extensions is loaded properly.

```
php -m | grep sqlsrv
pdo_sqlsrv
sqlsrv
```

以上是关于markdown 在MacOS中安装PHP MSSQL驱动程序(Mojave)的主要内容,如果未能解决你的问题,请参考以下文章

macos中mysql怎么安装

在 macOS 中安装 pyqt 的问题

在 MacOS 中安装 gcutil 时收到错误

如何使用自制软件在 macOS 中安装以前版本的 Python 3?

如何在macos中安装emacs

在 PyCharm (macOS) 中安装 dlib 时出现问题