- Using PHP Manager for IIS to setup and configure PHP
- Installation
- Registering PHP with IIS
- Validating existing PHP installations and fixing configuration issues
- Switching between PHP versions
- Checking phpinfo() output
- Configuring Error Reporting
- Configuring Runtime Limits
- Configuring All PHP Settings
- Enabling or Disabling PHP Extensions
- Configuring Step 1: Install IIS and PHP
- 1.1. Install IIS
- To install IIS on Windows Server 2012
- To install IIS on Windows 8
- 1.2. Download and Install PHP Manually
- To download and install PHP and WinCache
- To test your PHP installation
- 1.3. Add Your PHP Application
- To add a PHP web application
- See also
Using PHP Manager for IIS to setup and configure PHP
PHP Manager is not a Microsoft-owned or supported product.
Installation
From the Downloads page select the installation package that is appropriate for your target machine. Download and run the installer, which will install and register PHP Manager’s binaries with IIS. Note that only IIS versions 7.0 and above are supported. After installation is complete, launch the IIS Manager and find the «PHP Manager» feature:
When opened, the «PHP Manager» feature provides a configuration overview for the PHP installation that is registered with IIS and is currently active. If no PHP is registered with IIS, then the only action that can be performed is the registation of a new PHP version.
Registering PHP with IIS
To register a new PHP version with IIS, first you need to download the zip archive with PHP binaries from http://windows.php.net/ and then extract the files from it into a folder of your choice. Note that you can also install PHP by using Web Platform Installer or the Windows installer from http://windows.php.net/ — the PHP Manager can be used to manage those PHP installations as well.
Click on «Register new PHP version» task and then provide the full path to the location of the main php executable file: php-cgi.exe:
After clicking OK the new PHP version will be registered with IIS and will become active. This means that all the sites on this IIS server by default will use this PHP version.
Validating existing PHP installations and fixing configuration issues
In order for PHP to run properly on IIS there is a set of recommended settings that need to be configured in IIS and PHP. PHP Manager checks if all of the recommended settings are configured correctly. If some settings are not configured properly then you can use PHP Manager to fix those settings.
When some configuration settings are configured incorrectly you will see a warning message when you open PHP Manager:
After clicking on «View Recommendations» link you can see all the configuration issues that exist in your PHP installation. You can review each issue description and the recommended corrective action. You can also select which configuration issues you want to be fixed:
Switching between PHP versions
After multiple PHP versions have been registered with IIS, you can use PHP Manager to easily switch between the versions on a server and site level. This means that you can configure some IIS sites to use one PHP version, while other sites use different version.
Checking phpinfo() output
phpinfo() function in PHP provides very detailed information about all aspects of PHP runtime configuration. To check the phpinfo() output from within PHP Manager use the «Check phpinfo()» task.
Configuring Error Reporting
You can use PHP Manager to configure error reporting level in PHP. If IIS is used on a development machine then you may want to use verbose error reporting in order to see all the errors, warnings and notices from your PHP application right away. If IIS is used as a production server, then error reporting level is less verbose and errors are logged in a log file, but never communicated to HTTP client.
Configuring Runtime Limits
Various timeouts and limits can be configured in the «PHP Runtime Limits» page:
Configuring All PHP Settings
All existing PHP settings can be added, removed and modified in the «PHP Settings» page.
Enabling or Disabling PHP Extensions
PHP extensions can be enabled or disabled in the «PHP Extensions» page:
Configuring Step 1: Install IIS and PHP
In this step of building a PHP website, you install IIS and FastCGI, download and install PHP and the WinCache extension, and upload your PHP application.
When you are done, make sure that IIS and the PHP are installed, and your PHP application has been added to your website. Then go on to Step 2: Configure PHP Settings.
1.1. Install IIS
To install IIS, use the following steps:
To install IIS on Windows Server 2012
- On the Start page, click the Server Manager tile, and then click OK.
- In Server Manager, select Dashboard, and click Add roles and features.
- In the Add Roles and Features Wizard, on the Before You Begin page, click Next.
- On the Select Installation Type page, select Role-based or Feature-based Installation and click Next
- On the Select Destination Server page, select Select a server from the server pool, select your server, and click Next.
- On the Select Server Roles page, select Web Server (IIS), and then click Next.
- On the Select Features page, note the preselected features that are installed by default, and then select CGI. This selection also installs FastCGI, which is recommended for PHP applications.
- Click Next.
- On the Web Server Role (IIS) page, click Next.
- On the Select Role Services page, note the preselected role services that are installed by default, and then click Next.
To install IIS on Windows 8
- On the Start page, type Control Panel, and then click the Control Panel icon in the search results.
- In Control Panel, click Programs, and then click Turn Windows features on or off.
- In the Windows Features dialog box, click Internet Information Services, note the preselected features that are installed by default, and then select CGI. This selection also installs FastCGI, which is recommended for PHP applications.
- Click OK.
- To verify that IIS installed successfully, type the following into a web browser: http://localhost You see the default IIS Welcome page.
1.2. Download and Install PHP Manually
The procedures in this section guide you to install PHP Manually:
- Download PHP and the WinCache extension.
- Install PHP and WinCache.
- Add the PHP installation folder to the Path environment variable.
- Set up a handler mapping for PHP.
- Add default document entries for PHP.
- Test your PHP installation.
To keep this procedure simple, install the WinCache extension but do not configure it. You will configure and test WinCache in Step 2: Configure PHP Settings.
To download and install PHP and WinCache
- Open your browser to Windows for PHP Download Page and download the PHP non-thread-safe zip package.
- Download the WinCache extension from the List of Windows Extensions for PHP.
- Extract all files in the PHP .zip package to a folder of your choice, for example C:\PHP\ .
- Extract the WinCache .zip package to the PHP extensions folder (\ext), for example C:\PHP\ext . The WinCache .zip package contains one file (Php_wincache.dll).
- Open Control Panel, click System and Security, click System, and then click Advanced system settings.
- In the System Properties window, select the Advanced tab, and then click Environment Variables.
- Under System variables, select Path, and then click Edit.
- Add the path to your PHP installation folder to the end of the Variable value, for example ;C:\PHP . Click OK.
- Open IIS Manager, select the hostname of your computer in the Connections panel, and then double-click Handler Mappings.
- In the Action panel, click Add Module Mapping.
- In Request path, type *.php.
- From the Module menu, select FastCgiModule.
- In the Executable box, type the full path to Php-cgi.exe, for example C:\PHP\Php-cgi.exe .
- In Name, type a name for the module mapping, for example FastCGI.
- Click OK.
- Select the hostname of your computer in the Connections panel, and double-click Default Document.
- In the Action panel, click Add. Type Index.php in the Name box, and then click OK.
- Click Add again. Type Default.php in the Name box, and then click OK.
To test your PHP installation
- Open a text editor, for example Notepad, as Administrator.
- In a new file, type the following text:
- Save the file as C:\inetpub\wwwroot\Phpinfo.php .
- Open a browser and enter the following URL: http://localhost/phpinfo.php A nicely formatted webpage is displayed showing the current PHP settings.
1.3. Add Your PHP Application
Once you have IIS and PHP installed, you can add a PHP application to your web server. This section describes how to set up your PHP application on an IIS web server with PHP installed. It does not explain how to develop a PHP application.
To add a PHP web application
- Open IIS Manager.
- For Windows Server 2012, on the Start page click the Server Manager tile, and then click OK. On the Server Manager Dashboard, click the Tools menu, and then click Internet Information Services (IIS) Manager.
- For Windows 8, on the Start page type Control Panel, and then click the Control Panel icon in the search results. On the Control Panel screen, click System and Security, click Administrative Tools, and then click Internet Information Services (IIS) Manager.
- In the Connections pane, right-click the Sites node in the tree, and then click Add Website.
- In the Add Website dialog box, type a friendly name for your website in the Site name box.
- If you want to select a different application pool than the one listed in the Application Pool box, click Select. In the Select Application Pool dialog box, select an application pool from the Application Pool list and then click OK.
- In the Physical path box, type the physical path of the website’s folder, or click the browse button (. ) to navigate the file system to find the folder.
- If the physical path that you entered in step 5 is to a remote share, click Connect as to specify credentials that have permission to access the path. If you do not use specific credentials, select the Application user (pass-through authentication) option in the Connect As dialog box.
- Select the protocol for the website from the Type list.
- The default value in the IP address box is All Unassigned. If you must specify a static IP address for the website, type the IP address in the IP address box.
- Type a port number in the Port text box.
- Optionally, type a host header name for the website in the Host Header box.
- If you do not have to make any changes to the site, and you want the website to be immediately available, select the Start Web site immediately check box.
- Click OK.