.htaccess
(typically on host services)
mod_fcgid
or mod_fastcgi
apt-get install libfcgi-perl
yum install perl-FCGI
zypper install perl-FCGI
emerge dev-perl/FCGI
pkg install p5-FCGI
cpanm FCGI
mod_fcgid
is provided by default with apache2, and is recommended for simplicity of installation and configuration.
Below are some resources for the most common Linux distributions. The actual versions of the latest packages may have changed since this documentation was written.
mod_fcgid resources FcgidMaxRequestLen
must be large enough to
permit upload of the largest possible attachment, or the upload will fail with a 500 status. Be sure the FcgidMaxRequestLen
is larger so that the user will get a
friendly error message from Foswiki. The default limit on recent Apache releases is 131072 bytes. It is not possible to override this in a .htaccess
file.
Foswiki also ships with an example apache configuration, and example
.htaccess
files which include Fcgi example configurations.
/foswiki/bin
) and file system paths (/var/www/foswiki
) below
as appropriate for your system.
# Example with FastCGI processes launched by the webserver $HTTP["url"] =~ "^/foswiki/bin/" { alias.url += ( "/foswiki/bin" => "/var/www/foswiki/bin/foswiki.fcgi" ) fastcgi.server = ( ".fcgi" => ( ( "socket" => "/var/www/foswiki/working/tmp/foswiki.sock", "bin-path" => "/var/www/foswiki/bin/foswiki.fcgi", "max-procs" => 3 ), ) ) }
# Example with external FastCGI processes (running on the same host, with another user or at a remote machine) $HTTP["url"] =~ "^/foswiki/bin/" { alias.url += ( "/foswiki/bin" => "/var/www/foswiki/bin/foswiki.fcgi" ) fastcgi.server = ( ".fcgi" => ( ( "host" => "example.com", "port" => "8080", ), ) ) }
foswiki.fcgi
backend process. Instead you will
have to start it yourself using the system's init process. The FCGI::ProcManager class will then take care of (re-)spawning
enough child processes as required.
foswiki.fcgi
process on some socket on the localhost: /var/www/foswiki
, /var/log/nginx
) below as appropriate for your system. This configuration
uses "short URLs".
server { listen 80; server_name nginx.domain.com; set $foswiki_root "/var/www/foswiki"; root $foswiki_root; access_log /var/log/nginx/foswiki-access.log; error_log /var/log/nginx/foswiki-error.log; #error_log /var/log/nginx/foswiki-error.log debug; client_max_body_size 10M; # Set to maximum attachment size, See also ATTACHFILESIZELIMIT location = / { root $foswiki_root; rewrite .* /Main/WebHome; } location ~ (^/pub) { allow all; } location ~ ^/bin/ { gzip off; #fastcgi_pass unix:/var/run/nginx/foswiki.sock; fastcgi_pass 127.0.0.1:9000; fastcgi_split_path_info ^(/bin/\w+)(.*); # Captures two variables ($fastcgi_script_name) and ($fastcgi_path_info) fastcgi_param SCRIPT_FILENAME $foswiki_root/bin/$fastcgi_script_name; fastcgi_param SCRIPT_NAME $fastcgi_script_name; fastcgi_param PATH_INFO $fastcgi_path_info; include fastcgi_params; } location ~ (^/lib|^/data|^/locale|^/templates|^/tools|^/work) { deny all; } if ($http_user_agent ~ ^SiteSucker|^iGetter|^larbin|^LeechGet|^RealDownload|^Teleport|^Webwhacker|^WebDevil|^Webzip|^Attache|^SiteSnagger|^WX_mail|^EmailCollector|^WhoWhere|^Roverbot|^ActiveAgent|^EmailSiphon|^CrownPeak-HttpAgent|^$) { rewrite .* /404.html break; } location ~ ^/(.*)$ { rewrite ^/(.*)$ /bin/view/$1; } }
foswiki.fcgi
process into the system init. foswiki.fgi
process into the system's init process use the two helper scripts in the tools
directory:
tools/foswiki.init-script
: copy this to /etc/init.d/foswiki
; make the file executable using chmod +x /etc/init.d/foswiki
, and ensure that it is assigned to user/group root.
tools/foswiki.defaults
: copy this to /etc/default/foswiki
and make appropriate adjustments; 127.0.0.1:9000
)
FOSWIKI_ROOT
setting points to your foswiki installation.
tools/systemd/foswiki-fastcgi.service
: copy this to /etc/systemd/system/foswiki.service
.
tools/foswiki.freebsd.init-script
:
tools/foswiki.freebsd.etc-defaults
:
tools/foswiki.defaults
. If you need to override any of: www-data
/var/www/foswiki/working/foswiki.pid
/var/www/foswiki/bin/
/etc/systemd/system/foswiki.service
file must be edited directly, or overridden by a systemd "drop-in" file created in
/etc/systemd/system/foswiki.d/foswiki.conf
.
systemd
, then you will need to trigger a re-read of the init scripts and service files by running (as root): systemctl daemon-reload
.
This must be done any time the init scripts or service files are modified.
You should now be able to control the backend processes using either: service foswiki start/stop/reload/restart/status
. or
/etc/init.d/foswiki start/stop/reload/restart/status
update-rc.d foswiki defaults
to make sure the service is started on system startup time.
/etc/init.d/foswiki
, /etc/defaults/foswiki
and if used, /etc/systemd/system/foswiki.service
, to a new name (ex. myfoswiki)
foswiki.service
file would need similar changes not detailed here.) # Provides: myfoswiki # Short-Description: Start the myfoswiki backend server. NAME=myfoswiki <== Should match script name # The following defaults are overridden in etc/default/foswiki FOSWIKI_PNAME=myfoswiki <== Process name displayed in =ps aux=
fastcgi_pass
and matching FOSWIKI_BIND
.htaccess
file, it's possible to adjust the number of FastCGI processes. There is no magic number: it depends on some variables, like the hardware resources and access load. If you set this number too low, users may experience high latencies and you'll not use all hardware potential, on the other hand if this setting is adjusted too high then the server can be forced to use swap, what degrades performance a lot.
Due to possible memory growth, it's recommended to automatically restart the FCGI handlers afer they serve some number of requests. On Apache, this is
done using the FcgidMaxRequestsPerProcess 500
setting. On other web servers, use the Foswiki configuration setting: {FastCGIContrib}{MaxRequests} = 100
Dynamic servers are more useful when Foswiki access load on the server is low and/or it's used for something in addition to Foswiki. Under high loads, static servers can deliver better performance.
LocalSite.cfg
is changed. However there is a delay, and it is recommended to restart apache.
After the update, each process will still serve one more request before reloading itself (e.g. if you're using 3 processes, the next 3 requests after the update will not be affected. The update will take effect on the requests made after the initial 3). This reloading mechanism works only on operating systems that have the exec(2)
system call, like Linux and other POSIX compliant systems.
FastCGI support on IIS 6.0 (and maybe other versions) is broken with respect to the STDERR
stream. This may cause problems.
Name | Version | Description |
---|---|---|
FCGI | >0.67 | Optional. Required for nginx, and other web servers when configured for FastCGI support |
FCGI::ProcManager | >0.23 | Optional. Required on nginx for dynamic FCGI handler management. Not used with Apache. |
27 Sep 2021 | (1.20) Foswikitask:Item15043 - fixed parameter handling, i.e. when using zeor max requests |
21 Oct 2020 | (1.10) Foswikitask:Item14963 - add warmup parameter |
02 Dec 2017 | (1.05) Foswikitask:Item14532 - Allow process name to be overridden when running as started task. Foswikitask:Item11491 - Document relationship between ATTACHFILESIZELIMIT and FcgidMaxRequestLen .Foswikitask:Item14577 - Add sample init scripts for FreeBSD. |
21 May 2017 | (1.04) Foswikitask:Item14346 - Fix issues in the systemd service file. Improve documentation. Foswikitask:Item14402 - Fix default Foswiki root location. along with more doc improvements. |
04 Oct 2016 | (1.03) Foswikitask:Item13883 - Documentation updates, Foswikitask:Item14086 - Add a systemd example service file. |
14 Jun 2015 | (1.02) Foswikitask:Item10751 - Prepare for Unicode core. |
29 Mar 2015 | (1.01) Foswikitask:Item13342 - Add missing dependency, don't re-init back end after every transaction while bootstrapping. |
14 Jan 2015 | (1.00) Foswikitask:Item13010 - make checking LocalSite.cfg for changes optional so that it can be disabled for improved stability on high traffic sites |
29 Aug 2014 | (0.97) Foswikitask:Item13010 - fixed instability running under FCGI::ProcManager |
20 Feb 2014 | (0.96) Foswikitask:Item12755 - fixed socket not being closed properly on a reExec; work around error in FCGI.pm; added quiet parameter to suppress normal messages; fixed tainted pid filename; |
08 Sep 2011 | (0.95) Foswikitask:Item9957 - remove uninitialised value log message |
26 Oct 2010 | (0.94) Foswikitask:Item9902 - Adding more resources about how to get and install CPAN lib and mod_fcgid or mod_fastcgi. Also includes temporary fix from Foswikitask:Item1515: added maxRequests to ease memory leaks and fix for Foswikitask:Item9456: Taint error with foswiki.fcgi |
17 Sep 2010 | (0.93) Foswikitask:Item9701 - Documentation update, suggest mod_fcgid preferred over mod_fastcgi |
03 Sep 2010 | Foswikitask:Item9456 - Taint error, Foswikitask:Item9390 - LocalSite.cfg error handling, Foswikitask:Item8765 - Perl coding issue, Foswikitask:Item1315 - Support information |
21 Dec 2009 | Foswiki:Main.ItaloValcy: fix Foswikitask:Item8238 |
24 Jan 2009 | Documentation enhancements and some fixes (Foswikitask:Item853) |
25 Dec 2008 | Initial Release |
Author | Gilmar Santos Jr |
Version | 1.20 |
Release | 30 Sep 2021 |
Repository | https://github.com/foswiki/distro |
Copyright | © 2008-2021 Gilmar Santos Jr and Foswiki Contributors |
License | GPL (Gnu General Public License) |
Home | http://foswiki.org/Extensions/FastCGIEngineContrib |
Support | http://foswiki.org/Support/FastCGIEngineContrib |