Difference (from prior minor revision) (author diff)
Added: 112a113
* [InterTech 강좌]** |
Apache와 Fast CGI설치
Fast CGI란?
FastCGI? removes this limitation by keeping the process running and handling the requests by this always running process. This removes the time used for the fork() and the overall startup and cleanup time which is necessary to create and destroy a process.
While CGI programs communicate to the server over pipes, FastCGI? processes use Unix-Domain-Sockets or TCP/IP to talk with the webserver. This gives you the second advantage over simple CGI programs: FastCGI? don't have to run on the Webserver itself but everywhere in the network.
lighttpd takes it a little bit further by providing a internal FastCGI? load-balancer which can be used to balance the load over multiple FastCGI? Servers. In contrast to other solutions only the FastCGI? process has to be on the cluster and not the whole webserver. That gives the FastCGI? process more resources than a e.g. load-balancer+apache+mod_php solution.
If you compare FastCGI? against a apache+mod_php solution you should note that FastCGI? provides additional security as the FastCGI? process can be run under different permissions that the webserver and can also live a chroot which might be different than the one the webserver is running in.
with Apache 1.3 + Fast CGI 2.4
Fast CGI는 기존 CGI의 장점을 살리면서 문제점이었던 프로세스 생성의 부하를 해결한 CGI인터페이스이다.
범용언어에 대부분 적용되면 많은 서버 역시 적용된다.
여기서는 아피치 웹서버의 mod_fastcgi와 fastcgi-lib을 설치하고 사용하는 예를 보인다.
mod_fastcgi설치
// mod_fastcgi를 아파치 모둘 디렉토리로 이동한다.mv mod_fastcgi-2.4 <apache_dir>/src/modules/fastcgi// 아파치에 mod_fastcgi를 활성화해서 컴파일한다.cd <apache_dir>./configure --activate-module=src/modules/fastcgi/libfastcgi.amakemake install
http.conf
다음의 핸들러를 추가한다.
# To use FGI scripts: AddHandler fastcgi-script .fcgi .fpl
fcgi lib의 설치
// 라이브러리 파일을 설치한다.cd <fcgi-2.4>./configuremakemake install
펄모듈의 설치
펄의 표준모듈 CPNAM.pm을 사용한다.
perl -MCPN -e "install FCGI"perl -MCPN -e "install CGI::Fast"
C 예제
#include <fcgi_stdio.h>int main(void){ int count = 0; while(FCGI_Accept() >= 0) { printf("Content-type: text/html\r\n"); printf("\r\n"); printf("Hello world!<br>\r\n"); printf("Request number %d.", count++); } return(0);}
libfcgi와 함게 컴파일 한다.
gcc -o hello.fcgi hello_fcgi.c /usr/local/lib/libfcgi.a
Perl 예제
use FCGI;my $count = 0;my $request = FCGI::Request();while($request->Accept() >= 0) { print("Content-type: text/html\r\n\r\n", ++$count);}
관련 링크
출처 : http://codeordie.org/wiki/?action=browse&diff=2&id=FastCgi
'WEB서버' 카테고리의 다른 글
configure 옵션 (0) | 2011.10.16 |
---|---|
CENTOS + apache2 + mysql5 + php5 + jdk + resin2 (0) | 2011.10.16 |
아파치 웹서버에 사용자 모듈 추가 하는 예제 (0) | 2011.10.16 |
[펌] 이름기반 대 IP기반 가상호스트 (0) | 2011.10.16 |
HyperText Transfer Protocol -- HTTP/1.0 - 한글번역본 (0) | 2011.10.16 |