user656925
user656925

Reputation:

How do I deploy C++ to my web server?

Per this post here there are 3 ways

I'm not sure which is best so I looked at what a high volume site does. Here is a post from Facebook in 2010

They use a static analysis tool Hip Hop, to convert PHP to C++.

I don't need the static analysis tool as I only have about 1500 lines and can convert by hand...but I need a starting point.

Right now I run a Lamp stack and want to stay on it minus the (P)HP.

Here is a link that explains how Facebook works. Not sure how accurate it is.

Thanks

Upvotes: 1

Views: 2317

Answers (2)

craigmj
craigmj

Reputation: 5077

FastCGI is a much better option than CGI, and can act like CGI in certain circumstances. If you only want to work with Apache, you can also develop an Apache module, and there's an excellent book on the subject: The Apache Modules Book This describes many elements of C development with Apache acting in many ways like a (sort of) application server.

With careful C/C++ coding, you can achieve remarkable performance with limited memory. Not for everything, but in some circumstances, very powerful.

Upvotes: 1

Brooks Moses
Brooks Moses

Reputation: 9527

As the comments note, Facebook is almost certainly using a highly-customized solution that involves high administration costs in return for very high efficiency. It is unlikely that this is actually what you want.

Since what you want is simply to replace the "P" in your LAMP stack, that implies that you probably want to keep the "LAM" -- the Linux, Apache, and MySQL (if relevant) parts. That's a good idea; while there are advantages at Facebook's scale to running a custom web server, it is extremely unlikely that it will actually be useful for you, and continuing to run Apache is certainly much easier and simpler. (And probably more secure, since you don't have to think about the security and fix bugs all by yourself.)

And you're planning to translate all your PHP, not just part of it, so calling C++ from PHP doesn't make sense.

Thus, in your case, the best solution is most likely to be running the C++ application via cgi-bin with your existing Apache server.

Upvotes: 2

Related Questions