如何调用我的 C++通过 CGI 接口的二进制文件?
我想将 PHP 解决方案转换为 C++ 解决方案。目前我的服务器端是用 PHP 编写的 - 代码不多,不到一千行。所以我可以毫无问题地重写它 - 我不需要使用嘻哈或类似的自动化。
问题是如何安装/配置正确的软件以支持服务器端的 C++ 代码。我不知道如何通过 CGI 通过 Web 服务器调用二进制文件。
PHP 很简单,安装 XAMPP 或类似的编写 PHP 就可以了。
但是,我想运行 C++。
谢谢
I'd like to convert a PHP solution to a C++ solution. Currently I have my server-side written in PHP - not too much code, under a thousand lines. So I can rewrite it with no problem - I don't need to use hip-hop or similar automations.
The question is how do I install/configure the correct software to support C++ code on the server side. I do not know how to invoke binaries by the web server via CGI.
PHP is easy, install XAMPP or similar write the PHP and you are pretty much up and going.
However, I want to run C++.
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
三个基本选项:
Three basic options:
您可以通过 RFC 3875 中指定的通用网关接口调用 C++ 二进制文件。
每个支持 CGI(而且很常见)的网络服务器都可以调用您的二进制文件。如果您出于性能和稳定性原因而使用 apache 3.1,手册中有一个部分: 使用 CGI 的动态内容。
Cgi 和 C++ 代码示例很容易通过互联网搜索找到,因此 这只是一个示例。
当您让它工作并习惯它时,您可以考虑向前迈出一步并迁移到 FastCGI< /a>.它有助于降低每次分叉进程的成本,就像 CGI 那样。另一种选择是您以 apache 模块 的形式创建脚本并直接从 httpd 中提供服务。
You can invoke your C++ binaries via the Common Gateway Interface which is specified in RFC 3875.
Each webserver that supports CGI (and it's quite common) can then invoke your binaries. In case you're using apache 3.1 for performance and stablility reasons, there's a section in the manual: Dynamic Content with CGI.
Cgi and c++ code examples are easily to be located via an internet search, so this is just one example.
When you got this to work and got used to it, you can think about going a step ahead and migrate to FastCGI. It helps to reduce the costs of forking a process each time as CGI does. Another option is that you create your script in form of an apache module and directly serve from within httpd.