40

We've installed PHP on a Windows Server 2008 R2 box using Web Platform Installer (WPI) 3.0.x.

However, I'd like to uninstall PHP (5.3 in particular, leaving 5.2 as-is). Unfortunately, an uninstall option doesn't exist in Programs and Features, and in the past I've only upgraded PHP installs, and not had to do an uninstall. (Based on the lack of answers I've found online, it seems this is the case generally as well.)

I realize that I can leave the extra install there, but for the sake of a having a clean server, and making it rather obvious what version of PHP is being used, I'd like to remove the installation.

I suppose I could also remove the install directory - C:\Program Files (x86)\PHP\v5.3 - but that doesn't feel right.

PHP Manager is also installed (also via WPI), but I see no way to remove an installation, only add.

3 Answers 3

35

This link has instructions on how to manually remove a version of PHP from IIS on Windows 7. I would think the instructions for Windows Server 2008 would be similar. It seems to be instructing you to edit the applicationHost.config file and delete the folder.

http://forums.iis.net/t/1178803.aspx

From the link:

Open %userprofile%\documents\iisexpress\config\applicationhost.config file and:

  1. Find following entry (or similar entry) in applicationhost.config file and comment it or delete it.

    <application fullPath="C:\Program Files\iis express\PHP\v5.2\php-cgi.exe" monitorChangesTo="php.ini" activityTimeout="600" requestTimeout="600" instanceMaxRequests="10000">
        <environmentVariables>
            <environmentVariable name="PHP_FCGI_MAX_REQUESTS" value="10000" />
            <environmentVariable name="PHPRC" value="C:\Program Files\iis express\PHP\v5.2" />
        </environmentVariables>
    </application>
    
  2. Find following entry in hanlders section and comment this as well or delete.

    <add name="PHP52_via_FastCGI" path="*.php" verb="GET,HEAD,POST" modules="FastCgiModule" scriptProcessor="C:\Program Files (x86)\iis express\PHP\v5.2\php-cgi.exe" resourceType="Either" />
    
  3. By default Web Platform Installer installs PHP to %programfiles%\iis express\php. so open %programfiles%\iis express\php\ folder and delete the php version folder that you no longer need (don't forget to remove relavant entries from applicationhost.config as mentioned in step 1 and 2 above)

5
  • Score! And you included the text from the page. I wish I could +2 this, but sadly all I can do is vote up and accept. :D Dec 8, 2011 at 23:18
  • 11
    For me, PHP was in C:\Program Files (x86)\PHP and applicationHost.config was in C:\Windows\System32\inetsrv\config.
    – sfarbota
    Oct 23, 2014 at 18:56
  • You also need to go to Control Panel and uninstall 'php manager' and 'php cache extension' Nov 22, 2016 at 21:12
  • @ShadiNamrouti - Not necessairly you may want the php manager for PHP ON IIS not on IIS Express big difference.
    – JonH
    Apr 18, 2019 at 14:27
  • This helped me solve my PHP/IIS setting issues, thank you much!
    – OverMars
    Dec 30, 2020 at 21:14
30

1) In IIS Manager, click your machine in left pane. Then click "Handler Mappings" in right pane. Find the "PHP5?_via_FastCGI" for the PHP version you want to remove, right click then "Remove".

2) In IIS Manager, click your machine in left pane. Then click "FastCGI Settings" in right pane. Find the "C:\Program Files (x86)\PHP\v5.?\php.ini" for the PHP version you want to remove, right click then "Remove".

3) Go to Control Panel, "Uninstall a Program". Uninstall those extensions for PHP 5.? (WinCache etc)

4) Run Windows Explorer, remove folder "C:\Program Files (x86)\PHP\v5.?".

4
  • 1
    This was the better solution for me as there was no mention of PHP at all in the the files listed in the accepted answer.
    – Burgi
    May 31, 2016 at 9:57
  • This worked for me except for (3) - there was nothing listed for PHP at all in the add/remove programs
    – Logos
    Oct 17, 2016 at 16:09
  • 1
    For point #3 I found the win cache extension not in control panel but in the Apps section of the Settings app in Windows Server 2016.
    – Vincent
    Jan 31, 2018 at 23:03
  • I've used this answer as uninstall steps on Windows Server 2019 + IIS. Few obvious modifications, Handler was named just "PHP_via_FastCGI" and it pointed to "C:\Program Files\PHP\" as I had PHP x64 installed. Likewise, PHP was 7.3 and 7.4. And part of the answer says "FastCGI Settings" points to php.ini, it actually points to "php-cgi.exe" and as part of it's settings it has "monitor file" part that points to "php.ini". Extension wasn't installed so "Add or Remove Programs" was empty. I also found some remains of PHP v5.3 in the process, that was in Program Files (x86) folder, deleted it all.
    – LuxZg
    Jun 19, 2021 at 21:16
1

For me,windows server 2016, PHP was in C:\Program Files\PHP and applicationHost.config was in C:\Windows\System32\inetsrv\config>>file Deleted folder with PHP v7.4 and from file named applicationHost.config:

<application fullPath="C:\Program Files\PHP\v7.4\php-cgi.exe" monitorChangesTo="php.ini" activityTimeout="600" requestTimeout="600" instanceMaxRequests="10000">
                <environmentVariables>
                    <environmentVariable name="PHP_FCGI_MAX_REQUESTS" value="10000" />
                    <environmentVariable name="PHPRC" value="C:\Program Files\PHP\v7.4" />
                </environmentVariables>
            </application>


<add name="PHP_via_FastCGI4" path="*.php" verb="GET,HEAD,POST" modules="FastCgiModule" scriptProcessor="C:\Program Files\PHP\v7.4\php-cgi.exe" resourceType="Either" />

After that restarted services.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.