josef.van.niekerk
josef.van.niekerk

Reputation: 12121

Apache mod_c++ wanted?

I want to experiment a bit with C++ as a server side language. I'm not looking for a framework, and simply want to achieve a silly old "Hello World" webapp using C++.

Is there an Apache HTTP server module that I can install?

If i can do the PHP equivalent of :

<?php 
    $personName = "Peter Pan";
    echo "Hello " . $personName;

I'd be most thrilled! Thanks in advance!

Upvotes: 1

Views: 1242

Answers (6)

user251206
user251206

Reputation:

You might want to have a look at http://www.webtoolkit.eu/wt or www.tntnet.org instead.

Upvotes: 2

Gianni
Gianni

Reputation: 4390

I did create a mod_cpp once. It basically was written in c, but loaded a .so which was in turn written in C++.

Its performance was really good, but lacked a lot of things that we take for granted in things like PHP (sessions, HTML un/escaping, etc). It did use a template engine to separate the HTML from the C++.

I tell you, the initial set-up was a lot of work (the mod_cpp part); after that, it was kinda easy to write the .so's. I even tried to create an sf.net project to open-source it, but I never got around to actually porting it :-(

In summary: I did not find anything like that on the net, did it myself and found out to be a lot more work then I anticipated, but the result was very cool! This helped me a lot: Apache Modules

Upvotes: 1

blah
blah

Reputation: 11

Suppose for the moment the OP wanted something that was "like mod_php, mod_perl". Given the right configuration, it would be monumentally easy for the "mod_c++" to look at the source files, and compiled files and decide whether it had to do a "one off" compilation task. In fact this is how make works.

I know the OP probably didn't mean that it had to be "interpreted", but it's certainly not impossible to allow apache to compile cpp files on the fly if needed [this is how jsp works, btw].

Upvotes: 1

user229044
user229044

Reputation: 239382

"mod_c++" doesn't make sense; Once you're talking about compiled programs, Apache doesn't care what language the binary comes from. mod_cgi allows Apache to invoke such a binary (regardless of it's source language) in response to HTTP requests. Read more here:

http://library.thinkquest.org/16728/content/cgi/cplusplus.html

Upvotes: 1

anon
anon

Reputation:

I'm not saying there is no such thing, but if there is it would be monumentally inefficient. C++ is a compiled language, not an interpretive one, so the putative Apache C++ module would have to invoke the C++ compiler to compile the code before executing it. This would be very, very slow, apart from other problems.

Upvotes: 0

yaya
yaya

Reputation: 86

cgi would do this. Just have your C++ app spit its output to stdout and your mod_cgi will handle it

Upvotes: 7

Related Questions