### ### Copyright 2000-2007 University of Illinois Board of Trustees ### All rights reserved. ### ### FastCGI.pm - Apache/FastCGI config module for psgconf ### ### Campus Information Technologies and Educational Services ### University of Illinois at Urbana-Champaign ### package PSGConf::Control::Apache::FastCGI; use strict; use PSGConf::Data::Boolean; use PSGConf::Data::List; use PSGConf::Data::String; use PSGConf::Control::Packages qw(_add_pkgs); ############################################################################### ### policy methods ############################################################################### sub _policy_check_apache { my ($self, $psgconf) = @_; $psgconf->data_obj('www_fcgi_enable')->set('false') if ($psgconf->data_obj('www_enable')->equals('false')); } ### add Apache modules sub _policy_add_modules { my ($self, $psgconf) = @_; return if ($psgconf->data_obj('www_fcgi_enable')->equals('false')); ### add modules $psgconf->data_obj('www_modules')->append_row( [ 'fastcgi' ] ) if (! $psgconf->data_obj('www_modules')->find_row({0 => 'fastcgi'})); } ### update Apache config sub _policy_add_config { my ($self, $psgconf) = @_; my ($wrapper, $ipc_dir, $text); return if ($psgconf->data_obj('www_fcgi_enable')->equals('false')); $wrapper = $psgconf->data_obj('www_fcgi_wrapper_path')->get(); $ipc_dir = $psgconf->data_obj('www_fcgi_ipc_dir')->get(); $text = " AddHandler fastcgi-script .fcgi FastCgiIpcDir $ipc_dir"; $text .= " FastCgiWrapper $wrapper" if (defined($wrapper)); $text .= ' '; $psgconf->data_obj('www_main_server_config')->prepend($text); ### Add index.fcgi to the DirectoryIndex list if ( !grep /index\.fcgi/, $psgconf->data_obj('www_main_server_options')->find('DirectoryIndex')) { $text = 'index.fcgi ' . $psgconf->data_obj('www_main_server_options')->find('DirectoryIndex'); $psgconf->data_obj('www_main_server_options')->insert({ DirectoryIndex => $text }); } } ############################################################################### ### Constructor ############################################################################### sub new { my ($class, $psgconf) = @_; my ($self); $self = {}; bless($self, $class); ### So that _add_pkgs knows which directives to look at $self->{name} = 'www_fcgi'; $self->{enable} = $self->{name} . '_enable'; $self->{packages} = $self->{name} . '_packages'; $psgconf->register_data( www_fcgi_enable => PSGConf::Data::Boolean->new( value => 'false' ), www_fcgi_packages => PSGConf::Data::List->new(), www_fcgi_ipc_dir => PSGConf::Data::String->new( value_abspath => 1, value => '/var/lib/httpd' ), www_fcgi_wrapper_path => PSGConf::Data::String->new( value_abspath => 1, value => '/usr/local/sbin/suexec' ) ); $psgconf->register_policy($self, fcgi_check_apache => '_policy_check_apache', fcgi_add_packages => '_add_pkgs', fcgi_add_apache_modules => '_policy_add_modules', fcgi_add_apache_config => '_policy_add_config' ); return $self; } ############################################################################### ### documentation ############################################################################### 1; __END__ =head1 NAME PSGConf::Control::Apache::FastCGI - psgconf control class for Apache mod_fastcgi =head1 SYNOPSIS In F: Control PSGConf::Control::Apache::FastCGI =head1 DESCRIPTION The B module provides a B control object for configuring the Apache F module. It supports the following methods: =over 4 =item new() The constructor. Its parameter is a reference to the B object. It registers the following data objects: =over 4 =item I A B value, indicating whether FastCGI should be configured. The default is no. =item I A B value, indicating what packages need to be installed. =item I A B object containing the absolute path to the FastCGI IPC directory. The default is F. =item I A B object containing the absolute path to the FastCGI wrapper binary. The default is F. If unset, the C config directive is not added. =back The constructor also registers the following policy methods: =over 4 =item I If the I data object (supplied by the B module) is not set, then unsets the I object. =item I Adds F and F to the list of requested packages. (This uses the I config object supplied by B.) =item I Adds the F module to the I data object (provided by the B module). =item I Adds some reasonable defaults to the I data object (provided by the B module). =back =back =head1 SEE ALSO L L L L L L L L =cut