Mason FastCGI

From DreamHost

Jump to: navigation, search

Contents

FastCGI Instructions

  1. Setup the CPAN module.
  2. Run: cpan -i CGI::Fast BSD::Resource
  3. Grab mason.fcgi and place it in the document root of your website. (Make sure it's named mason.fcgi.)
  4. The mason.fcgi script must be executable. The script and the containing directory must be group-writable by your default unix group:
 (chgrp `groups | awk '{print $1}'` . mason.fcgi ;  chmod 775 . mason.fcgi )
  1. Grab .htaccess and place it in any directory on your website that you want to be run through Mason. (Make sure it's named .htaccess.)
  2. To try the script out from the commandline you should do "./mason.fcgi" If you want to run manually with perl, make sure you pass -T.

CGI Instructions

  1. Follow the FastCGI Instructions above
  2. Rename mason.fcgi to mason.cgi
  3. Edit the .htaccess to change its reference to mason.fcgi to mason.cgi

Things to be aware of

This script will create a mason/SITENAME directory off of your home directory and place the Mason runtime files there.

Advantages of this method

  • This handler requires no setup other then putting it in place.
  • It automatically includes the path to the modules you've installed via CPAN.
  • It puts in process limits to stop your script from impacting other people from the script if a bug causes it to leak memory or enter an infinite loop.
  • It runs under taint mode so that it's more difficult to accidentally use untrusted (user provided) information in unsafe ways.
  • It turns on HTML escaping by default in Mason which will significantly reduce the chance of creating a site vulnerable to XSS attacks. You can still output stuff without HTML escaping with the "n" flag, eg <% $stuff |n %>.
  • Works with both CGI and FastCGI in one script.

Disadvantages of this method

  • Does no forking. It'd be nice to get a nice pre-forking FastCGI handler for Perl.
Personal tools