在基于 Linux 的服务器上运行 ASP.Net

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1116175/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-03 17:30:49  来源:igfitidea点击:

Running ASP.Net on a Linux based server

asp.netlinuxmono

提问by Anand

For a developer with a Java background, I am interested in exploring software development using the ASP.NET tools/platform as well.

对于具有 Java 背景的开发人员,我也有兴趣探索使用 ASP.NET 工具/平台的软件开发。

Java web applications (.jsp and servlets) can run on many server platforms.

Java Web 应用程序(.jsp 和 servlet)可以在许多服务器平台上运行。

Question: Will a .NET web application be able to run in a Linux based server? Considering the scenario of not being able to use a Windows server for hosting a web app.

问题:.NET Web 应用程序能否在基于 Linux 的服务器中运行?考虑到无法使用 Windows 服务器托管 Web 应用程序的情况。

采纳答案by alastairs

It depends what specific .NET technologies you're using. The Mono Projectprovides an Apache module (mod_mono) for running ASP.NET sites, and from what I gather it works well.

这取决于您使用的特定 .NET 技术。该Mono项目提供运行ASP.NET网站的Apache模块(是mod_mono),并从我收集它工作得很好。

Mono doesn't support all the .NET APIs, though - notably WPF (and possibly WCF too, I can't remember) - but it does provide good support for much else of the framework.

不过,Mono 并不支持所有 .NET API——尤其是 WPF(可能还有 WCF,我记不清了)——但它确实为框架的其他许多方面提供了良好的支持。

If you're starting from scratch and particularly want to target non-Windows servers, then ensuring your project works with Mono would be a good goal to aim for. However, if you need particular APIs or language features that are not supported by Mono, then you will need to use a Windows server for deployment. It's a design-time/architectural choice that should make up front.

如果您是从头开始并且特别想要针对非 Windows 服务器,那么确保您的项目与 Mono 一起工作将是一个很好的目标。但是,如果您需要 Mono 不支持的特定 API 或语言功能,则需要使用 Windows 服务器进行部署。这是一个设计时/架构选择,应该预先做出。

回答by dahlbyk

For ASP.NET on Linux, check out Mono.

对于 Linux 上的 ASP.NET,请查看Mono

That said, thousands of sites run on Windows Server without any issues. A poorly-configured server with any OS will be vulnerable; Linux won't save you from a poor admin.

也就是说,数千个站点在 Windows Server 上运行没有任何问题。带有任何操作系统的配置不​​当的服务器都容易受到攻击;Linux 不会让你摆脱糟糕的管理员。

So I guess my "best practice" for deplying an ASP.NET app would be to use Windows Server 2008 (likely Web edition). And hire a good administrator.

所以我想我部署 ASP.NET 应用程序的“最佳实践”是使用 Windows Server 2008(可能是 Web 版)。并聘请一位优秀的管理员。

回答by blowdart

You can use Monoto run ASP.NET applications on Apache/Linux, however it has a limited subset of what you can do under Windows. As for "they" saying Windows is more vulnerable to attack - it's not true. IIS has had less security problems over the last couple of years that Apache, but in either case it's all down to the administration of the boxes - both OSes can be easily secured. These days the attack points are not the OS or web server software, but the applications themselves.

您可以使用Mono在 Apache/Linux 上运行 ASP.NET 应用程序,但是它具有您在 Windows 下可以执行的操作的有限子集。至于“他们”说 Windows 更容易受到攻击——这不是真的。在过去的几年里,IIS 的安全问题比 Apache 少,但在任何一种情况下,这都取决于机器的管理 - 两个操作系统都可以轻松保护。如今,攻击点不是操作系统或 Web 服务器软件,而是应用程序本身。

回答by Jared

There is the Mono Project from Novell that will allow you to run ASP.Net on Apache.

Novell 的 Mono 项目将允许您在 Apache 上运行 ASP.Net。

http://www.mono-project.com/Main_Page

http://www.mono-project.com/Main_Page

回答by dde

Yes we can. get familiar with Mono Projectand read this articleto get started.

我们可以。熟悉Mono 项目并阅读本文以开始使用。

回答by anishMarokey

Now a days .Net is run in multiple platforms,like linux ,Mac os etc. but mono is not fully platform independent ,Because to deploy .NET in another OS required third party software.so it is not like java platform independent.

现在 .Net 可以在多个平台上运行,如 linux、Mac os 等,但 Mono 并不完全独立于平台,因为在另一个操作系统中部署 .NET 需要第三方软件。所以它不像 java 平台独立。

Mono is running in different platform ,because of JIT is there in different os.

Mono 在不同的平台上运行,因为 JIT 在不同的操作系统中。

Mono is not fully success in moonlight(silver light in .NET) .Not only Research is going on.

Mono 在月光下(.NET 中的银光)并没有完全成功。不仅研究正在进行中。

Mono uses XSP2 server or apache . some of the big companies are using this project,Some of the robotic project are also running on mono.

Mono 使用 XSP2 服务器或 apache 。一些大公司正在使用这个项目,一些机器人项目也在单声道上运行。

For more details http://www.mono-project.com/Main_Page.

有关更多详细信息,请 访问 http://www.mono-project.com/Main_Page

回答by Ben

The Mono project is your best option. However, it has a lot of pitfalls (like incomplete API support in some areas), and it's legally gray (people like Richard Stallman have derided the use of Mono because of the possibility of Microsoft coming down on Mono by using its patent rights, but that's another story).

Mono 项目是您的最佳选择。然而,它有很多陷阱(比如某些领域的 API 支持不完整),而且它在法律上是灰色的(像 Richard Stallman 这样的人嘲笑使用 Mono,因为微软可能会利用其专利权来打击 Mono,但是那是另一个故事)。

Anyway, Apache supports .NET/Mono through a module, but the last time I checked the version supplied with Debian, it gave Perl language support only; I can't say if it's changed since, perhaps someone else can correct me there.

无论如何,Apache 通过一个模块支持 .NET/Mono,但是上次我检查了 Debian 提供的版本时,它只提供了 Perl 语言支持;我不能说它是否已经改变,也许其他人可以在那里纠正我。

回答by miguel.de.icaza

You might want to consider this guide that helps Windows developers port their code to Mono/Linux:

您可能需要考虑这份帮助 Windows 开发人员将代码移植到 Mono/Linux 的指南:

Guide: Porting ASP.NET Applications - Mono

指南:移植 ASP.NET 应用程序 - Mono

回答by thelsdj

I can speak from experience. Even if your ASP.net website only uses .NET libraries supported by Mono you are going to have a hard time getting it to run if its anything beyond Hello World.

我可以根据经验说话。即使您的 ASP.net 网站只使用 Mono 支持的 .NET 库,如果它超出了 Hello World,您将很难让它运行。

You won't have to re-write much code but you will spend hours/days/weeks dealing with little issues with mod_mono/xsp/apache configuration and file permissions and error handling and all the little things that go into a large website. (Be prepared to spend a lot of time asking questions on serverfault :) )

您不必重新编写很多代码,但您将花费数小时/数天/数周来处理有关 mod_mono/xsp/apache 配置和文件权限和错误处理的小问题以及进入大型网站的所有小问题。(准备好花大量时间询问有关 serverfault 的问题:))

The problem is that a lot of people don't use Mono for ASP.net websites and so there aren't as many people reporting bugs so a lot of things that are minor bugs go un-fixed for a long time.

问题是很多人不将 Mono 用于 ASP.net 网站,因此报告错误的人并不多,因此很长一段时间内很多小错误都没有得到修复。

回答by Terrance

So I know this is an older question but I think it could stand an updated answer.

所以我知道这是一个较旧的问题,但我认为它可以接受更新的答案。

Microsoft has officially released asp.net vnextand its open source and deploy-able to both Linux and Mac. Its all still pretty new but does rely on the latest builds of mono and thus currently needs you to compile the mono-frameworkbut in time I suspect that it will be easier to access as various linux distros release updated versions of mono. This is a how to setup guide

微软已经正式发布了asp.net vnext及其开源版本,并且可以部署到 Linux 和 Mac。它仍然很新,但确实依赖于mono的最新版本,因此目前需要您编译它,mono-framework但我怀疑随着各种linux发行版发布mono的更新版本,它会更容易访问。这是一个如何设置指南

This information may be somewhat volatile and with updates is due to change.

此信息可能会有些不稳定,并且会因更改而更新。

Update ASP.NET CORE 11/10/2017

更新 ASP.NET 核心 11/10/2017