Instaling PHP on Windows with IIS

2020-08-05 10:50发布

问题:

How can I install PHP on a Windows machine using Internet Information Services (IIS)?

回答1:

This is more a guide than a question in the hope it helps many users who are looking for an easy beginner's proof installation guide:

First of all you need to have installed and running IIS on your machine, IIS doesn't comes by default, you have to add the characteristic from control panel -> Programs -> Windows Characteristics.

I had successfully installed PHP under IIS 5.1 (WinXP), IIS 7.5.7x (Win7) and IIS 10.0.10x (Windows 10) both x32 and x64 platforms and works great.

I resumed this guide in 10 easy steps:

  1. Download the PHP version you like from http://windows.php.net/download/ make sure you download the Non-Thread Safe (NTS) versions of PHP.
  2. Extract the files into 'C:\PHP\'.
  3. Open then 'Internet Information Services Administrator IIS'.
  4. Select the root item in the left panel.
  5. Double click on 'Handler Mappings' (Asignaciones de Controlador).
  6. On the right side panel click on 'Add Module Mapping' (Agregar asignacion de modulo..).
  7. Setup the values like this:

    Request Path: *.php Module: FastCgiModule Executable: C:\PHP\php-cgi.exe Name: PHP_FastCGI Request Restrictions: Folder or File, All Verbs, Access: Script

  8. Install 'vcredist_x64.exe' o 'vcredist_x86.exe' (Visual C++ 2012 Redistributable) https://www.microsoft.com/en-US/download/details.aspx?id=30679

  9. Setup your 'C:\PHP\php.ini', especially set the 'extension_dir ="C:\PHP\ext"'.

  10. Reset Internet Information Services: In a command console type IISRESET.

Congratulations you have now PHP working on Windows!

Optionally you can install the 'PHP Manager for IIS' https://phpmanager.codeplex.com/ which is of great help to setup the ini file and track the log of errors (sadly It doesn't works on Win10 as far i know).

Remember to set 'index.php' as one of the default documents for IIS.

Glad to help.