Documente Academic
Documente Profesional
Documente Cultură
InstallandConfigurePHP:TheOfficialMicrosoftIISSite
Sign In
Home
Get Started
Install
Downloads
Manage
Develop
Learn
Publish
Reference
Troubleshoot
Solutions
Extensions
Media
Blogs
Join
Forums
Application Frameworks
Web Hosting
Home Learn Application Frameworks Chapter 3. Install and Configure PHP on IIS Install and Configure PHP
Introduction
The fastest and easiest way to install PHP on Internet Information Services IIS is by using the
Microsoft Web Platform Installer Web PI. Web PI completely automates setting up IIS, FastCGI,
and the latest version of PHP from the php.net Web site. With Web PI, you can navigate to the
Web Platform tab and select PHP under Framework and Runtimes customize link. Alternately,
use the instructions that follow as guidance for installing PHP with Windows Installer or using a
compressed Zip file installation.
Table of Contents
There are two builds for each PHP version: one is threadsafe, and one is not referred to as the
nonthreadsafe [NTS] version. The threadsafe version is designed for environments where the
Web server core can keep the PHP engine in memory, running multiple treads of execution for
different Web requests simultaneously. The architecture of IIS and the FastCGI extension provide
an isolation model that keeps requests separate, removing the need for a threadsafe version. The
NTS version does not have any of the code that allows PHP to manage multiple threads. As a
result, there is a performance improvement on IIS when using the NTS version when compared to
Integrated Pipeline
the treadsafe version because the NTS version avoids unnecessary threadsafety checks FastCGI
How to Capture ASP.NET Page Trace Events
Install PHP
There are two main ways to install PHP on a Windowsbased computer: download the Windows
Installer or use the Windows Zip file from the PHP Web site. Either method will get PHP working,
pipeline
but both have some extra steps that are needed to make PHP work well.
Windows Installer
The Windows Installer version can get a complete PHP environment up and running, but the
installation of extensions can be confusing. By default, no extensions are installed, and this can
adversely affect the usefulness of the PHP installation. Alternately, all of the extensions can be
installed; this results in an unstable system because some of the extensions can conflict with
others. It is generally easier to use the Zip file installation.
Windows Installer version; however, none of the extensions are enabled until their entries in the
Databases on IIS
Classic ASP Script Error Messages No Longer
http://www.iis.net/learn/applicationframeworks/installandconfigurephponiis/installandconfigurephp#_Extensions_1
1/10
4/27/2015
InstallandConfigurePHP:TheOfficialMicrosoftIISSite
1. Download the latest nonthreadsafe Zip file package with binaries of PHP. Under Windows
Binaries, click on the most current PHP nonthreadsafe Zip package to download the PHP files.
2. Unpack the files to a directory of your choice for example, C:\PHP on your IIS server.
4. Open the Php.ini file in a text editor, then uncomment and modify settings as follows:
a. Set fastcgi.impersonate = 1.
FastCGI under IIS supports the ability to impersonate security tokens of the calling client. This
Overview
allows IIS to define the security context that the request runs under.
b. Set cgi.fix_pathinfo=0
The cgi.fix_pathinfo provides PATH_INFO/PATH_TRANSLATED support for Common Gateway
Interface CGI. Setting this to 1 will cause PHP CGI to fix its paths to conform to the specification.
c. Set cgi.force_redirect = 0.
d. Set open_basedir to point to a folder or network path where the content of the Web sites is
located.
e. Set extension_dir to point to a location where PHP extensions reside. For PHP 5.2.X, this is
typically extension_dir = "./ext" .
FastCGI
Setting Up a Database for a PHP Application
on IIS
Install PHP and FastCGI Support on Server
Core
f. Set error_log=C:php_errors.log
This can help with troubleshooting.
g. Enable the required PHP extension by uncommenting corresponding lines. More information
follows in the section, Extensions.
http://www.iis.net/learn/applicationframeworks/installandconfigurephponiis/installandconfigurephp#_Extensions_1
2/10
4/27/2015
InstallandConfigurePHP:TheOfficialMicrosoftIISSite
8. Select the Path variable from the System Variables section, and then click on Edit. Add: c:\php to
Coppermine on IIS
10. Start IIS Manager by clicking on Start, Programs, Administrative Tools, and then Internet
Information Services IIS Manager.
Gallery2 on IIS
Geeklog on IIS
11. From the IIS Manager, click on the hostname of your server in the Connections panel on the
left.
12. Doubleclick on the Handler Mappings icon.
Mambo on IIS
Install WordPress on IIS
XOOPS on IIS
MediaWiki on IIS
Install osCommerce on IIS
PHPNuke on IIS
Install Zen Cart on IIS
CubeCart on IIS
ExpressionEngine on IIS
LimeSurvey on IIS
OpenAds on IIS
PHPList on IIS
http://www.iis.net/learn/applicationframeworks/installandconfigurephponiis/installandconfigurephp#_Extensions_1
PHProjekt on IIS
Siteframe on IIS
3/10
4/27/2015
InstallandConfigurePHP:TheOfficialMicrosoftIISSite
PHPWCMS on IIS
pMachinePro on IIS
Install Drupal on IIS
Install Joomla! on IIS
Using FastCGI to Host PHP Applications on
IIS 7
Using FastCGI to Host PHP Applications on
IIS 6.0
Translate .htaccess Content to IIS web.config
Provide URL Rewriting Functionality
14. Type the following information into the appropriate text boxes, and then click OK.
Executable: C:\php\phpcgi.exe
Name: FastCGI
16. In the left panel, click on your servers hostname, and then doubleclick on the Default
Document icon.
17. From the Actions panel on the right, click Add.
18. Enter index.php as the new default document name, and then click OK.
19. Enter default.php as the new default document name, and then click OK.
http://www.iis.net/learn/applicationframeworks/installandconfigurephponiis/installandconfigurephp#_Extensions_1
4/10
4/27/2015
InstallandConfigurePHP:TheOfficialMicrosoftIISSite
22. Create a new text document, and save it as c:\inetpub\wwwroot\phpinfo.php with the following
content:
Modules
Configuring Step 2: Configure ASP.NET
<?phpphpinfo();?>
Settings
Configuring Step 3: Configure Data Source
23. You should now see the PHP information page at http://localhost/phpinfo.php.
Settings
Configuring Step 4: Configure Application
Security
Extensions
It is important to determine which extensions are needed by the applications that will be running
and then to limit the installed extensions to only those. For a typical opensource application
Application Security
with a variety of databases; this extra layer of abstraction provides a richer set of object
database functionality and controls. If Microsoft SQL Server or an express version, such
as Microsoft SQL Server 2008 Express or Microsoft SQL Server 2005 Express Edition
is the database engine, use the php_mssql extension for opensource applications. For new
development work, use the PDO version of the SQL driver.
Image Handling ExtensionsMany of the opensource applications that enable work with
images make use of the GD2 extension php_gd2, which has a number of good basic
image manipulation application programming interfaces APIs. Some applications use the
ImageMagick application and libraries. There is also a php_exif library for working with the
extended information that modern digital cameras store within the images.
Internationalization and Localization ExtensionsThe two most commonly used extensions
for i18n and l10n are php_mbstring MultiByte String and php_gettext Native Language
http://www.iis.net/learn/applicationframeworks/installandconfigurephponiis/installandconfigurephp#_Extensions_1
5/10
4/27/2015
InstallandConfigurePHP:TheOfficialMicrosoftIISSite
Support. Many of the opensource applications use one or both of these.
Web Services ExtensionsChoose the Web services extensions based on the services
desired. For PHP, the SOAP extension is widely used. The XMLRPC extension is often used
in conjunction with SOAP and other services.
REQUIRED SETTINGS:
extension_dir = <PATH TO EXTENSIONS>
The extension_dir needs to point to the directory where the PHP extensions are stored. The
path can be fully qualified for example, C:\PHP\ext or relative for example, .\ext.
Extensions that are specified lower in the Php.ini file need to be located in the extension_dir.
If the extensions specified are not in the extension_dir, then PHP will give a warning
message at the start of script execution, and the application may show errors because of the
missing functionality.
extension = xxxxxx.dll
For each extension enabled, a corresponding extension= directive that tells PHP which
extensions in the extension_dir to load at startup time is necessary.
log_errors=On
PHP errors can also go through the PHP error logging facility. This can be used to send
errors to a file or to a service for example, syslog and works with the error_log directive
described below. When running under IIS, log_errors must be enabled with a valid error_log.
Otherwise, FastCGI considers any startup messages which may be benign as an error
condition, which generates an HTTP 500 return error code to the browser.
error_log=<path_to_error_log_file
The error_log needs to specify the fully qualified, or relative, path to the file where the PHP
error log is stored. This file needs to be writable for the IIS service. The most common places
for this file are in various temporary directories for example, C:\inetpub\temp\php
errors.log. That puts the log in a place that IIS can use, and also keeps the log close to
where PHP applications are running.
cgi.force_redirect = 0
This directive is required for running under IIS. It is a directory security facility required by
many other Web servers; however, enabling it under IIS will cause the PHP engine to fail on
Windows.
cgi.fix_pathinfo = 1
This lets PHP access real path info following the CGI specification. The IIS FastCGI
implementation needs this extension set.
fastcgi.impersonate = 1
FastCGI under IIS supports the ability to impersonate security tokens of the calling client.
This allows IIS to define the security context that the request runs under.
fastcgi.logging = 0
FastCGI logging should be disabled on IIS. If it is left enabled, then any messages of any
class are treated by FastCGI as error conditions, which will cause IIS to generate an HTTP 500
exception.
http://www.iis.net/learn/applicationframeworks/installandconfigurephponiis/installandconfigurephp#_Extensions_1
6/10
4/27/2015
InstallandConfigurePHP:TheOfficialMicrosoftIISSite
OPTIONAL SETTINGS:
max_execution_time=##
This directive sets the maximum amount of time that can be taken executing any given
script. The default is 30 seconds. Some applications need more time to process batch
operations for example, Gallery2 loading multiple images from a remote location.
However, setting the execution time higher than 300 seconds is not advised because there
are often other parts of the connection that cannot support such a long execution time.
memory_limit=###M
The amount of memory available for the PHP process in MB. The default is 128 MB, which
is appropriate for most PHP applications.
display_errors=Off
This directive determines whether to include any error messages in the stream that it returns
to the Web server. If turned on, PHP will send the classes of errors that are defined with the
error_reporting directive back to IIS as part of the error stream. Many of the opensource
applications bypass error reporting by executing commands prefaced with @. This allows
the applications to control error handling.
Mail functions
PHP is configured by default to send outbound mail through an SMTP server located on the
same system as the Web server. Note that most Windows installations usually have the Web
and mail servers on separate systems.
http://www.iis.net/learn/applicationframeworks/installandconfigurephponiis/installandconfigurephp#_Extensions_1
7/10
4/27/2015
InstallandConfigurePHP:TheOfficialMicrosoftIISSite
http://www.iis.net/learn/applicationframeworks/installandconfigurephponiis/installandconfigurephp#_Extensions_1
8/10
4/27/2015
InstallandConfigurePHP:TheOfficialMicrosoftIISSite
9/10
4/27/2015
InstallandConfigurePHP:TheOfficialMicrosoftIISSite
BYTALI SMITH
Tali Smith is a technical writer at Prowess Consulting, a Seattlebased IT
software and services firm with expertise in Microsoft technologies.
This site is managed for Microsoft by Neudesic, LLC. | 2015 Microsoft. All rights reserved.
Follow us on:
Privacy Statement | Terms of Use | Contact Us | Advertise With Us | Hosted on Microsoft Azure
http://www.iis.net/learn/applicationframeworks/installandconfigurephponiis/installandconfigurephp#_Extensions_1
10/10