Install Config Wiki

All about installing, configuring and troubleshooting

User Tools

Site Tools


Sidebar

Wiki Topics

wiki:install_and_configure_php_7.0.26_on_windows_server

Install and Configure PHP 7.0.26 On Windows Server

Obtain the PHP Binaries for Your Windows Operating System and the Visual C++ Redistributables for Visual Studio

  1. Go to http://windows.php.net/download to find and download the appropriate PHP binaries and the corresponding Visual Studio Visual C++ Redistributable.
  2. If you are planning to use FastCGI support in IIS, which you should for performance purposes, then you should download a Non-Thread-Safe version of PHP. Note that the architecture of IIS and the FastCGI extension provide an isolation model that keeps requests separate, removing the need for a thread-safe version.
  3. If your Windows Server has a 32 bit operating system, then download the Zip file for VC14 x86 Non-Thread Safe
  4. If your Windows Server has a 64 bit operating system, then download the Zip file for VC14 x64 Non-Thread Safe
  5. For example, with a 32-bit server, download the ZIP file for Non-Thread Safe named “php-7.0.26-nts-Win32-VC14-x86.zip” and place the Zip file in a new download folder that you created and named for this purpose
  6. Unblock the Zip file from Windows access protection (How? Right-click the file and select Properties, then Click the “Unblock” button where is says this file came from another computer, and then click the Apply button)
  7. Extract the files from this Zip Archive by Right-clicking the Zip File and then left click “Extract All” from the option menu presented
  8. Click “Extract” button and/or Click “Next” button (to proceed with extracting)
  9. After extracting, view the root of the extracted files in Windows Explorer. They should be located in the php-7.0.26-nts-win32-VC15-x86 sub-folder. Remember this location for later. You can use a text editor like Notepad++ to view the “Install.txt” file.

Caution - 500 Errors with Newer PHP Builds: Trying to install PHP 7.2 on either Server 2008 SP2 or Server 2008 R2 requires the use of the VC15 Binaries and the corresponding Visual C++ Redistributable for Visual Studio 2017 (rather than Visual Studio 2015). One or both of these, that is either the PHP 7.2.x build or the C++ Redistributable for Visual Studio 2017, seem to be incompatible with IIS7 and/or those older operating systems. When testing the install of PHP 7.2.0 VC15 with the C++ Redistributable for Visual Studio 2017, the IIS 7 displays a 500 Error - Internal Server Error crashing the FastCGI Module. Also on those 2008 operating systems, you may want to avoid PHP 7.1.x as well, even though PHP 7.1.x build uses a VC14 download that corresponds to using Visual C++ Redistributable for Visual Studio 2015 (rather than 2017). 500 Errors may result using the 7.1 Binaries.

Enable FastCGI Role Service for IIS7

  1. Make sure that you have enabled FastCGI support for IIS7. This is the URL for the source article containing the following listed instructions: https://docs.microsoft.com/en-us/iis/application-frameworks/install-and-configure-php-on-iis/enable-fastcgi-support-in-iis-7-on-windows-server-2008-windows-server-2008-r2-windows-vista-or-windows-7
  2. Note on Prerequisites: If you are enabling FastCGI on Server 2008, you may need to download and install the FastCGI Update for IIS 7 for Windows Server 2008 (KB954946) from here: http://go.microsoft.com/fwlink/?LinkId=131593. This will provide an extra icon for FastCGI Settings in the IIS 7 Management Console. This FastCGI Settings module is in addition to the existing Handler Mappings module.
  3. Note2 on Prerequisites: You may also need or want to install Microsoft IIS 7 Administration Pack 1.0 (x86) on Server 2008 SP2 (x86) from here: http://go.microsoft.com/?linkid=9655656 - (File Name: AdminPack_x86.msi). When you attempt installation using this *.msi file, an alert box may tell you whether this Package is not suitable for your operating system.
  4. Begin Instructions to Enable FastCGI Role Service. First, Open the “Server Manager” and, in the left pane, select the icon for “Roles” (but do not +expand roles)
  5. In the right pane, under Windows Server (IIS), look under the subcategory of Role Services, and click the link on the far right to “Add Role Services”
  6. Under Application Development category, select the checkbox next to “CGI” for installing the “CGI” role service. This enables both the CGI and the FastCGI services.
  7. Click the “Next” button to proceed
  8. Confirm the selections on the Confirm Installation Selection page, and then click the “Install” button
  9. After the “Progress” indicator shows the conclusion of the installation, you will be presented with the “Results” page, hopefully stating that the “Installation Succeeded”
  10. Click the “Close” button

Install the Visual C++ Redistributable for Visual Studio 2015

  1. The “VC14” builds require installation of the Visual C++ Redistributable for Visual Studio 2015 either x64 or x86 depending on whether you are installing the 32bit or 64bit builds of PHP on your Windows server.
  2. Visual Studio 2015 for X64 (64bit) or for x86 (32bit) may be downloaded here: https://www.microsoft.com/en-us/download/details.aspx?id=48145
  3. Now install the downloaded Visual Studio 2015 x86 or x64 redistributable by opening or running the file named VC_redist.x86.exe or VC_Resist.x64.exe as the case may require
  4. Click the checkbox to agree to the license terms for the Microsoft Visual C++ 2015 Redistributable (x86), and click the “Install” button
  5. When the prompt states “Setup Successful,” click the Close button
  6. At this point, maybe restart the IIS service
  7. -Using Windows Explorer, make a new folder named “php” at the root of the C:\ drive. Namely, c:\php
  8. Copy all of the extracted files and folders from the source “php-7.0.26-nts-win32-VC15-x86” sub-folder that you just extracted and paste them into the c:\php folder. In other words, the c:\php folder is the selected target folder of the copy routine.

Configure the php.ini File

  1. In the c:\php folder, open the php.ini-production file using a good text editor like Notepad++ and then “save as” the contents of this file using the new file name “php.ini” and then close (x) both the php.ini-production file (tab) and the new php.ini file (tab) from within Notepad++.
  2. Re-open the php.ini file using Notepad++ text editor and then un-comment and modify certain settings within php.ini as follows:
  3. Set fastcgi.impersonate = 1 ;REMARK 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.
  4. Set cgi.fix_pathinfo = 0 ;REMARK 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.
  5. Set cgi.force_redirect = 0
  6. Set open_basedir = a path pointing to a folder or network path where the content of the Web site(s) is located. (Such as c:\hostdata), or just leave it commented like this “;open_basedir =” without the quotes
  7. Set extension_dir to point to a location where PHP extensions reside. This is typically extension_dir = “./ext”
  8. Set error_log=“C:php_errors.log” ;REMARK This can help with troubleshooting. Alternatively, set error_log = “c:\php\logs\errors_log” and make a new sub-folder in c:php named “logs” and grant the sub-folder “logs” full control write access for both IUSR and IIS_USERS.
  9. Enable the required PHP extension by un-commenting the appropriate lines within the extensions section of the php.ini file. See a further discussion of which extensions to enable.

Set the appropriate paths in the System Environment Variables

  1. Click on Start, Settings, Control Panel, and then double-click on the System icon (using the class view).
  2. Click on the Advanced system settings link in the left column.
  3. From the System Properties window, click on the Advanced tab, and then click on the Environment Variables button at the bottom.
  4. Select the Path variable from the System Variables section, and then click on Edit. Add/Insert: c:\php to your system path. Insert a screen capture here depicting Edit System Variable. Variable Name: Path and Variable Value C:\Windows\system32;C:\Windows;(etc;)C:\php
  5. Click OK until you have exited the System Properties window.

Configure Handler Mappings for FastCGI Module in IIS Manager

  1. Start IIS Manager by clicking on Start, Programs, Administrative Tools, and then Internet Information Services (IIS) Manager.
  2. From the IIS Manager, click on the hostname of your server in the Connections panel on the left.
  3. Double-click on the Handler Mappings icon. Insert a screen capture here depicting IIS and handler mappings
  4. From the Handler Mappings Actions panel, click on Add Module Mapping.
  5. Type the following information into the appropriate text boxes, and then click OK. Request path: *.php then Module : FastCGImodule then Executable: C:\php\php-cgi.exe then Name: FastCGI (insert a screen capture depiction here)
  6. Click OK, and then click Yes.

Configure the default PHP documents in IIS Manager

  1. In the left panel, click on your server's hostname, and then double-click on the Default Document icon.
  2. From the Actions panel on the right, click Add.
  3. Enter index.php as the new default document name, and then click OK.
  4. Enter default.php as the new default document name, and then click OK.
  5. In the left panel, click on your server's hostname.
  6. In the Actions panel on the right, click Restart.

Test Your PHP Installation

  1. Create a new text document, and save it as c:\inetpub\wwwroot\phpinfo.php with the following content:
    <?php phpinfo(); ?>
  2. You can now go to your web browser and see php information at:
    http://localhost/phpinfo.php

If you have Windows Server 2008 without service pack 2 installed, then you may want to download and install Windows Server 2008 Service Pack 2. See: https://www.microsoft.com/en-us/download/confirmation.aspx?id=16468

wiki/install_and_configure_php_7.0.26_on_windows_server.txt · Last modified: 2018/01/02 15:10 (external edit)