web.config IIS中的PHP(或任何其他形式)CGI配置 [英] PHP (or whatever) CGI configuration in web.config IIS

查看:226
本文介绍了web.config IIS中的PHP(或任何其他形式)CGI配置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近使用



在安装结束时使用自定义操作,我使用



请注意本地,这确认设置来自本地web.config,而不是来自applicationhost.config文件。


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:

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.

解决方案

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)

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

这篇关于web.config IIS中的PHP(或任何其他形式)CGI配置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆