开发者

The working of a interpreted language in apache

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.


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:

  • Nick Kew's The Apache Modules Book - a few years old but still relevant
  • Apache's httpd source - check /httpd/httpd/trunk/modules/examples/ for simple examples
  • Where can I find good reference/tutorial on writing Apache modules (in C)? contains additional references.

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.


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...


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜