Share via


Step 2: Configure PHP Settings

 

Applies To: Windows Server 2012 R2, Windows Server 2012

In this step of building a PHP website on IIS, you configure the WinCache PHP extension, configure PHP settings, and download and configure any other PHP extensions that your application requires.

When you complete these tasks, continue to Step 3: Configure PHP Application Security.

2.1. Configure WinCache

Before you perform this procedure, you should download in install PHP and WinCache as described in 1.3. Download and Install PHP Manually. For more information about WinCache, see 2.1. Plan WinCache Configuration.

To configure the WinCache PHP extension

  1. In Windows Explorer, open your PHP installation folder, for example C:\PHP.

  2. Choose either the php.ini - development or php.ini - production file, and rename it php.ini.

  3. In a text editor, open the php.ini file and added the following line at the end of the file: extension = php_wincache.dll.

  4. Save and close the php.ini file.

  5. Recycle the IIS Application Pools for PHP to pick up the configuration changes.

To view WinCache configuration and other PHP settings

  1. Open a text editor.

  2. In a new file, type the following text: <?php phpinfo(); ?>

  3. Save the file as c:\inetpub\wwwroot\phpinfo.php.

  4. Open a browser and enter the following URL: https://localhost/phpinfo.php

    A nicely formatted web page is displayed showing the current PHP settings. The WinCache settings appear in a section called wincache.

    Warning

    Delete the phpinfo.php file when it’s no longer needed.

2.2. Configure Other PHP Settings

The following procedure explains how to configure PHP settings in the php.ini file. For more information about PHP settings, see 2.2. Plan Other PHP Settings.

To configure a PHP setting

  1. In Windows Explorer, open your PHP installation folder, for example C:\PHP.

  2. In a text editor, open the php.ini file.

  3. Search the file for the setting you want to change.

    If the setting is commented out (line begins with a semicolon [;]), delete the semicolon and set the value. If you can’t find the setting, add the line to the end of the file.

  4. Save and close the php.ini file.

  5. Recycle the IIS Application Pools for PHP to pick up the configuration changes.

2.3 Configure PHP Extensions

The following procedure shows how to download and install a PHP extension. For information about PHP extensions, see 2.3 Plan PHP Extensions.

To configure a PHP extension

  1. Download the PHP extension you want from the list of Windows extensions for PHP.

  2. Extract the extension zip package to the PHP extensions folder (\ext), for example C:\PHP\ext.

  3. In Windows Explorer, open your PHP installation folder, for example C:\PHP.

  4. In a text editor, open the php.ini file.

  5. Search the file for the extension you want to configure.

    If the extension is commented out (line begins with a semicolon [;]), delete the semicolon. If you can’t find the extension, add it to the end of the file. A line that adds an extension is in the form: extension = extension_name.dll. For example: extension = php_soap.dll.

  6. Save and close the php.ini file.

  7. Recycle the IIS Application Pools for PHP to pick up the configuration changes.

See Also