Tips on getting PHP to work on Windows/IIS
September 02, 2011
PHP | Troubleshooting

Trying to set up php on a Windows server running IIS from scratch can be a challenge. I would recommend first trying out the Microsoft's Web Platform Installer because it is so easy to use, but sometimes that doesn't set things up correctly. In my experience it usually works, but occasionally the installation fails to create a working environment. In such cases it may be easier to do the installation from scratch by downloading and running the correct PHP installer for your system from php.net.

If you decide to install from scratch, the following tips may help you resolve problems you are likely to encounter along the way.


Ads by Google

Posted by ellen at September 02, 2011 09:55 PM


The Tips


  1. Make sure you know which php.ini file is active. If you have installed PHP multiple times it's probably a good idea to remove the old installs.

  2. To save time, make sure file extensions are visible:
    In Windows Explorer, select Folder Options >View tab, and make sure "Hide extensions for known file types" is not checked.

    hide extensions.jpg


  3. After each change to configuration files or file locations, restart IIS and the application pool.

  4. If you make a change to php.ini and restart IIS and the application pool, but the setting change seems to have no effect, check that the setting is listed only ONCE in php.ini.
  5. Make sure that execute permissions are set on the website:
    In IIS 7, select the website. Double-click the Handler Mappings icon.
    Screen shot 2013-03-12 at 3.07.56 PM.jpg
    Then click Edit Feature Permissions... and check Execute
    editFeaturePermissions

  6. Double-check that the extension directory path listed in php.ini matches the path to your php extension directory.


  7. ; Directory in which the loadable extensions (modules) reside.
    ;extension_dir = "./"
    extension_dir = "C:\Program Files\PHP\v5.2\ext"



  8. Make sure that the PATH environment variable contains the path to the php executable.
    for example
    C:\Program Files\PHP\v5.2;
    or
    C:\PHP\;


  9. Now open the php.ini file that is in the PHP folder you just installed.

    Search for and comment out doc_root if it isn't already.

    ; doc_root =

  10. FastCGI configuration
    Install FastCGI
    Download FastCGI for IIS

    Detailed instructions on setting up FastCGI on IIS

    Make sure the extension is in the %windir%\system32\inetsrv" directory, for example:

    C:\WINDOWS\system32\inetsrv\fcgiext.dll
  11. Set up Type associations correctly in fcgiext.ini [Learn More]


    Find and open C:\WINDOWS\system32\inteserv\fcgiext.ini
    The editable sections are toward the bottom of the file. Find the [TYPES] section. This section maps file extensions from the URL with FastCGI applications. Read the examples and add the mappings needed for your setup.

    Example:


    [Types]
    php:/W3SVC/364137164/Root=PHP52_via_FastCGI
    php=PHP52_via_FastCGI


  12. Configure Environment variables in fcgiext.ini.
    Example:

    [PHP52_via_FastCGI]
    ExePath=C:\Program Files\PHP\v5.2\php-cgi.exe
    InstanceMaxRequests=10000
    ActivityTimeout=600
    RequestTimeout=600
    EnvironmentVars=PHP_FCGI_MAX_REQUESTS:10000,PHPRC:%ProgramFiles%\PHP\v5.2


Ads by Google


Ads by Google

 RSS   |   Contact Me


Ads by Google