Apache Fast Cgi Tutorial
Apache Fast Cgi Tutorial
Release 0.9
Sbastien Lugan
CONTENTS
1 2
Prerequisites Server conguration 2.1 Installation of Apache, FastCGI module and libraries 2.2 Conguration of Apache web server . . . . . . . . . 2.3 Starting the FastCGI TCP server . . . . . . . . . . . 2.4 Killing the FastCGI TCP server . . . . . . . . . . .
1 3 3 3 4 4 5 5 5 7
. . . .
. . . .
. . . .
. . . .
. . . .
. . . .
. . . .
. . . .
. . . .
. . . .
. . . .
. . . .
. . . .
. . . .
. . . .
. . . .
. . . .
. . . .
. . . .
. . . .
. . . .
. . . .
. . . .
. . . .
Setting-up the FastCGI development environment 3.1 Installation of FastCGI library and headers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3.2 Example FastCGI script . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Testing your Apache FastCGI server
ii
CHAPTER
ONE
PREREQUISITES
This document assumes that you are currently running a Debian-based distribution, such as Debian Squeeze. The instructions given in this documentation should work with any other Debian-based distribution (other Debian releases, Ubuntu, etc.) as well but this has not been tested. Please refer to the documentation provided with your distribution if needed.
Chapter 1. Prerequisites
CHAPTER
TWO
SERVER CONFIGURATION
2.1 Installation of Apache, FastCGI module and libraries
The following packages must be installed: apache2-mpm-prefork Apache web server itself libapache2-mod-fastcgi Apache FastCGI module libfcgi FastCGI library spawn-fcgi FastCGI process spawner Step 1 install the required packages:
# aptitude install apache2-mpm-prefork libapache2-mod-fastcgi libfcgi spawn-fcgi Note: selecting "libfcgi0ldbl" instead of the virtual package "libfcgi" The following NEW packages will be installed: apache2-mpm-prefork apache2-utils{a} apache2.2-bin{a} apache2.2-common{a} libapache2-mod-fastcgi libapr1{a} libaprutil1{a} libaprutil1-dbd-sqlite3{a} libaprutil1-ldap{a} libfcgi0ldbl spawn-fcgi 0 packages upgraded, 11 newly installed, 0 to remove and 0 not upgraded. Need to get 2405 kB of archives. After unpacking 7971 kB will be used. Do you want to continue? [Y/n/?] Y
where /var/www is your DocumentRoot. Please note that /var/www/myFCGI does not need to (and actually should not) exist in your lesystem. Unlike CGI, FastCGI uses network or UNIX domain sockets to connect to the FastCGI script, not les. This directive simply indicates to the web server the location of the requests which should be handled by the FastCGI script (here: http://your.web.server/myFCGI). For example, if your original le looks like that:
<IfModule mod_fastcgi.c> AddHandler fastcgi-script .fcgi #FastCgiWrapper /usr/lib/apache2/suexec FastCgiIpcDir /var/lib/apache2/fastcgi </IfModule>
Your Apache web server will then connect the following URL http://your.web.server/myFCGI to a FastCGI TCP server running on localhost, port 3000.
CHAPTER
THREE
You can now upload this le to your FastCGI server (e.g. in /home/httpd/fcgi-scripts/tiny-fcgi).
CHAPTER
FOUR
(please note that the request number is increasing, since the very same process is answering all of the requests) Congratulations: your Apache FastCGI installation is working!