解释性语言在 apache 中的工作
我想编写一种简单的解释语言并在 Apache 中使用它。我之前已经写过一篇,但它是在我们自己编写的网络服务器中构建的。
我猜测apache将需要编译的文件传递给一些可执行文件,该可执行文件将“执行”代码并将要发送给用户的html返回给apache?如果我错了,请纠正我。
有谁知道我该如何完成这件事?也许样品?语言并不重要(尽管 C# 或 Java 会很好,因为我可以处理这两种语言),更重要的是为了理解。
I'd like to write a simple interpreted language and use it in Apache. I've already written one before but that was built in our own written webserver.
I'm guessing apache passes the file that needs to be compiled to some executable which will 'execute' the code and return to apache the html to be sent to the user? Please correct me if I'm wrong.
Does anyone have an idea of how I could get this done? perhaps samples? The language doesn't really matter (although C# or Java would be nice since i can handle both), it's more for the understanding.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
如果您不想走 CGI 路线,请考虑编写一个 Apache 模块来托管您的解释器或在另一个进程中调用它。听起来很吓人,但实际上并没有那么糟糕。从哪里开始:
一旦你熟悉了,你可以看看更强大的实现:
如果你选择一个模块,你将无法避免 C。
If you don't want to go the CGI route, consider writing an Apache module that either hosts your interpreter or calls it in another process. It sounds intimidating, but it's actually not that bad. Places to start:
Once you get comfortable, you can look at beefier implementations:
You won't be able to avoid C if you choose a module.
通用网关接口 (CGI) 描述了网络服务器应如何与程序(例如解释器)交互)生成动态网页。曾几何时,超过 90% 的非静态网页是由通过 CGI 调用的 Perl 解释器生成的……
The Common Gateway Interface (CGI) describes how a webserver should interact with a program (such as an interpreter) that produces dynamic webpages. Once upon a time, upwards of 90% of all non-static webpages were produced by a Perl interpreter invoked via CGI...
我建议你使用 apache 已经支持的现有语言。
如果您想了解开发一种新语言/编译器/运行时工具包可能需要多长时间,您可以使用 Java 或 PHP 作为指南。
OpenJDK
http://www.ohloh.net/p/openjdk/estimated_cost
PHP
http://www.ohloh.net/p/php/estimated_cost
开发该语言后,您必须将其与 Apache 集成。
I suggest you use an existing language which apache supports already.
If you want an idea of how long developing a new language/compiler/runtime kit it might take, you could use Java or PHP as a guide.
OpenJDK
http://www.ohloh.net/p/openjdk/estimated_cost
PHP
http://www.ohloh.net/p/php/estimated_cost
Having developed the language you would have to integrate it with Apache.