PHP 和 ASP.Net 可以在 IIS 7.5 中的同一个网站中一起运行吗?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4761769/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Can PHP and ASP.Net run together within the same web site in IIS 7.5?
提问by Aaron
A portion of our site is done in PHP and a portion of our site is done in ASP.Net. We just set up a new web server with Windows Server 2008 R2 which has IIS 7.5 installed.
我们网站的一部分是用 PHP 完成的,我们网站的一部分是用 ASP.Net 完成的。我们刚刚使用安装了 IIS 7.5 的 Windows Server 2008 R2 设置了一个新的 Web 服务器。
I understand that IIS 7+ supports PHP, but can PHP and ASP.Net run side-by-side within a single web site in IIS, or would I have to set up one web site for the PHP pages and one web site for the ASP.Net pages?
我知道 IIS 7+ 支持 PHP,但是 PHP 和 ASP.Net 可以在 IIS 的单个网站中并行运行,还是我必须为 PHP 页面设置一个网站,为 PHP 页面设置一个网站ASP.Net 页面?
采纳答案by Cylon Cat
You should be able to run both in the same site, but be sure that the AppPool for the site runs a "classic" ASP.NET pool configuration. The default AppPool routes everything through ASP.NET, and you won't want that for your PHP pages.
您应该能够在同一个站点中运行两者,但请确保站点的 AppPool 运行“经典”ASP.NET 池配置。默认的 AppPool 通过 ASP.NET 路由所有内容,您不会希望在您的 PHP 页面中使用它。
Other than that, you should be fine. Query strings, files, and back-end databases will be the best way to share data between pages.
除此之外,你应该没问题。查询字符串、文件和后端数据库将是在页面之间共享数据的最佳方式。
回答by Joel Etherton
Yes you can use both under the same website. Since the file extensions are mapped to specific external processes, they are called independently. You can even use Asp.Net to secure .php files with FormsAuthentication by implementing wildcard mappings within IIS (I know 6/7 have this, not sure about 5). Mixing data across them is tricky because they will have separate external processes and thus separate sessions. Most cookies will be readable across both, but secured cookies will not be.
是的,您可以在同一个网站下使用两者。由于文件扩展名映射到特定的外部进程,因此它们被独立调用。您甚至可以使用 Asp.Net 通过在 IIS 中实现通配符映射来使用 FormsAuthentication 保护 .php 文件(我知道 6/7 有这个,不确定 5)。在它们之间混合数据是很棘手的,因为它们将具有单独的外部进程,因此具有单独的会话。大多数 cookie 都可以在两者之间读取,但安全 cookie 不会。
回答by foxontherock
Yes you can, but watch out for this:
是的,你可以,但要注意这一点:
If you have a wordpress on your "root", and asp.net apps in folders under it
如果您的“root”上有 wordpress,并且其下的文件夹中有 asp.net 应用程序
(e.g. http://root.com/aspnetapp1/), and if you follow these suggestionsabout "urlrewrite" for permalinks in wordpress, you can have trouble if you try to configure "wildcard handlers" in the apsnetapp1.
(例如http://root.com/aspnetapp1/),并且如果您遵循这些关于 wordpress 中永久链接的“urlrewrite”的建议,如果您尝试在 apsnetapp1 中配置“通配符处理程序”,您可能会遇到麻烦。
To avoid issues, the web.config of the wordpress root app must also have that setting:
为避免出现问题,wordpress 根应用程序的 web.config 也必须具有该设置:
<location path="." inheritInChildApplications="false">
<system.webServer>
...
</system.webServer>
</location>
Or else, your wildcard handler will never raise because index.php from root will catch all your requests to url like: http://root.com/aspnetapp1/api/*
否则,您的通配符处理程序将永远不会引发,因为来自 root 的 index.php 将捕获您对 url 的所有请求,例如:http: //root.com/aspnetapp1/api/*
回答by Wazy
Yes, it will be not a problem. Even some Windows Shared Hosts offer PHP plans - Windows Hosting PHP.
是的,这不会有问题。甚至一些 Windows 共享主机也提供 PHP 计划 - Windows Hosting PHP。
回答by Apache
Yes, PHP can be seamlessly implemented into ASP.NET 3.5 / 4.0
是的,PHP 可以无缝实现到 ASP.NET 3.5 / 4.0
Go to http://phalanger.codeplex.com/(or http://www.php-compiler.net/) and download the latest version of Phalanger. Install into Visual Studio and voila!
转到http://phalanger.codeplex.com/(或http://www.php-compiler.net/)并下载最新版本的 Phalanger。安装到 Visual Studio 中,瞧!
Phalanger – the PHP compiler for .NET
Welcome to Phalanger – full-featured PHP runtime & compiler for .NET/Mono frameworks. Phalanger is modern open-source implementation of PHP, compatible with the vast array of existing PHP code. In addition Phalanger gives PHP-application developers lot of new possibilities; from improving performance and using modern environments, to taking advantage of seamless unique .NET integration.
Phalanger – .NET 的 PHP 编译器
欢迎使用 Phalanger – 用于 .NET/Mono 框架的全功能 PHP 运行时和编译器。Phalanger 是 PHP 的现代开源实现,与大量现有的 PHP 代码兼容。此外,Phalanger 为 PHP 应用程序开发人员提供了许多新的可能性;从提高性能和使用现代环境,到利用无缝独特的 .NET 集成。
回答by Do Nhu Vy
ASP.NET and PHP Support
Develop, deploy and easily manage Web applications using your choice of languages. From ASP.NET to PHP, IIS7 provides a powerful and flexible Web server environment for the world's most popular Web applications.
ASP.NET 和 PHP 支持
使用您选择的语言开发、部署和轻松管理 Web 应用程序。从 ASP.NET 到 PHP,IIS7 为世界上最流行的 Web 应用程序提供了强大而灵活的 Web 服务器环境。
(Source: http://www.iis.net/overview/choice/aspnetandphpsupport)
(来源:http: //www.iis.net/overview/choice/aspnetandphpsupport)
I tried put a test.php
file (with conent: <?php phpinfo(); ?>
) to existing ASP.NET website (use real server at https://somee.com). I knew that ASP.NET and PHP have worked together.
我尝试将test.php
文件(包含内容:)<?php phpinfo(); ?>
放到现有的 ASP.NET 网站(在https://somee.com使用真实服务器)。我知道 ASP.NET 和 PHP 已经一起工作了。
Read more:
http://www.w3schools.com/aspnet/webpages_php.asp
https://technet.microsoft.com/en-us/library/hh994592.aspx
阅读更多:
http: //www.w3schools.com/aspnet/webpages_php.asp
https://technet.microsoft.com/en-us/library/hh994592.aspx
回答by davidbcn
You can run both on the same site, but won't be able to talk to each other unless you setup some sort of messaging system or share storage.They are basically applications of complete different nature.
您可以在同一个站点上运行两者,但除非您设置某种消息传递系统或共享存储,否则它们将无法相互交谈。它们基本上是完全不同性质的应用程序。
Another possibility is to call your .NET code from PHP:
另一种可能性是从 PHP 调用您的 .NET 代码:
A piece of code written in C# like this:
用C#写的一段代码是这样的:
string javascript = "";
Microsoft.Ajax.Utilities.Minifier m = new Microsoft.Ajax.Utilities.Minifier();
Microsoft.Ajax.Utilities.CodeSettings settings = new Microsoft.Ajax.Utilities.CodeSettings();
settings.OutputMode = Microsoft.Ajax.Utilities.OutputMode.SingleLine;
settings.PreserveFunctionNames = false;
string minified = m.MinifyJavaScript(javascript, settings);
Will look like this on PHP:
在 PHP 上看起来像这样:
$minifier = netMinifier::Minifier_Constructor();
$settings = netCodeSettings::CodeSettings_Constructor();
$csssettings = \ms\Microsoft\Ajax\Utilities\netCssSettings::CssSettings_Constructor();
$settings->OutputMode(\ms\Microsoft\Ajax\Utilities\netOutputMode::SingleLine());
$settings->PreserveFunctionNames(FALSE);
$settings->QuoteObjectLiteralProperties(TRUE);
$result = $minifier->MinifyStyleSheet($css, $csssettings, $settings)->Val();
From:
从:
http://www.drupalonwindows.com/en/blog/calling-net-framework-and-net-assemblies-php
http://www.drupalonwindows.com/en/blog/calling-net-framework-and-net-assemblies-php
回答by Wazy
ASPand PHPcan be used on windows boxes. As long as they're completely separate and aren't dependent on each other. For example, using query strings (i.e file.php?var=1&var2=bla)
things get messy when you need to transfer those variables over to the ASP file or vice versa.
ASP和PHP可以在 windows box 上使用。只要它们是完全独立的,并且不相互依赖。例如,(i.e file.php?var=1&var2=bla)
当您需要将这些变量传输到 ASP 文件或反之亦然时,使用查询字符串会变得很混乱。
So as long as the 2 systems are totally independent of each other, then it should work fine.
所以只要这两个系统完全相互独立,那么它应该可以正常工作。
You may also find some incompatibility with cookiesand sessions. Those too can be passed but not easily.
您可能还会发现与cookie和会话的某些不兼容。那些也可以通过,但并不容易。