Skip to content

Commit 4d2ebb9

Browse files
committed
2 parents 7d45079 + 5d2a653 commit 4d2ebb9

File tree

2 files changed

+44
-34
lines changed

2 files changed

+44
-34
lines changed

Linux-mac-install.md

Lines changed: 42 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,37 @@
11
# Linux and macOS Installation Tutorial for the Microsoft Drivers for PHP for SQL Server
2-
The following instructions assume a clean environment and show how to install PHP 7.x, the Microsoft ODBC driver, Apache, and the Microsoft drivers for PHP for Microsoft SQL Server on Ubuntu 16.04, 17.10 and 18.04, RedHat 7, Debian 8 and 9, Suse 12, and macOS 10.11, 10.12 and 10.13. These instructions advise installing the drivers using PECL, but you can also download the prebuilt binaries from the [Microsoft Drivers for PHP for Microsoft SQL Server](https://github.com/Microsoft/msphpsql/releases) Github project page and install them following the instructions in [Loading the Microsoft Drivers for PHP for Microsoft SQL Server](https://docs.microsoft.com/sql/connect/php/loading-the-php-sql-driver)). For an explanation of extension loading and why we do not add the extensions to php.ini, see the section on [loading the drivers](https://docs.microsoft.com/sql/connect/php/loading-the-php-sql-driver#loading-the-driver-at-php-startup).
2+
The following instructions assume a clean environment and show how to install PHP 7.x, the Microsoft ODBC driver, Apache, and the Microsoft Drivers for PHP for SQL Server on Ubuntu 16.04, 18.04, and 18.10, RedHat 7, Debian 8 and 9, Suse 12, and macOS 10.11, 10.12, 10.13, and 10.14. 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](https://github.com/Microsoft/msphpsql/releases) Github project page and install them following the instructions in [Loading the Microsoft Drivers for PHP for SQL Server](https://docs.microsoft.com/sql/connect/php/loading-the-php-sql-driver). For an explanation of extension loading and why we do not add the extensions to php.ini, see the section on [loading the drivers](https://docs.microsoft.com/sql/connect/php/loading-the-php-sql-driver.md##loading-the-driver-at-php-startup).
33

44
These instructions install PHP 7.2 by default -- see the notes at the beginning of each section to install PHP 7.0 or 7.1.
55

66
## Contents of this page:
77

8-
- [Installing the drivers on Ubuntu 16.04, 18.04 and 18.10](#installing-the-drivers-on-ubuntu-1604-1804-and-1810)
8+
- [Installing the drivers on Ubuntu 16.04, 18.04, and 18.10](#installing-the-drivers-on-ubuntu-1604-1804-and-1810)
99
- [Installing the drivers on Red Hat 7](#installing-the-drivers-on-red-hat-7)
1010
- [Installing the drivers on Debian 8 and 9](#installing-the-drivers-on-debian-8-and-9)
1111
- [Installing the drivers on Suse 12](#installing-the-drivers-on-suse-12)
12-
- [Installing the drivers on macOS El Capitan, Sierra, High Sierra and Mojave](#installing-the-drivers-on-macos-el-capitan-sierra-high-sierra-and-mojave)
12+
- [Installing the drivers on macOS El Capitan, Sierra, High Sierra, and Mojave](#installing-the-drivers-on-macos-el-capitan-sierra-high-sierra-and-mojave)
1313

14-
## Installing the drivers on Ubuntu 16.04, 18.04 and 18.10
14+
## Installing the drivers on Ubuntu 16.04, 18.04, and 18.10
1515

1616
> [!NOTE]
17-
> To install PHP 7.0 or 7.1, replace 7.2 with 7.0 or 7.1 in the following commands.
18-
> For Ubuntu 18.04, the step to add the ondrej repository is not required unless
19-
> PHP 7.0 or 7.1 is needed. However, installing PHP 7.0 or 7.1 in Ubuntu 18.04 or 18.10
20-
> may not work as packages from the ondrej repository come with dependencies that may
21-
> conflict with a base Ubuntu 18.04 or 18.10 install.
17+
> To install PHP 7.0, 7.1, or 7.3, replace `7.2` with `7.0`, `7.1`, or `7.3` in the following commands.
2218
2319
### Step 1. Install PHP
2420
```
2521
sudo su
26-
# The following step is required for Ubuntu 16.04 only
27-
add-apt-repository ppa:ondrej/php -y
22+
add-apt-repository ppa:ondrej/php -y
2823
apt-get update
2924
apt-get install php7.2 php7.2-dev php7.2-xml -y --allow-unauthenticated
3025
```
3126
### Step 2. Install prerequisites
32-
Install the ODBC driver for Ubuntu by following the instructions on the [Linux and macOS installation page](https://docs.microsoft.com/en-us/sql/connect/odbc/linux-mac/installing-the-microsoft-odbc-driver-for-sql-server).
27+
Install the ODBC driver for Ubuntu by following the instructions on the [Linux and macOS installation page](https://docs.microsoft.com/sql/connect/odbc/linux-mac/installing-the-microsoft-odbc-driver-for-sql-server).
3328

34-
For Ubuntu 18.10, follow the above steps for Ubuntu 18.04 except replace `18.04` by `18.10` and download ODBC 17.3 preview [here](https://www.microsoft.com/en-us/download/details.aspx?id=57341).
29+
For Ubuntu 18.10, follow the above steps for Ubuntu 18.04 except replace `18.04` by `18.10` and download ODBC 17.3 preview [here](https://www.microsoft.com/download/details.aspx?id=57341).
3530

3631
### Step 3. Install the PHP drivers for Microsoft SQL Server
32+
33+
> [!NOTE]
34+
> If using PHP 7.3, replace `sqlsrv` and `pdo_sqlsrv` in the following commands with `sqlsrv-5.4.0preview` and `pdo_sqlsrv-5.4.0preview` or later, as earlier versions are not compatible with PHP 7.3.
3735
```
3836
sudo pecl install sqlsrv
3937
sudo pecl install pdo_sqlsrv
@@ -62,22 +60,23 @@ To test your installation, see [Testing your installation](#testing-your-install
6260
## Installing the drivers on Red Hat 7
6361

6462
> [!NOTE]
65-
> To install PHP 7.0 or 7.1, replace remi-php72 with remi-php70 or remi-php71 respectively in the following commands.
63+
> To install PHP 7.0, 7.1, or 7.3, replace `remi-php72` with `remi-php70`, `remi-php71`, or `remi-php73` respectively in the following commands.
6664
6765
### Step 1. Install PHP
6866

6967
```
7068
sudo su
7169
wget https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
72-
wget http://rpms.remirepo.net/enterprise/remi-release-7.rpm
70+
wget https://rpms.remirepo.net/enterprise/remi-release-7.rpm
7371
rpm -Uvh remi-release-7.rpm epel-release-latest-7.noarch.rpm
7472
subscription-manager repos --enable=rhel-7-server-optional-rpms
73+
yum install yum-utils
7574
yum-config-manager --enable remi-php72
7675
yum update
7776
yum install php php-pdo php-xml php-pear php-devel re2c gcc-c++ gcc
7877
```
7978
### Step 2. Install prerequisites
80-
Install the ODBC driver for Red Hat 7 by following the instructions on the [Linux and macOS installation page](https://docs.microsoft.com/en-us/sql/connect/odbc/linux-mac/installing-the-microsoft-odbc-driver-for-sql-server).
79+
Install the ODBC driver for Red Hat 7 by following the instructions on the [Linux and macOS installation page](https://docs.microsoft.com/sql/connect/odbc/linux-mac/installing-the-microsoft-odbc-driver-for-sql-server).
8180

8281
Compiling the PHP drivers with PECL with PHP 7.2 requires a more recent GCC than the default:
8382
```
@@ -86,6 +85,9 @@ sudo yum install devtoolset-7
8685
scl enable devtoolset-7 bash
8786
```
8887
### Step 3. Install the PHP drivers for Microsoft SQL Server
88+
89+
> [!NOTE]
90+
> If using PHP 7.3, replace `sqlsrv` and `pdo_sqlsrv` in the following commands with `sqlsrv-5.4.0preview` and `pdo_sqlsrv-5.4.0preview` or later, as earlier versions are not compatible with PHP 7.3.
8991
```
9092
sudo pecl install sqlsrv
9193
sudo pecl install pdo_sqlsrv
@@ -106,7 +108,7 @@ sudo make install
106108
```
107109
You can alternatively download the prebuilt binaries from the [Github project page](https://github.com/Microsoft/msphpsql/releases), or install from the Remi repo:
108110
```
109-
sudo yum install php-sqlsrv php-pdo_sqlsrv
111+
sudo yum install php-sqlsrv
110112
```
111113
### Step 4. Install Apache
112114
```
@@ -125,7 +127,7 @@ To test your installation, see [Testing your installation](#testing-your-install
125127
## Installing the drivers on Debian 8 and 9
126128

127129
> [!NOTE]
128-
> To install PHP 7.0 or 7.1, replace 7.2 in the following commands with 7.0 or 7.1.
130+
> To install PHP 7.0, 7.1, or 7.3, replace `7.2` with `7.0`, `7.1`, or `7.3` in the following commands.
129131
130132
### Step 1. Install PHP
131133
```
@@ -137,7 +139,7 @@ apt-get update
137139
apt-get install -y php7.2 php7.2-dev php7.2-xml
138140
```
139141
### Step 2. Install prerequisites
140-
Install the ODBC driver for Debian by following the instructions on the [Linux and macOS installation page](https://docs.microsoft.com/en-us/sql/connect/odbc/linux-mac/installing-the-microsoft-odbc-driver-for-sql-server).
142+
Install the ODBC driver for Debian by following the instructions on the [Linux and macOS installation page](https://docs.microsoft.com/sql/connect/odbc/linux-mac/installing-the-microsoft-odbc-driver-for-sql-server).
141143

142144
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:
143145
```
@@ -147,6 +149,9 @@ locale-gen
147149
```
148150

149151
### Step 3. Install the PHP drivers for Microsoft SQL Server
152+
153+
> [!NOTE]
154+
> If using PHP 7.3, replace `sqlsrv` and `pdo_sqlsrv` in the following commands with `sqlsrv-5.4.0preview` and `pdo_sqlsrv-5.4.0preview` or later, as earlier versions are not compatible with PHP 7.3.
150155
```
151156
sudo pecl install sqlsrv
152157
sudo pecl install pdo_sqlsrv
@@ -174,21 +179,24 @@ To test your installation, see [Testing your installation](#testing-your-install
174179
## Installing the drivers on Suse 12
175180

176181
> [!NOTE]
177-
> To install PHP 7.0, skip the command below adding the repository - 7.0 is the default PHP on suse 12.
178-
> To install PHP 7.1, replace the repository URL below with the following URL:
179-
`http://download.opensuse.org/repositories/devel:/languages:/php:/php71/SLE_12/devel:languages:php:php71.repo`
182+
> To install PHP 7.0 or 7.1, replace the repository URL below with one of the following URLs:
183+
`https://download.opensuse.org/repositories/devel:languages:php:php70/SLE_12_SP3/devel:languages:php:php70.repo`
184+
`https://download.opensuse.org/repositories/devel:languages:php:php71/SLE_12_SP3/devel:languages:php:php71.repo`
180185

181186
### Step 1. Install PHP
182187
```
183188
sudo su
184-
zypper -n ar -f http://download.opensuse.org/repositories/devel:languages:php/SLE_12/devel:languages:php.repo
189+
zypper -n ar -f https://download.opensuse.org/repositories/devel:languages:php/SLE_12_SP3/devel:languages:php.repo
185190
zypper --gpg-auto-import-keys refresh
186191
zypper -n install php7 php7-pear php7-devel
187192
```
188193
### Step 2. Install prerequisites
189-
Install the ODBC driver for Suse 12 by following the instructions on the [Linux and macOS installation page](https://docs.microsoft.com/en-us/sql/connect/odbc/linux-mac/installing-the-microsoft-odbc-driver-for-sql-server).
194+
Install the ODBC driver for Suse 12 by following the instructions on the [Linux and macOS installation page](https://docs.microsoft.com/sql/connect/odbc/linux-mac/installing-the-microsoft-odbc-driver-for-sql-server).
190195

191196
### Step 3. Install the PHP drivers for Microsoft SQL Server
197+
198+
> [!NOTE]
199+
> If using PHP 7.3, replace `sqlsrv` and `pdo_sqlsrv` in the following commands with `sqlsrv-5.4.0preview` and `pdo_sqlsrv-5.4.0preview` or later, as earlier versions are not compatible with PHP 7.3.
192200
```
193201
sudo pecl install sqlsrv
194202
sudo pecl install pdo_sqlsrv
@@ -212,15 +220,15 @@ sudo systemctl restart apache2
212220
```
213221
To test your installation, see [Testing your installation](#testing-your-installation) at the end of this document.
214222

215-
## Installing the drivers on macOS El Capitan, Sierra, High Sierra and Mojave
223+
## Installing the drivers on macOS El Capitan, Sierra, High Sierra, and Mojave
216224

217225
If you do not already have it, install brew as follows:
218226
```
219227
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
220228
```
221229

222230
> [!NOTE]
223-
> To install PHP 7.0 or 7.1, replace [email protected] with [email protected] or php@7.1 respectively in the following commands.
231+
> To install PHP 7.0, 7.1, or 7.3, replace `[email protected]` with `[email protected]`, `[email protected]`, or `php@7.3` respectively in the following commands.
224232
225233
### Step 1. Install PHP
226234

@@ -229,22 +237,23 @@ brew tap
229237
brew tap homebrew/core
230238
brew install [email protected]
231239
```
232-
233240
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:
234-
235241
```
236242
brew link --force --overwrite [email protected]
237243
```
238244

239245
### Step 2. Install prerequisites
240-
Install the ODBC driver for macOS by following the instructions on the [Linux and macOS installation page](https://docs.microsoft.com/en-us/sql/connect/odbc/linux-mac/installing-the-microsoft-odbc-driver-for-sql-server).
246+
Install the ODBC driver for macOS by following the instructions on the [Linux and macOS installation page](https://docs.microsoft.com/sql/connect/odbc/linux-mac/installing-the-microsoft-odbc-driver-for-sql-server).
241247

242248
In addition, you may need to install the GNU make tools:
243249
```
244250
brew install autoconf automake libtool
245251
```
246252

247253
### Step 3. Install the PHP drivers for Microsoft SQL Server
254+
255+
> [!NOTE]
256+
> If using PHP 7.3, replace `sqlsrv` and `pdo_sqlsrv` in the following commands with `sqlsrv-5.4.0preview` and `pdo_sqlsrv-5.4.0preview` or later, as earlier versions are not compatible with PHP 7.3.
248257
```
249258
sudo pecl install sqlsrv
250259
sudo pecl install pdo_sqlsrv
@@ -253,10 +262,10 @@ sudo pecl install pdo_sqlsrv
253262
```
254263
brew install apache2
255264
```
256-
To find the Apache configuration file for your Apache installation, run
265+
To find the Apache configuration file for your Apache installation, run
257266
```
258267
apachectl -V | grep SERVER_CONFIG_FILE
259-
```
268+
```
260269
and substitute the path for `httpd.conf` in the following commands:
261270
```
262271
echo "LoadModule php7_module /usr/local/opt/[email protected]/lib/httpd/modules/libphp7.so" >> /usr/local/etc/httpd/httpd.conf
@@ -320,4 +329,5 @@ function formatErrors($errors)
320329
}
321330
?>
322331
```
323-
Point your browser to http://localhost/testsql.php (http://localhost:8080/testsql.php on macOS). You should now be able to connect to your SQL Server/Azure SQL database.
332+
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.
333+

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ Thank you for taking the time to participate in our last survey. You can continu
4545
For full details on the system requirements for the drivers, see the [system requirements](https://docs.microsoft.com/sql/connect/php/system-requirements-for-the-php-sql-driver) on Microsoft Docs.
4646

4747
On the client machine:
48-
- PHP 7.1.x, or 7.2.x (7.2.0 and up on Unix, 7.2.1 and up on Windows)
49-
- [Microsoft ODBC Driver 17, Microsoft ODBC Driver 13, or Microsoft ODBC Driver 11](https://docs.microsoft.com/sql/connect/odbc/download-odbc-driver-for-sql-server?view=sql-server-2017)
48+
- PHP 7.1.x, 7.2.x (7.2.0 and up on Unix, 7.2.1 and up on Windows), or 7.3.x
49+
- [Microsoft ODBC Driver 17, Microsoft ODBC Driver 13, or Microsoft ODBC Driver 11](https://docs.microsoft.com/sql/connect/odbc/download-odbc-driver-for-sql-server)
5050
- If using a Web server such as Internet Information Services (IIS) or Apache, it must be configured to run PHP
5151

5252
On the server side, Microsoft SQL Server 2008 R2 and above on Windows are supported, as are Microsoft SQL Server 2016 and above on Linux.

0 commit comments

Comments
 (0)