解释性语言在 apache 中的工作

发布于 2024-11-16 11:09:37 字数 226 浏览 0 评论 0原文

我想编写一种简单的解释语言并在 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 技术交流群。

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

发布评论

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

评论(3

影子的影子 2024-11-23 11:09:37

如果您不想走 CGI 路线,请考虑编写一个 Apache 模块来托管您的解释器或在另一个进程中调用它。听起来很吓人,但实际上并没有那么糟糕。从哪里开始:

一旦你熟悉了,你可以看看更强大的实现:

  • 从 httpd 源代码, /httpd/mod_wombat/trunk/ 是 Lua 如何在 Apache 中托管的完整(但复杂)视图
  • modwsgi 是 Apache 中选项丰富的 Python。它遵循 WSGI 协议。

如果你选择一个模块,你将无法避免 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:

  • From the httpd source, /httpd/mod_wombat/trunk/ is a complete (but complex) view of how Lua is hosted in Apache
  • modwsgi is option-rich Python in Apache. It honors the WSGI protocol.

You won't be able to avoid C if you choose a module.

自控 2024-11-23 11:09:37

通用网关接口 (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...

白况 2024-11-23 11:09:37

我建议你使用 apache 已经支持的现有语言。

如果您想了解开发一种新语言/编译器/运行时工具包可能需要多长时间,您可以使用 Java 或 PHP 作为指南。

OpenJDK

Codebase         4,782,692 lines
Effort (est.)     1451 person-years
Estimated Cost $79,802,051

http://www.ohloh.net/p/openjdk/estimated_cost

PHP

Codebase     2,696,715 lines
Effort (est.)      772 person-years
Estimated cost     $42m.

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

Codebase         4,782,692 lines
Effort (est.)     1451 person-years
Estimated Cost $79,802,051

http://www.ohloh.net/p/openjdk/estimated_cost

PHP

Codebase     2,696,715 lines
Effort (est.)      772 person-years
Estimated cost     $42m.

http://www.ohloh.net/p/php/estimated_cost

Having developed the language you would have to integrate it with Apache.

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