diff --git a/README.md b/README.md index c78c480b..95fe64d9 100644 --- a/README.md +++ b/README.md @@ -42,7 +42,7 @@ Thank you for taking time to take our February survey. Let us know how we are do ## Build (Windows) -Note: if you prefer, you can use the pre-compiled binary found [HERE](https://github.com/Azure/msphpsql/releases) +Note: if you prefer, you can use the pre-compiled binary found [HERE](https://github.com/Microsoft/msphpsql/releases) #### Prerequisites @@ -62,7 +62,7 @@ You must first be able to build PHP 7 without including these extensions. For h 5. To install the resulting build, run `nmake install` or just copy php_sqlsrv.dll and/or php_pdo_sqlsrv.dll to your PHP extension directory. -This software has been compiled and tested under PHP 7.0.8 using the Visual C++ 2015 compiler. +This software has been compiled and tested under PHP 7.0.20 and 7.1.6 using the Visual C++ 2015 compiler. ## Install (Windows) @@ -75,147 +75,181 @@ This software has been compiled and tested under PHP 7.0.8 using the Visual C++ 1. Make sure that the driver is in your PHP extension directory (you can simply copy it there if you did not use nmake install). -2. Enable it within your PHP installation's php.ini: `extension=php_sqlsrv.dll` and/or `extension=php_pdo_sqlsrv.dll`. If necessary, specify the extension directory using extension_dir, for example: `extension_dir = "C:\PHP\ext"` +2. Enable it within your PHP installation's php.ini: `extension=php_sqlsrv.dll` and/or `extension=php_pdo_sqlsrv.dll`. If necessary, specify the extension directory using extension_dir, for example: `extension_dir = "C:\PHP\ext"`. Note that the precompiled binaries have different names -- substitute accordingly in php.ini. 3. Restart the Web server. ## Install (UNIX) -The following instructions assume a clean environment and show 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. +The following instructions assume a clean environment and show how to install PHP 7.x, Microsoft ODBC driver, apache, and Microsoft PHP drivers on Ubuntu 15, 16, RedHat 7, Debian 8, and Mac OS X. ### Step 1: Install PHP7+ #### PHP 7.0 -**Ubuntu 15.04, Ubuntu 15.10** +**Ubuntu 15.10** - sudo su - sh -c 'echo "deb http://packages.dotdeb.org jessie all \ndeb-src http://packages.dotdeb.org jessie all" >> /etc/apt/sources.list' - apt-get update - apt-get install php7.0 php7.0-fpm php-pear php7.0-dev mcrypt php7.0-mcrypt php-mbstring php7.0-xml re2c gcc g++ + sudo su + sh -c 'echo "deb http://packages.dotdeb.org jessie all \ndeb-src http://packages.dotdeb.org jessie all" >> /etc/apt/sources.list' + apt-get update + apt-get install php7.0 php7.0-fpm php-pear php7.0-dev mcrypt php7.0-mcrypt php-mbstring php7.0-xml - **Ubuntu 16.04** - sudo su - apt-get update - apt-get -y install php7.0 mcrypt php7.0-mcrypt php-mbstring php-pear php7.0-dev php7.0-xml re2c gcc g++ + sudo su + apt-get update + apt-get -y install php7.0 mcrypt php7.0-mcrypt php-mbstring php-pear php7.0-dev php7.0-xml - **RedHat 7** - sudo su - wget https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm - wget http://rpms.remirepo.net/enterprise/remi-release-7.rpm - rpm -Uvh remi-release-7.rpm epel-release-latest-7.noarch.rpm - subscription-manager repos --enable=rhel-7-server-optional-rpms - yum-config-manager --enable remi-php70 - yum update - yum install php php-pdo php-xml php-pear php-devel re2c gcc-c++ gcc + sudo su + wget https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm + wget http://rpms.remirepo.net/enterprise/remi-release-7.rpm + rpm -Uvh remi-release-7.rpm epel-release-latest-7.noarch.rpm + subscription-manager repos --enable=rhel-7-server-optional-rpms + yum-config-manager --enable remi-php70 + yum update + yum install php php-pdo php-xml php-pear php-devel re2c gcc-c++ gcc + +**Debian 8** + + sudo su + apt-get install curl apt-transport-https + curl https://www.dotdeb.org/dotdeb.gpg | apt-key add - + echo "deb http://packages.dotdeb.org jessie all" >> /etc/apt/sources.list + echo "deb-src http://packages.dotdeb.org jessie all" >> /etc/apt/sources.list + apt-get update + apt-get install -y php7.0 php-pear php7.0-dev php7.0-xml **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 - source ~/.bash_profile + /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 + source ~/.bash_profile #### PHP 7.1 +Note that there are no PHP 7.1 packages available for Ubuntu 15.10. **Ubuntu 16.04** - 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 php7.1-xml + 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 php7.1-xml **RedHat 7** - - sudo su - wget https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm - wget http://rpms.remirepo.net/enterprise/remi-release-7.rpm - rpm -Uvh remi-release-7.rpm epel-release-latest-7.noarch.rpm - subscription-manager repos --enable=rhel-7-server-optional-rpms - yum-config-manager --enable remi-php71 - yum update - yum install php php-pdo php-xml php-pear php-devel - + + sudo su + wget https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm + wget http://rpms.remirepo.net/enterprise/remi-release-7.rpm + rpm -Uvh remi-release-7.rpm epel-release-latest-7.noarch.rpm + subscription-manager repos --enable=rhel-7-server-optional-rpms + yum-config-manager --enable remi-php71 + yum update + yum install php php-pdo php-xml php-pear php-devel re2c gcc-c++ gcc + +**Debian 8** + + sudo su + apt-get install curl apt-transport-https + wget -O /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpg + echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" > /etc/apt/sources.list.d/php.list + apt-get update + apt-get install -y php7.1 php-pear php7.1-dev php7.1-xml + **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 - source ~/.bash_profile + /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 + source ~/.bash_profile ### Step 2: Install Prerequisites - **Ubuntu 15.10** - sudo su - curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add - - curl https://packages.microsoft.com/config/ubuntu/15.10/prod.list > /etc/apt/sources.list.d/mssql-release.list - exit - sudo apt-get update - sudo ACCEPT_EULA=Y apt-get install msodbcsql mssql-tools - sudo apt-get install unixodbc-dev - echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bash_profile - echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bashrc - source ~/.bashrc + sudo su + curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add - + curl https://packages.microsoft.com/config/ubuntu/15.10/prod.list > /etc/apt/sources.list.d/mssql-release.list + exit + sudo apt-get update + sudo ACCEPT_EULA=Y apt-get install msodbcsql mssql-tools + sudo apt-get install unixodbc-dev + echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bash_profile + echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bashrc + source ~/.bashrc - **Ubuntu 16.04** - sudo su - curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add - - curl https://packages.microsoft.com/config/ubuntu/16.04/prod.list > /etc/apt/sources.list.d/mssql-release.list - exit - sudo apt-get update - sudo ACCEPT_EULA=Y apt-get install msodbcsql mssql-tools - sudo apt-get install unixodbc-dev - echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bash_profile - echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bashrc - source ~/.bashrc + sudo su + curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add - + curl https://packages.microsoft.com/config/ubuntu/16.04/prod.list > /etc/apt/sources.list.d/mssql-release.list + exit + sudo apt-get update + sudo ACCEPT_EULA=Y apt-get install msodbcsql mssql-tools + sudo apt-get install unixodbc-dev + echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bash_profile + echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bashrc + source ~/.bashrc **RedHat 7** - sudo su - curl https://packages.microsoft.com/config/rhel/7/prod.repo > /etc/yum.repos.d/mssql-release.repo - exit - sudo yum update - sudo yum remove unixODBC-utf16-devel #to avoid conflicts - sudo ACCEPT_EULA=Y yum install msodbcsql mssql-tools - sudo yum install unixODBC-devel - echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bash_profile - echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bashrc - source ~/.bashrc - + sudo su + curl https://packages.microsoft.com/config/rhel/7/prod.repo > /etc/yum.repos.d/mssql-release.repo + exit + sudo yum update + sudo yum remove unixODBC-utf16-devel #to avoid conflicts + sudo ACCEPT_EULA=Y yum install msodbcsql mssql-tools + sudo yum install unixODBC-devel + echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bash_profile + echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bashrc + source ~/.bashrc + +**Debian 8** + + sudo su + curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add - + curl https://packages.microsoft.com/config/debian/8/prod.list > /etc/apt/sources.list.d/mssql-release.list + apt-get install -y locales + echo "en_US.UTF-8 UTF-8" > /etc/locale.gen + locale-gen + exit + sudo apt-get update + sudo ACCEPT_EULA=Y apt-get install msodbcsql + sudo apt-get install unixodbc-dev + **Mac OS X** - brew tap microsoft/msodbcsql https://github.com/Microsoft/homebrew-mssql-release - brew update - brew install msodbcsql - brew install mssql-tools - brew install autoconf + brew tap microsoft/msodbcsql https://github.com/Microsoft/homebrew-mssql-release + brew update + brew install msodbcsql + brew install mssql-tools + brew install autoconf -*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+. +*Note: Be sure to install PHP 7+ before proceeding to step 3. The Microsoft PHP Drivers for SQL Server will only work for PHP 7+. ### Step 3: Install the Microsoft PHP Drivers for SQL Server -*Note: The first step is not required in Mac OS X. PECL installs the stable version when version is not specified. You may run `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. +*Note: You can run `sudo pecl search sqlsrv` to search for the latest releases and `sudo pecl install sqlsrv-[version]` to install a specific version. PECL installs the stable version when version is not specified. Drivers are Mac-compatible starting from `4.1.7preview` release. + +On Ubuntu and Debian systems only, run: sudo pear config-set php_ini `php --ini | grep "Loaded Configuration" | sed -e "s|.*:\s*||"` system + +On all systems, run: + sudo pecl install sqlsrv sudo pecl install pdo_sqlsrv @@ -223,7 +257,7 @@ The following instructions assume a clean environment and show how to install PH #### PHP 7.0 -**Ubuntu** +**Ubuntu and Debian** sudo su apt-get install libapache2-mod-php7.0 apache2 @@ -232,11 +266,13 @@ The following instructions assume a clean environment and show how to install PH a2enmod php7.0 echo "extension=sqlsrv.so" >> /etc/php/7.0/apache2/php.ini echo "extension=pdo_sqlsrv.so" >> /etc/php/7.0/apache2/php.ini - exit - + **RedHat** - sudo yum install httpd + sudo su + yum install httpd + echo "extension=sqlsrv.so" > /etc/php.d/sqlsrv.ini + echo "extension=pdo_sqlsrv.so" > /etc/php.d/pdo_sqlsrv.ini **Mac OS X** @@ -244,7 +280,7 @@ The following instructions assume a clean environment and show how to install PH #### PHP 7.1 -**Ubuntu** +**Ubuntu and Debian** sudo su apt-get install libapache2-mod-php7.1 apache2 @@ -253,35 +289,37 @@ The following instructions assume a clean environment and show how to install PH a2enmod php7.1 echo "extension=sqlsrv.so" >> /etc/php/7.1/apache2/php.ini echo "extension=pdo_sqlsrv.so" >> /etc/php/7.1/apache2/php.ini - exit - + **RedHat** - sudo yum install httpd + sudo su + yum install httpd + echo "extension=sqlsrv.so" > /etc/php.d/sqlsrv.ini + echo "extension=pdo_sqlsrv.so" > /etc/php.d/pdo_sqlsrv.ini **Mac OS X** (echo ""; echo "SetHandler application/x-httpd-php"; echo "";) >> /usr/local/etc/apache2/2.4/httpd.conf - + ### Step 5: Restart Apache to load the new php.ini file -**Ubuntu** +**Ubuntu and Debian** - sudo service apache2 restart + sudo service apache2 restart **RedHat** - sudo apachectl restart - + sudo apachectl restart + **Mac OS X** - sudo apachectl restart + 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` +*Note to RedHat users: SELinux is installed by default and runs in Enforcing mode. To allow Apache to connect to database through SELinux, run `sudo setsebool -P httpd_can_network_connect_db 1` ### 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. +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 into testsql.php and change the servername, username, password and databasename.