Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mac instructions #319

Merged
merged 26 commits into from
Mar 10, 2017
Merged
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
3918ac4
Initial Mac instructions
ulvii Mar 3, 2017
e87f62a
Add pecl install for mac
ulvii Mar 7, 2017
4fa3112
Changing instructions for loading the drivers
ulvii Mar 7, 2017
741fde8
Updating apache install intructions for MAC
ulvii Mar 7, 2017
41e4ab6
Adding Mac related notes
ulvii Mar 7, 2017
55d9aa3
Minor cleanup
ulvii Mar 7, 2017
4702c28
appveyor.yml now outputs details of failing tests
david-puglielli Mar 2, 2017
a13839a
updated versioning to semantic versioning #282
Mar 4, 2017
f4d116a
Update README.md
meet-bhagdev Mar 4, 2017
a6231ea
changed locale for mac
yitam Mar 4, 2017
5e69182
added client info tests
Mar 4, 2017
b96bda8
added versioning notes
Mar 7, 2017
b017ce8
updated precedence order example
Mar 7, 2017
75d195f
added 4.1.7 to changedlog
yukiwongky Mar 7, 2017
267a617
updated PECL package version
Mar 7, 2017
0878863
Update CHANGELOG.md
yukiwongky Mar 7, 2017
7cf86e6
Update CHANGELOG.md
yukiwongky Mar 7, 2017
ac2c0c8
Update CHANGELOG.md
yukiwongky Mar 7, 2017
3ed11cc
MAC OS X announcement
Mar 7, 2017
0c9e073
Merge branch 'dev' of https://github.com/Microsoft/msphpsql into MacI…
ulvii Mar 8, 2017
52b77f5
Merge branch 'MacInstructions' of https://github.com/ulvii/msphpsql i…
ulvii Mar 8, 2017
a6416d7
Updating Mac Apache Instructions. Also removing the step of manually …
ulvii Mar 9, 2017
f76f604
Adding php7.1-xml installation
ulvii Mar 9, 2017
42302ce
Apache config for Mac
ulvii Mar 9, 2017
bba90a6
Fixing Apache config
ulvii Mar 10, 2017
81d898d
Update PECL instructions
ulvii Mar 10, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
111 changes: 57 additions & 54 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,10 @@ This software has been compiled and tested under PHP 7.0.8 using the Visual C++

3. Restart the Web server.

## Install (Linux)
Following instructions shows how to install PHP 7.x, Microsoft ODBC driver, apache, and Microsoft PHP drivers on Ubuntu 15, 16 and RedHat 7. To see how to get PHP SQLSRV drivers running on Debian, please visit [Wiki](https://github.com/Microsoft/msphpsql/wiki/Dockerfile-for-getting-pdo_sqlsrv-for-PHP-7.0-on-Debian-in-3-ways). Note that Debian is not officially supported and this instruction hasn't been tested in our test lab.
## Install (UNIX)
Following instructions shows how to install PHP 7.x, Microsoft ODBC driver, apache, and Microsoft PHP drivers on Ubuntu 15, 16, RedHat 7 and Mac OS X. To see how to get PHP SQLSRV drivers running on Debian, please visit [Wiki](https://github.com/Microsoft/msphpsql/wiki/Dockerfile-for-getting-pdo_sqlsrv-for-PHP-7.0-on-Debian-in-3-ways). Note that Debian is not officially supported and this instruction hasn't been tested in our test lab.

### Step 1: Install PHP (unless already installed)
### Step 1: Install PHP7 (unless already installed)

#### PHP 7.0

Expand Down Expand Up @@ -114,6 +114,17 @@ Following instructions shows how to install PHP 7.x, Microsoft ODBC driver, apac
yum update
yum install php php-pdo php-xml php-pear php-devel re2c gcc-c++ gcc

**Mac OS X**

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
brew tap
brew tap homebrew/dupes
brew tap homebrew/versions
brew tap homebrew/homebrew-php
brew install php70 --with-pear --with-httpd24 --with-cgi
echo 'export PATH="/usr/local/sbin:$PATH"' >> ~/.bash_profile
echo 'export PATH="/usr/local/bin:$PATH"' >> ~/.bash_profile
*Note: Restart the terminal if PHP(`php -v`) is not updated.


#### PHP 7.1
Expand All @@ -124,7 +135,7 @@ Following instructions shows how to install PHP 7.x, Microsoft ODBC driver, apac
sudo su
add-apt-repository ppa:ondrej/php
apt-get update
apt-get -y install php7.1 mcrypt php7.1-mcrypt php-mbstring php-pear php7.1-dev
apt-get -y install php7.1 mcrypt php7.1-mcrypt php-mbstring php-pear php7.1-dev php7.1-xml

**RedHat 7**

Expand All @@ -137,7 +148,17 @@ Following instructions shows how to install PHP 7.x, Microsoft ODBC driver, apac
yum update
yum install php php-pdo php-xml php-pear php-devel


**Mac OS X**

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
brew tap
brew tap homebrew/dupes
brew tap homebrew/versions
brew tap homebrew/homebrew-php
brew install php71 --with-pear --with-httpd24 --with-cgi
echo 'export PATH="/usr/local/sbin:$PATH"' >> ~/.bash_profile
echo 'export PATH="/usr/local/bin:$PATH"' >> ~/.bash_profile
*Note: Restart the terminal if PHP(`php -v`) is not updated.


### Step 2: Install pre-requisites
Expand Down Expand Up @@ -182,10 +203,17 @@ Following instructions shows how to install PHP 7.x, Microsoft ODBC driver, apac
echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bash_profile
echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bashrc
source ~/.bashrc

**Mac OS X**

brew tap microsoft/msodbcsql https://github.com/Microsoft/homebrew-msodbcsql
brew update
brew install unixodbc
brew install msodbcsql
brew install llvm --with-clang --with-clang-extra-tools
brew install autoconf


*Note: On Ubuntu, you need to make sure you install PHP 7 before you proceed to step 2. The Microsoft PHP Drivers for SQL Server will only work for PHP 7+.
*Note: You need to make sure you install PHP 7 before you proceed to step 3. The Microsoft PHP Drivers for SQL Server will only work for PHP 7+.

### Step 3: Install Apache

Expand All @@ -200,65 +228,36 @@ Following instructions shows how to install PHP 7.x, Microsoft ODBC driver, apac

sudo yum install httpd

**Mac OS X**

(echo "<FilesMatch .php$>"; echo "SetHandler application/x-httpd-php"; echo "</FilesMatch>";) >> /usr/local/etc/apache2/2.4/httpd.conf

####PHP 7.1

**Ubuntu**

sudo apt-get install libapache2-mod-php7.1
sudo apt-get install apache2
sudo apt-get install libapache2-mod-php7.1
sudo apt-get install apache2

**RedHat**

sudo yum install httpd

**Mac OS X**

(echo "<FilesMatch .php$>"; echo "SetHandler application/x-httpd-php"; echo "</FilesMatch>";) >> /usr/local/etc/apache2/2.4/httpd.conf


### Step 4: Install the Microsoft PHP Drivers for SQL Server

sudo pear config-set php_ini `php --ini | grep "Loaded Configuration" | sed -e "s|.*:\s*||"` system
sudo pecl install sqlsrv
sudo pecl install pdo_sqlsrv

*Note: it installs the stable version, for specific version you should set the version. For example, `sudo pecl install sqlsrv-4.0.8`


### Step 5: Add the Microsoft PHP Drivers for SQL Server to php.ini


####PHP 7.0

**Ubuntu**
*Note: it installs the stable version, for specific version you should set the version. For example, do `sudo pecl search sqlsrv` to search for the latest releases and `sudo pecl install sqlsrv-[version]` to install a specific version.
Drivers are Mac-compatible starting from 4.1.7preview release. .

echo "extension=/usr/lib/php/20151012/sqlsrv.so" >> /etc/php/7.0/apache2/php.ini
echo "extension=/usr/lib/php/20151012/pdo_sqlsrv.so" >> /etc/php/7.0/apache2/php.ini
echo "extension=/usr/lib/php/20151012/sqlsrv.so" >> /etc/php/7.0/cli/php.ini
echo "extension=/usr/lib/php/20151012/pdo_sqlsrv.so" >> /etc/php/7.0/cli/php.ini


**RedHat**

echo "extension= /usr/lib64/php/modules/sqlsrv.so" > /etc/php.d/sqlsrv.ini
echo "extension= /usr/lib64/php/modules/pdo_sqlsrv.so" > /etc/php.d/pdo_sqlsrv.ini


####PHP 7.1


**Ubuntu 16.04**

echo "extension=/usr/lib/php/20160303/sqlsrv.so" >> /etc/php/7.1/apache2/php.ini
echo "extension=/usr/lib/php/20160303/pdo_sqlsrv.so" >> /etc/php/7.1/apache2/php.ini
echo "extension=/usr/lib/php/20160303/sqlsrv.so" >> /etc/php/7.1/cli/php.ini
echo "extension=/usr/lib/php/20160303/pdo_sqlsrv.so" >> /etc/php/7.1/cli/php.ini



**RedHat**

echo "extension= /usr/lib64/php/modules/sqlsrv.so" > /etc/php.d/sqlsrv.ini
echo "extension= /usr/lib64/php/modules/pdo_sqlsrv.so" > /etc/php.d/pdo_sqlsrv.ini



### Step 6: Restart Apache to load the new php.ini file
### Step 5: Restart Apache to load the new php.ini file

**Ubuntu**

Expand All @@ -267,11 +266,15 @@ Following instructions shows how to install PHP 7.x, Microsoft ODBC driver, apac
**RedHat**

sudo apachectl restart

**Mac OS X**

sudo apachectl restart

*Note to RedHat users: SELinux is installed by default and runs in Enforcing mode. To allow Apache to connect to database through SELinux, do this `sudo setsebool -P httpd_can_network_connect_db 1`

### Step 7: Create your sample app
Navigate to `/var/www/html` and create a new file called testsql.php. Copy and paste the following code in tetsql.php and change the servername, username, password and databasename.
### Step 6: Create your sample app
Navigate to `/var/www/html` (`/usr/local/var/www/htdocs` on Mac) and create a new file called testsql.php. Copy and paste the following code in tetsql.php and change the servername, username, password and databasename.

<?php
$serverName = "yourServername";
Expand Down Expand Up @@ -312,9 +315,9 @@ Navigate to `/var/www/html` and create a new file called testsql.php. Copy and p
}
?>

### Step 8: Run your sample app
### Step 7: Run your sample app

Go to your browser and type in http://localhost/testsql.php
Go to your browser and type in http://localhost/testsql.php (http://localhost:8080/testsql.php on Mac)
You should be able to connect to your SQL Server/Azure SQL Database.

The drivers are distributed as shared binary extensions for PHP. They are available in thread safe (*_ts.so) and-non thread safe (*_nts.so) versions. The source code for the drivers is also available, and you can choose whether to compile them as thread safe or non-thread safe versions. The thread safety configuration of your web server will determine which version you need.
Expand Down