红联Linux门户
Linux帮助

ubuntu 使用fastcgi和cgicc

发布时间:2011-12-30 09:42:48来源:红联作者:haolifengwang
安装fastcgi
1)http://www.fastcgi.com/drupal/node/5
2)下载fcgi-2.4.0.tar.gz
3)sudo tar -xf fcgi-2.4.0.tar.gz
4)cd fcgi-2.4.0
5)./configure --prefix=/opt/fcgi
6) cd include
7) sudo chmod 777 fcgio.h
8)vim fcgio.h
9)在fcgio.h中添加#include
10)make
11)make install
12)安装路径
/opt/fcgi/下有bin,include和lib文件夹
自解压目录中有doc


ubuntu使用fastcig
1)安装apache2-- 用新立得软件包管理器安装apache2-bin和apache2-common
2)sudo apt-get install apache2
3)127.0.0.1测试 apache2
4)ubuntu默认安装路径
Ubuntu (Apache 2):

ServerRoot :: /etc/apache2
DocumentRoot :: /var/www
Apache Config Files :: /etc/apache2/apache2.conf
:: /etc/apache2/ports.conf
Default VHost Config :: /etc/apache2/sites-available/default, /etc/apache2/sites-enabled/000-default
Module Locations :: /etc/apache2/mods-available, /etc/apache2/mods-enabled
ErrorLog :: /var/log/apache2/error.log
AccessLog :: /var/log/apache2/access.log
cgi-bin :: /usr/lib/cgi-bin
binaries (apachectl) :: /usr/sbin
start/stop :: /etc/init.d/apache2 (start|stop|restart|reload|force-reload|start-htcacheclean|stop-htcacheclean)
5)修改cgi-bin目录
5.1)cd /etc/apache2/sites-enabled
5.2)sudo chmod 777 000-default
5.3)vim 000-default
5.4)将ScriptAlias /cgi-bin/ /usr/lib/cgi-bin 修改为ScriptAlias /cgi-bin/ /var/www/cgi-bin
5.5) 将
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all

改为

AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all

6)创建cgi-bin目录
6.1)cd /var
6.2)sudo chmod -R 777 www
6.3)在/var/www/创建目录cgi-bin -- mkdir cgi-bin
6.4)sudo chmod -R 777 cgi-bin

7)安装cgicc
7.1)http://www.gnu.org/software/cgicc下载cgicc
7.2)解压
7.3)cd cgicc-3.2.9
7.4)./configure --prefix=/usr
7.5)make -- 如果发现html无法通过,不用管理
7.6)sudo make install
7.8)安装后得文件目录
/usr/inlcude/cgicc
/usr/lib/libcgicc.a

8)创建简单用例
8.1)在/var/www/下创建fcgi.html

test fcgi










8.2)在/var/www/cgi-bin下创建fcig.cpp

#include
#include
#include
#include "cgicc/CgiDefs.h"
#include "cgicc/Cgicc.h"
#include "cgicc/HTTPHTMLHeader.h"
#include "cgicc/HTMLClasses.h"
using namespace std;
int main(int argc,char* argv[])
{
while(FCGI_Accept() >=0)
{
Cgicc cgi;
string strName,strAge;
form_iterator iterName;
form_iterator iterAge;
iterName = cgi.getElement("name");
strName = iterName->getValue();
iterAge = cgi.getElement("age");
strAge = iterAge->getValue();
printf("Content-Type:text/html\n\n");
printf(strName.c_str());
printf(strAge.c_str());
return 0;
}
}
8.3)makefile
fcgi:fcgi.cpp
g++ -o fcgi fcgi.cpp -I/usr/include -L/usr/lib -lcgicc -I/opt/fcgi/include -L/opt/fcgi/lib -lfcgi
8.4)在/ect/ld.so.conf中添加一行,将libfcgi.so.0的路径包含,
include /etc/ld.so.conf.d/*.conf

/opt/fcgi/lib
8.5)sudo ldconfig
8.6)重启apache2
文章评论

共有 4 条评论

  1. 于 2012-02-07 13:21:18发表:

    这个贴子操作步骤有错误。特此声明,我将在以后更正。

  2. linuxunix 于 2011-12-31 11:32:22发表:

    学习一下

  3. haolifengwang 于 2011-12-31 09:41:23发表:

    写的比较详细。

  4. Aogu 于 2011-12-30 10:30:06发表:

    看起来好多步