Project

General

Profile

Fastcgi on apache » History » Version 1

Koen Deforche, 10/28/2010 09:45 AM
Document FastCGI on apache configuration

1 1 Koen Deforche
h1. Fastcgi on apache
2
3
h2. Using mod_fastcgi
4
5
You'll need to enable mod_fastcgi first for apache. In most cases, this is done by linking the module's configuration file @fastcgi.conf@ from @mods-available@ to @mods-enabled@ (this can be done by running @a2enmod@.
6
7
Next you need to modify the configuation file:
8
9
<pre>
10
<IfModule mod_fastcgi.c>
11
  AddHandler fastcgi-script .wt
12
  FastCgiIpcDir /var/lib/apache2/fastcgi
13
  FastCgiConfig -idle-timeout 100 -maxClassProcesses 1 -initial-env WT_APP_ROOT=/tmp
14
</IfModule>
15
</pre>
16
17
This will automatically start any file ending with @.wt@ as a FastCGI executable. You can also use "external CGIs", which allow you to control in more detail how a single application gets started (and restarted):
18
19
<pre>
20
  FastCgiExternalServer /var/www/wt-examples/simplechat/simplechat.wt -host localhost:9091 -idle-timeout 200
21
</pre>
22
23
For this latter deployment option, you need to use the FastCGI utility @cgi-fcgi@ to run the Wt application independent of the web server. When a request for the application is received by the web server, it is forwarded to your FastCGI application using the FastCGI protocol over the given TCP connection.
24
25
The only thing left to do is enable CGI execution in your apache configuration (see below).
26
27
h2. Using mod_fcgid
28
29
You'll need to enable mod_fcgid first for apache. In most cases, this is done by linking the module's configuration file @fcgid.conf@ from @mods-available@ to @mods-enabled@ (this can be done by running @a2enmod@.
30
31
Next you need to modify the configuration file:
32
33
<pre>
34
<IfModule mod_fcgid.c>
35
  AddHandler fcgid-script .wt
36
  SocketPath /var/lib/apache2/fcgid/sock
37
  IdleTimeout -1
38
  ProcessLifeTime -1
39
  MaxProcessCount 1
40
  DefaultMaxClassProcessCount 1
41
  DefaultMinClassProcessCount 1
42
</IfModule>
43
</pre>
44
45
and then do this command:
46
<pre>
47
    chown www-data:www-data /var/run/wt -R
48
</pre>
49
50
h2. Enabling CGI in apache.
51
52
Next, we create a new "site" configuration file for Wt applications: @/etc/apache2/sites-available/wt@ which we will install in @/var/www/wt@ (this must be a directory within your docroot):
53
54
<pre>
55
<Directory /var/www/wt/>
56
  #Order Deny,Allow
57
  Allow from all
58
  # Enable CGIs to be executed 
59
  Options ExecCGI
60
</Directory>
61
</pre>
62
63
Next I enable the site & reload apache:
64
<pre>
65
    a2ensite wt
66
    /etc/init.d/apache2 reload
67
</pre>