【问题标题】:How do you configure WebMatrix to run PHP on *.htm, *.html files?如何配置 WebMatrix 以在 *.htm、*.html 文件上运行 PHP?
【发布时间】:2012-08-05 18:19:13
【问题描述】:

我正在使用 WebMatrix 在本地运行一个 PHP 网站。该站点在 *.html 文件中使用 PHP。默认情况下,WebMatrix 不允许这样做。如何配置 WebMatrix 以便 PHP 运行?

(请注意,我正在回答我自己的问题)

【问题讨论】:

    标签: php webmatrix iis-express


    【解决方案1】:

    您需要编辑文件:

    %USERPROFILE%\Documents\IISExpress\config\applicationhost.config
    

    (例如,“C:\Users\Marcus\Documents\IISExpress\config\applicationhost.config”)

    你会注意到这样一行:

    <add name="PHP53_via_FastCGI" path="*.php" verb="GET,HEAD,POST" modules="FastCgiModule" scriptProcessor="C:\Program Files (x86)\iis express\PHP\v5.3\php-cgi.exe" resourceType="Either" />
    

    您可以通过添加新行来添加其他文件扩展名:

    <add name="PHP53_via_FastCGI_html" path="*.html" verb="GET,HEAD,POST" modules="FastCgiModule" scriptProcessor="C:\Program Files (x86)\iis express\PHP\v5.3\php-cgi.exe" resourceType="Either" />
    <add name="PHP53_via_FastCGI_htm" path="*.htm" verb="GET,HEAD,POST" modules="FastCgiModule" scriptProcessor="C:\Program Files (x86)\iis express\PHP\v5.3\php-cgi.exe" resourceType="Either" />
    

    为每个 元素赋予唯一的“名称”属性很重要。

    【讨论】:

    • (如果有人正在阅读这篇文章并有更好的解决方案,请告诉我!经过几次尝试,我想不出一种语法可以让我在一个元素中完成所有操作(例如".php,.htm,*.html"))
    • 忽略最后一条评论中的斜体。我想要“.php”两侧的实际星号,
    猜你喜欢
    • 2016-06-05
    • 2015-05-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-11-24
    • 2017-11-07
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多