如何配置的Apache2和FastCGI运行我的C ++应用程序 [英] how to config apache2 and fastCGI to run my c++ application

查看:399
本文介绍了如何配置的Apache2和FastCGI运行我的C ++应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经写了一个程序使用C ++和GCC编译它(如在fastcgi.com样本),但我不知道如何在本地主机上运行它。

I have written a program with c++ and compiled it with gcc ( like the sample in the fastcgi.com) but i dont know how to run it on localhost.

我到处搜查,我发现mod_fcgi PHP配置它不会工作
对于C ++。

everywhere i searched , i found the php configuration for mod_fcgi which wont work for c++.

做任何机构配置Apache和mod_fcgi运行一个C ++的Web应用程序???

does any body configured apache and mod_fcgi to run a c++ web application ???

推荐答案

mod_fcgi?我只找到的mod_fastcgi和mod_fcgid。 Apache的配置看起来pretty简单的两个。让我们编译的FastCGI例如,创建一个简约的Apache实例来服务它:

mod_fcgi? I have found only mod_fastcgi and mod_fcgid. Apache configuration looks pretty simple for both. Lets compile FastCGI example and create a minimalistic Apache instance to serve it:


  1. 安装libfcgi-dev的

  1. Install libfcgi-dev

某处创建临时目录和编译从示例<一个href=\"http://www.fastcgi.com/devkit/doc/fcgi-devel-kit.htm#S3.1\">http://www.fastcgi.com/devkit/doc/fcgi-devel-kit.htm#S3.1

Create temporary directory somewhere and compile the example from http://www.fastcgi.com/devkit/doc/fcgi-devel-kit.htm#S3.1

当你只需要运行它,它已经有一些输出:

When you simply run it, it already has some output:

$ ./tiny-cgi 
Content-type: text/html


<title>FastCGI Hello!</title><h1>FastCGI Hello!</h1>Request number 1 running on host <i>(null)</i>


  • 安装的Apache2和中的libapache2-MOD-fcgid;创建配置文件的apache.conf:

  • Install apache2 and libapache2-mod-fcgid; create configuration file apache.conf:

    User www-data
    Listen 8080
    PidFile apache.pid
    DocumentRoot .
    LoadModule fcgid_module /usr/lib/apache2/modules/mod_fcgid.so
    SetHandler fcgid-script
    Options +ExecCGI
    ErrorLog error.log
    

    用户WWW的数据是非常重要的,因为它可以访问的/ var / lib中/的Apache2 / fcgid /袜子/ ,这是pretty为fcgid重要(我在Debian上运行,也许别的地方会有所不同)。与其他相同的目录拥有的DocumentRoot不是很好,但是这仅仅是一个简单的例子。

    User www-data is important, because it has access to /var/lib/apache2/fcgid/sock/, which is pretty important for fcgid (I am running on Debian, maybe somewhere else it will be different). Having DocumentRoot in the same directory with the rest is not very good, but this is just a quick example.

    运行 sudo的/ usr / sbin目录/ Apache2的-d。 -f -X的apache.conf

    这是 -X 是调试模式,当服务器不会守护进程(不分离),这是pretty方便此类播放。

    That -X is for debug mode, when the server does not daemonize (does not detach), which is pretty handy for such playing.

    的http://本地主机:8080 /微小-CGI ,在那里你会看到从你的FastCGI程序的输出。如果没有,请参阅 error.log中

    Go to http://localhost:8080/tiny-cgi, where you will see output from your FastCGI program. If not, see error.log.

    停止了Apache,安装中的libapache2-MOD-FastCGI的,与替换两行配置:

    Stop Apache, install libapache2-mod-fastcgi, replace the two lines in configuration with:

    LoadModule fastcgi_module /usr/lib/apache2/modules/mod_fastcgi.so
    SetHandler fastcgi-script
    


  • 访问的http://本地主机:8080 /微小-CGI 再次

    这篇关于如何配置的Apache2和FastCGI运行我的C ++应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

  • 查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆