You are not logged in Log in Join
You are here: Home » Members » Søren Roug » FastCGI, virtualhosts and root folders

Log in
Name

Password

 

FastCGI, virtualhosts and root folders

How it works:
I basically followed kedai's approach, and I used the RewriteEngine to make it work in the rootfolder. This is what I put in the Serverconfig (beware you must fit these lines into your own file at the relevant places:

LoadModule fastcgi_module     libexec/mod_fastcgi.so
LoadModule rewrite_module     libexec/mod_rewrite.so
AddModule mod_fastcgi.c
AddModule mod_rewrite.c
FastCgiExternalServer /disk1/fastcgi/zope.fcgi -host localhost:8889 \
    -pass-header Authorization
Then I created a virtual host:
<VirtualHost 12.34.56.78>
ServerAdmin helpdesk@my.domain
DocumentRoot /disk1/htdocs
ServerName fastcgi.my.domain
ServerAlias fastcgi
DirectoryIndex index_html
RewriteEngine On
RewriteRule .*\.php - [L]
RewriteRule ^/(.*) /disk1/fastcgi/zope.fcgi/$1 [L]

<Directory /disk1/fastcgi>
AddHandler fastcgi-script .fcgi
AllowOverride none
Options ExecCGI
Order allow,deny
Allow from all
</Directory>

</VirtualHost>

The file /disk1/fastcgi/zope.fcgi doesn't have to exist, but the directory most likely must. Otherwise Apache will write a warning in error_log.

About the FastCGI module
I downloaded mod_fastcgi_SNAP_Oct06 (1999) from www.fastcgi.com. Any newer release should work also.

As I also want WEBDAV to work I have commented out some lines in mod_fastcgi.c line 1358:

    /* We don't do anything but GET and POST */
#if 0
    if (r->method_number == M_OPTIONS) {
        r->allowed |= (1 << M_GET);
        r->allowed |= (1 << M_POST);
        return DECLINED;
    }
#endif

Vanilla FastCGI simply checks if the method is GET or POST and declines if otherwise.

If you want to serve PHP as well as Zope
It is possible to server PHP pages from Apache and the Rest from Zope if you add this line just below the RewriteEngine On:
RewriteRule .*\.php - [L]

You will also want to avoid that people can do funny tricks with your PHP scripts through WEBDAV, so you add these lines somewhere near the bottom of your <VirtualHost> envelope.

<LocationMatch ".*\.php">
<Limit  PUT DELETE PROPFIND PROPPATCH MKCOL COPY MOVE LOCK UNLOCK>
    order deny,allow
    deny from all
</Limit>
</LocationMatch>