本文介绍了在Visual Studio(不含WebMatrix)的IIS Express上启用PHP的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在研究主要是.NET的Web应用程序,但是其中一部分是用PHP编写的.在我的开发环境中,IIS Express是我的首选Web服务器,因此,我希望在此环境中使PHP和.NET一起工作.

I am working on this web application which is mostly .NET, but a part is written in PHP. In my development environment, IIS Express is my web server of choice, so I would prefer to get PHP and .NET work together in this environment.

第一次天真尝试:只需将PHP脚本放入网站中,然后将其加载到浏览器中即可.结果是带有以下建议的HTTP Error 404.21 - Not Found:

First naive attempt: Just throw the PHP scripts into the web site, and load them in a browser. The result is an HTTP Error 404.21 - Not Found with the following suggestions:

不使用WebMatrix,这对我没有任何帮助.然后,我将深入研究与IIS Express和PHP在Google上相关的所有内容.从我阅读的内容来看,它应该是可行的,但是我发现的有关该主题的所有内容似乎都假设我的IDE是WebMatrix.不是.

Not using WebMatrix, this does nothing to help me. I then proceed to do a deep trawl of anything related to IIS Express and PHP on Google. From what I read, it should be doable, but everything I find about the subject seems to assume that my IDE is WebMatrix. It isn't.

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

Does anyone know if it is possible to install on IIS Express and configure it to work with a Visual Studio based web site, without having to install WebMatrix? If yes, how?

推荐答案

IIS Express支持不带Web矩阵的PHP.您可以只安装IIS Express,并使它与Visual Studio一起使用.为此,您需要Visual Studio 2010 SP1.

IIS Express supports PHP without Web matrix. You can install just IIS Express alone and make it work with Visual Studio. For this you need Visual Studio 2010 SP1.

  1. 从此链接下载IIS Express: Internet信息服务(IIS)7.5 Express

在Visual Studio中,将WebSite/WebApplication项目配置为使用IIS Express.看看这个线程如何配置网站项目以使用IIS Express?

In Visual Studio configure your WebSite/WebApplication project to use IIS Express. Take a look at this thread How do I configure a website project to use IIS Express?

要在IIS Express上启用PHP,请安装PHP并更新applicationhost.config(%userprofile%\ documents \ iisexpress \ config \ applicationhost.config).您可以使用IIS Express安装文件夹中的appcmd.exe版本进行此操作.参见此链接以获取详细信息.

To enable PHP on IIS Express, install PHP and update applicationhost.config (%userprofile%\documents\iisexpress\config\applicationhost.config). You can use the version of appcmd.exe located in IIS Express installation folder for doing this. See this link for details.

如果所有内容均安装在Windows的英语版本的默认位置,则命令为:

If everything is installed in the default places for US English versions of Windows the commands will be:

"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的完整路径中有空格,则必须像上面的示例一样用单引号和双引号将路径引起来.

Note that if there are spaces in the full path of php-cgi.exe, you MUST enclose the path in single and double quotes as in the example above.

最后,如果您没有VS 2010 SP1,则可能应该看看以下帖子:使用IIS Express调试.NET Web项目

Finally, if you don't have VS 2010 SP1, probably you should take a look at this post: Debug Your .NET Web Project With IIS Express

这篇关于在Visual Studio(不含WebMatrix)的IIS Express上启用PHP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-27 01:23