gpt4 book ai didi

php - 使用 Visual Studio 在 IIS Express 上启用 PHP(无 WebMatrix)

转载 作者:IT王子 更新时间:2023-10-29 00:20:14 26 4
gpt4 key购买 nike

我正在开发这个主要是 .NET 的 Web 应用程序,但有一部分是用 PHP 编写的。在我的开发环境中,IIS Express 是我选择的 Web 服务器,因此我更愿意让 PHP 和 .NET 在此环境中协同工作。

第一次天真的尝试:将 PHP 脚本放入网站,然后在浏览器中加载它们。结果是一个 HTTP Error 404.21 - Not Found,建议如下:

  • Install PHP and configure handlers correctly.
  • Install and enable PHP for this web site.
  • If you are using WebMatrix, follow these steps to enable PHP:
    • Open the web site in WebMatrix.
    • Select the Site workspace and click on Settings.
    • Check the "Enable PHP" checkbox to install and enable PHP.

没有使用 WebMatrix,这对我没有任何帮助。然后,我继续在 Google 上深入搜索与 IIS Express 和 PHP 相关的任何内容。从我读到的内容来看,它应该是可行的,但我发现的关于这个主题的一切似乎都假设我的 IDE 是 WebMatrix。它不是。

有谁知道是否可以在 IIS Express 上安装并将其配置为与基于 Visual Studio 的网站一起使用,而无需安装 WebMatrix?如果是,如何?

最佳答案

IIS Express 支持没有 Web 矩阵的 PHP。您可以单独安装 IIS Express 并使其与 Visual Studio 一起使用。为此,您需要 Visual Studio 2010 SP1。

  1. 从此链接下载 IIS Express:Internet Information Services (IIS) 7.5 Express

  2. 在 Visual Studio 中配置您的网站/WebApplication 项目以使用 IIS Express。看看这个线程 How do I configure a website project to use IIS Express?

  3. 要在 IIS Express 上启用 PHP,请安装 PHP 并更新 applicationhost.config (%userprofile%\documents\iisexpress\config\applicationhost.config)。您可以使用位于 IIS Express 安装文件夹中的 appcmd.exe 版本来执行此操作。参见 this link了解详情。

如果一切都安装在美国英语版 Windows 的默认位置,命令将是:

"C:\Program Files (x86)\IIS Express\appcmd.exe" set config /section:system.webServer/fastCGI /+[fullPath='"C:\Program Files (x86)\PHP\php-cgi.exe"']
"C:\Program Files (x86)\IIS Express\appcmd.exe" set config /section:system.webServer/handlers /+[name='PHP_via_FastCGI',path='*.php',verb='*',modules='FastCgiModule',scriptProcessor='"C:\Program Files (x86)\PHP\php-cgi.exe"',resourceType='Unspecified']

请注意,如果 php-cgi.exe 的完整路径中有空格,则必须将路径用单引号和双引号括起来,如上例所示。

最后,如果您没有 VS 2010 SP1,您可能应该看看这篇文章:Debug Your .NET Web Project With IIS Express

关于php - 使用 Visual Studio 在 IIS Express 上启用 PHP(无 WebMatrix),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6099143/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com