[英]Compile C# as CGI
如何将C#程序编译为CGI以在LAMP / Linux / Apache服务器的cgi-bin中运行?
Maybe, you could use a very simple wrapper script, eg, with bash, that itself executes your C# program with mono in the normal way. 也许,您可以使用一个非常简单的包装器脚本,例如,使用bash,它本身以正常方式执行您的C#程序。 eg :
例如 :
#!/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.) (当然,如果可以,只使用带有mod_mono的 Apache是一个更好的解决方案。)
Nothing special is required - just compile the application as normal with Mono's gmcs compiler. 没有什么特别之处 - 只需使用Mono的gmcs编译器正常编译应用程序。
For more information on integration, check out these two links: 有关集成的更多信息,请查看以下两个链接:
http://www.mono-project.com/ASP.NET http://www.mono-project.com/ASP.NET
and this one for CGI specifically: 这个CGI专门用于:
http://www.mono-project.com/CGI http://www.mono-project.com/CGI
You usually compile C programs using the compiler on the server, often the gnu compiler. 您通常使用服务器上的编译器编译C程序,通常是gnu编译器。 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; 无论你命名文件是什么,你需要给它扩展名.cgi所有你要做的就是把它移到cgi-bin文件夹,记得设置程序的权限,通常是你使用的cgi东西755;
chmod 755 <name_of_file>
This is how I do it for C, C# I imagine is the same. 这就是我为C做的事情,C#我想象的是一样的。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.