9

I recently developed an installer for a web application (Yes, Web Application with an Installer) using Wix Tool Set.

The wizard guides the user to obtain all the basic information the site need for the installation, and looks like below:

enter image description here

Using custom actions at the end of the installation I configured dynamically the IIS to handler CGI using the documentation, to configure FastCGI to Host PHP, Python, Applications. There are a lot of steps and development to achieve this results, but the problem is here:

I installed the application and everything works fine, but, if I uninstall or install another Instance or another WebApplication the handlers configure by IIS is like globally and always points to the first installed. (The problem occurs when I uninstall the application) The applicationHost.config located in C:\Windows\System32\inetsrv\config that is the configuration of IIS has the "config" like global.

<handlers accessPolicy="Read, Script">
            <add name="PHP-FastCGI" path="*.php" verb="*" modules="FastCgiModule" scriptProcessor="E:\CIM_dev\bin\php-v5.6\php-cgi.exe" resourceType="Either" />
            <add name="CGI-exe_2" path="*.exe" verb="*" modules="CgiModule" resourceType="File" requireAccess="Execute" allowPathInfo="true" />
            <add name="TRACEVerbHandler2" path="*" verb="TRACE" modules="ProtocolSupportModule" requireAccess="None" />
            <add name="OPTIONSVerbHandler2" path="*" verb="OPTIONS" modules="ProtocolSupportModule" requireAccess="None" />
            <add name="StaticFile2" path="*" verb="*" modules="StaticFileModule,DefaultDocumentModule,DirectoryListingModule" resourceType="Either" requireAccess="Read" />
        </handlers>

My question is, is there any way to do this configuration for each web site into the web.config? I've been trying all stuff without success.

xsami
  • 1,312
  • 16
  • 31
wrivas
  • 509
  • 6
  • 12

1 Answers1

6

So if I understand it right, you want to move php handlers from server/website level to individual applications. Why dont you add a web.config file within your php application folder and move the application specific handlers there.

  1. https://stackoverflow.com/a/35332431/1766402 - check this answer (I am hoping you have CGI enabled in IIS?). To do this via wix, can you add the following command within a custom action and execute. This will unlock the parent config file.

%windir%\system32\inetsrv\appcmd.exe unlock config "SiteName/app1" -section:system.webServer/handlers

  1. Within the PHP application folder (let's say c:\php\app1) create a web.config file with the following content:

<?xml version="1.0"?>
<configuration>
    <system.webServer>      
        <handlers>
            <add name="PHPviaFastCGI" path="*.php" verb="*" modules="FastCgiModule" scriptProcessor="C:\Users\axputhe\Documents\PHP\php-cgi.exe" resourceType="Unspecified" />
        </handlers>
    </system.webServer> 
</configuration>
  1. Now if you look at your application within IIS Manager you should see something like this (App Dir -> Handler Mappings)

enter image description here

Note "local" this confirms that the setting is coming from your local web.config and not from the applicationhost.config file.

Community
  • 1
  • 1
Isaiah4110
  • 9,855
  • 1
  • 40
  • 56
  • I try this and always get: This configuration section cannot be used at this path. This happens when the section is locked at a parent level. Locking is either by default (overrideModeDefault="Deny"), or set explicitly by a location tag with overrideMode="Deny" or the legacy allowOverride="false". – wrivas Feb 10 '17 at 15:50
  • looks like your handler section is locked at parent level. Can you try the updated section in the answer? – Isaiah4110 Feb 10 '17 at 16:43
  • This section can be unlocked in applicationHost.config but the goals is to avoid user intervention. As I said, I has try lots of tricks without success :( – wrivas Feb 10 '17 at 18:20
  • Can you add the unlock command (that I added to the answer) within wix using a custom action? – Isaiah4110 Feb 10 '17 at 21:50
  • @wrivas - can you confirm whether it worked? If it worked can you please mark it as the answer. – Isaiah4110 Feb 14 '17 at 18:55
  • 1
    Yes, now I have another error but I can handle it. With the help of [https://www.iis.net/configreference/system.webserver/fastcgi] and you. Thank you – wrivas Feb 15 '17 at 15:59