资源简介
http://blog.csdn.net/wangkangluo1/archive/2011/05/11/6411641.aspx
[原创] Redhat 上 FastCGI 安装与配置
软件包
相关软件包:
httpd
httpd-devel
fcgi-2.4.0.tar.gz
mod_fastcgi-2.4.6.tar.gz 请仔细阅读其中的README
配置httpd.conf:
LoadModule fastcgi_module modules/mod_fastcgi.so
AddHandler fastcgi-script .fcgi # you can put whatever extension you want
FastCgiIpcDir /tmp
FastCgiServer /home/m/Dev/cvs/ImRoBot5/shdaily/cgi/shdaily.fcgi -processes 1 -idle-timeout 1000
代码片段和文件信息
/*
* $Id: fcgi_buf.cv 1.18 2003/02/03 23:07:37 robs Exp $
*/
#include “fcgi.h“
#ifdef WIN32
#pragma warning( disable : 4127 )
#else
#ifdef APACHE2
#include
#endif
#endif
/*******************************************************************************
* Check buffer consistency with assertions.
*/
#ifdef DEBUG
static void fcgi_buf_check(Buffer *buf)
{
ASSERT(buf->size > 0);
ASSERT(buf->length >= 0);
ASSERT(buf->length <= buf->size);
ASSERT(buf->begin >= buf->data);
ASSERT(buf->begin < buf->data + buf->size);
ASSERT(buf->end >= buf->data);
ASSERT(buf->end < buf->data + buf->size);
ASSERT(((buf->end - buf->begin + buf->size) % buf->size)
== (buf->length % buf->size));
}
#else
#define fcgi_buf_check(a) ((void) 0)
#endif
/*******************************************************************************
* Reset buffer losing any data that‘s in it.
*/
void fcgi_buf_reset(Buffer *buf)
{
buf->length = 0;
buf->begin = buf->end = buf->data;
}
/*******************************************************************************
* Allocate and intialize a new buffer of the specified size.
*/
Buffer *fcgi_buf_new(pool *p int size)
{
Buffer *buf;
buf = (Buffer *)ap_pcalloc(p sizeof(Buffer) + size);
buf->size = size;
fcgi_buf_reset(buf);
return buf;
}
void fcgi_buf_removed(Buffer * const b unsigned int len)
{
b->length -= len;
b->begin += len;
if (b->length == 0)
{
b->begin = b->end = b->data;
}
else if (b->begin >= b->data + b->size)
{
b->begin -= b->size;
}
}
void fcgi_buf_added(Buffer * const b const unsigned int len)
{
b->length += len;
b->end += len;
if (b->end >= b->data + b->size)
{
b->end -= b->size;
}
}
#ifdef WIN32
static int socket_recv(SOCKET fd char *buf int len)
{
int bytes_read = recv(fd buf len 0);
if (bytes_read == SOCKET_ERROR)
{
return -1;
}
return bytes_read;
}
static int socket_send(SOCKET fd char * buf int len)
{
int bytes_sent = send(fd buf len 0);
if (bytes_sent == SOCKET_ERROR)
{
return -1;
}
return bytes_sent;
}
#else /* !WIN32 */
static int socket_recv(int fd char * buf int len)
{
int bytes_read;
do {
bytes_read = read(fd buf len);
if (bytes_read < 0)
{
#ifdef EWOULDBLOCK
ASSERT(errno != EWOULDBLOCK);
#endif
#ifdef EAGAIN
ASSERT(errno != EAGAIN);
#endif
}
} while (bytes_read == -1 && errno == EINTR);
return bytes_read;
}
static int socket_send(int fd char * buf int len)
{
int bytes_sent;
do {
bytes_sent = write(fd buf len);
if (bytes_sent < 0)
{
#ifdef EWOULDBLOCK
ASSERT(errno != EWOULDBLOCK);
#endif
#ifdef EAGAIN
ASSERT(errno != EAGAIN);
#endif
}
}
while (bytes_sent == -1 && errno == EINTR);
return bytes_sent;
}
#endif /* !
- 上一篇:fcgi-2.4.0.tar.gz
- 下一篇:SendGrid发送邮件Demo
评论
共有 条评论