Fastcgi on apache » History » Version 4
Peter Mortensen, 04/15/2011 10:27 PM
Copy edit.
1 | 4 | Peter Mortensen | h1. FastCGI on Apache |
---|---|---|---|
2 | 1 | Koen Deforche | |
3 | h2. Using mod_fastcgi |
||
4 | |||
5 | 4 | Peter Mortensen | 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 | 1 | Koen Deforche | |
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 | 4 | Peter Mortensen | The only thing left to do is enable CGI execution in your Apache configuration (see below). |
26 | 1 | Koen Deforche | |
27 | h2. Using mod_fcgid |
||
28 | |||
29 | 4 | Peter Mortensen | 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 | 1 | Koen Deforche | |
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 | 2 | Koen Deforche | MaxProcessCount 10 |
40 | DefaultMaxClassProcessCount 10 |
||
41 | 1 | Koen Deforche | 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 | 4 | Peter Mortensen | h2. Enabling CGI in Apache |
51 | 1 | Koen Deforche | |
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 | 4 | Peter Mortensen | Then, we need to create folder /var/run/wt and to give the Apache server write permissions to that directory. |
63 | Next I enable the site and reload Apache: |
||
64 | 1 | Koen Deforche | <pre> |
65 | a2ensite wt |
||
66 | /etc/init.d/apache2 reload |
||
67 | </pre> |