将 C# 编译为 CGI

发布于 2024-09-03 14:57:11 字数 62 浏览 3 评论 0原文

如何将 C# 程序编译为 CGI 以在 LAMP/Linux/Apache 服务器的 cgi-bin 中运行?

How do you compile a C# program as CGI to run in the cgi-bin of a LAMP/Linux/Apache server?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

随波逐流 2024-09-10 14:57:11

不需要什么特别的 - 只需使用 Mono 的 gmcs 编译器正常编译应用程序即可。

有关集成的更多信息,请查看这两个链接:

http://www.mono-project。 com/ASP.NET

,这个专门用于 CGI:

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

Nothing special is required - just compile the application as normal with Mono's gmcs compiler.

For more information on integration, check out these two links:

http://www.mono-project.com/ASP.NET

and this one for CGI specifically:

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

蓝海似她心 2024-09-10 14:57:11

通常使用服务器上的编译器(通常是 gnu 编译器)来编译 C 程序。
如果这是您正在使用的编译器;

gcc -o <name_of_output_file>.cgi <name_of_source_file>

无论您为文件命名什么,都需要为其指定扩展名.cgi
然后你所要做的就是将它移动到cgi-bin文件夹中,记住设置程序的权限,通常对于cgi的东西你使用755;

chmod 755 <name_of_file>

这就是我对 C 的做法,我想 C# 也是一样的。

You usually compile C programs using the compiler on the server, often the gnu compiler.
If this is the complier you are using then;

gcc -o <name_of_output_file>.cgi <name_of_source_file>

Whatever you name the file you need to give it the extension .cgi
All You have to do then is to move it to the cgi-bin folder, remember to set the permissions of the program, usually for cgi stuff you use 755;

chmod 755 <name_of_file>

This is how I do it for C, C# I imagine is the same.

挽手叙旧 2024-09-10 14:57:11

也许,您可以使用一个非常简单的包装脚本,例如使用 bash,它本身以正常方式使用 mono 执行您的 C# 程序。 eg:(

#!/usr/bin bash

/usr/bin/opt/mono myprogram.exe $@

当然,仅将 Apache 与 mod_mono 一起使用就是如果可以的话,更好的解决方案。)

Maybe, you could use a very simple wrapper script, e.g., with bash, that itself executes your C# program with mono in the normal way. e.g.:

#!/usr/bin bash

/usr/bin/opt/mono myprogram.exe $@

(Of course, just using Apache with mod_mono is a much better solution, if you can.)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文