Skip to content

Running multiple on demand Quilt FastCGI instances

Mo McRoberts edited this page Jul 6, 2015 · 2 revisions

From time to time, particularly during development, it can be useful to run multiple, distinct, Quilt FastCGI instances that are started on demand (i.e., the web server launches the FastCGI processes as needed).

With mod_fcgid, this can be accomplished through the use of symbolic links, FcgidCmdOptions and the QUILT_CONFIG environment variable (which specifies the path to a Quilt configuration file).

Let's say that quilt-fcgid is installed to /usr/local/sbin, and you have two virtual hosts served from /www/host1 and /www/host2, which you want to both be served by Quilt. Create symbolic links in each of these directories (using sudo where needed):

$ cd /www/host1
$ ln -s /usr/local/sbin/quilt-fcgid index.fcgi
$ cd /www/host2
$ ln -s /usr/local/sbin/quilt-fcgid index.fcgi

Next, create two different Quilt configuration files. You can put these wherever it makes sense to, but for this example lets call them quilt-host1.conf and quilt-host2.conf and keep them in /usr/local/etc.

Your two Apache virtual hosts would then be configured along the following lines:

<VirtualHost *:80>
  ServerName host1
  DocumentRoot /www/host1
  Options FollowSymlinks ExecCGI
  AddHandler fcgid-script .fcgi
  RewriteEngine on
  RewriteCond %{LA-U:REQUEST_FILENAME} !-f
  RewriteRule ^(.*)$ /index.fcgi [NS,L]
  FcgidCmdOptions /www/host1/index.fcgi InitialEnv QUILT_CONFIG=/usr/local/etc/quilt-host1.conf
</VirtualHost>

<VirtualHost *:80>
  ServerName host2
  DocumentRoot /www/host2
  Options FollowSymlinks ExecCGI
  AddHandler fcgid-script .fcgi
  RewriteEngine on
  RewriteCond %{LA-U:REQUEST_FILENAME} !-f
  RewriteRule ^(.*)$ /index.fcgi [NS,L]
  FcgidCmdOptions /www/host2/index.fcgi InitialEnv QUILT_CONFIG=/usr/local/etc/quilt-host2.conf
</VirtualHost>