=begin pod =CHAPTER Configuring Webdao Configuration is done via environment variables. The following variables is using: =begin table :caption('Configuration parameters') name description sample ------------|-------------------------------------------|----------- wdIndexFile |" index.html - name of the file to be processed upon request. Possible values : absolute path or relative to C. Default: C<$ENV{DOCUMENT_ROOT}/index.xhtml> "| index.html wdEngine |" name of the package core module. This module serves all requests coming to I. Default: I "| ShowPrice wdEnginePar |" initialization parameters when creating the main module. Value a string containing the pairs I. Pairs are semicolon separated (I<;>). Default: I "| config=/home/zag/showprice.ini wdSession | Name the package module, which serves a sessional. This module is used to identify a web session. Default: I | WebDAO::Sessionco wdFCGIreq | number of requests for each I process. The parameter is used to work in I mode. Default: -1 - unlimited | 1000 wdDebug |" Debug level. 1 - critical errors, 2 .. n - warns, info. Default: 0 - off "| 2 =end table For server lighttpd uses names respectively: WD_INDEXFILE, WD_ENGINE, WD_ENGINE_PAR, WD_SESSION, WD_STORE, WD_STORE_PAR, WD_DEBUG. =head2 Configuring Web server It supports all popular Web servers: IIS (isapi_fcgi.dll), nginx, lighttpd, apache. The I suuports: I, I, I. The most productive is the mode I. In the examples used the following initial conditions. =begin table :caption('Baseline data') Parameter | Value ----------------------------------|----------- Web root | /usr/zag/www Temporary directory | /tmp Directory for logs | /var/log/ Domain name | example.org Path for file socket for FastCGI | /tmp/myapp.socket =end table =head3 Setup standalone FastCGI In the package I includes a script C ( C for example). To run an independent server using the following command: #!/bin/sh /usr/local/bin/wd_fcgi.fpl -d -l /tmp/myapp.socket -n 5 -maxreq 1000 For help use I<--help>: /usr/local/bin/wd_fcgi.fpl --help Output: Usage: wd_fcgi.fpl [options] -d -daemon Daemonize the server. -p -pidfile Write a pidfile with the pid of the process manager. -l -listen Listen on a socket path, hostname:port, or :port. -n -nproc The number of processes started to handle requests. -m -maxreq Number of request before process will be restarted -1 - unlimited. (defailt: -1) =head4 nginx ( standalone FastCGI) =item * Simple example server { listen 80; server_name example.org; charset utf-8; access_log /var/log/nginx/example.org-access.log ; error_log /var/log/nginx/example.org-error.log debug; root /home/zag/www/; location ~ / { include fastcgi_params; fastcgi_pass unix:/tmp/webdao.sock; fastcgi_param wdSession WebDAO::Sessionco; fastcgi_param wdIndexFile index.xhtm; } } =item * An example of using a custom package of basic module For example, even if used as the name of the module: I. The constructor of this class as a parameter takes I - path to the configuration file. server { listen 80; server_name example.org; charset utf-8; access_log /var/log/nginx/example.org-access.log; error_log /var/log/nginx/example.org-error.log debug; root /home/zag/www/; #sample for static data #location ~* ^/(js|imag|img|data|data2|css|static|images)/ { #} location ~ / { include fastcgi_params; fastcgi_pass unix:/tmp/webdao.sock; fastcgi_param wdSession WebDAO::Sessionco; fastcgi_param wdIndexFile index.xhtm; fastcgi_param wdEngine MySite; fastcgi_param wdEnginePar config=/home/zag/www/mysite.ini; } } =head4 apache (static + standalone FastCGI) There are two modes. When use own manager I (I) and connection is made through FCGI socket. Requires installation of the module I: mod_fastcgi-2.4.2 As part of the global C want to add one of the required sections: =item 1 Static (FastCgiServer) AddHandler fastcgi-script fpl fcgi FastCgiServer /usr/local/bin/wd_fcgi.fpl \ -idle-timeout 3000 -flush -restart-delay 5 \ -initial-env wdFCGIreq=1000 -processes 4 \ =item 2 Standalone ( FastCgiExternalServer ) # Connect via net socket # FastCgiExternalServer /usr/local/bin/wd_fcgi.fpl -host localhost:60000 FastCgiExternalServer /usr/local/bin/wd_fcgi.fpl -socket /tmp/myapp.socket At B section: DocumentRoot /usr/zag/www ServerName example.org ErrorLog /var/log/example.org-error_log CustomLog /var/log/example.org-access_log common SetEnv wdEngine WedDAO::Kern SetEnv wdIndexFile index.xhtml SetEnv wdSession WebDAO::Sessionco RewriteEngine on AddDefaultCharset UTF-8 RewriteCond %{HTTP:Authorization} ^(.*)$ [NC] RewriteRule /.* - [E=HTTP_AUTHORIZATION:%1] RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-f RewriteRule ^/(.*) /usr/local/bin/wd_fcgi.fpl?$1 [QSA] =head4 lighttpd (standalone FastCGI) var.engine = "ZagSite" var.defaults = ( "WD_SESSION"=>"WebDAO::Sessionco", "WD_INDEXFILE"=>"index.xhtm" ) $HTTP["host"] == "example.org" { server.document-root = "/home/zag/www/" setenv.add-environment = var.defaults } #use custom root class - MySite $HTTP["host"] == "example.com" { server.document-root = "/home/zag/www/" setenv.add-environment = var.defaults + ( "WD_ENGINE" => "MySite", "WD_ENGINE_PAR"=>"config=/home/zag/www/mysite.ini" ) } #skip static $HTTP["url"] !~ "^/(js|imag|img|css|static)" { fastcgi.server = ( "" => ( "" => ( "socket" => "/tmp/webdao.sock", "check-local" => "disable" ) ) ) } =head3 Work in cgi mode For work I as I application use the script I =head4 apache ( CGI ) DocumentRoot /usr/zag/www ServerName example.org ErrorLog /var/log/example.org-error_log CustomLog /var/log/example.org-access_log common SetEnv wdIndexFile index.xhtm SetEnv wdEngine WebDAO::Engine SetEnv wdSession WebDAO::Sessionco RewriteEngine on RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-f RewriteRule ^/(.*) /usr/local/bin/wd_cgi.pl?$1 [QSA] AddHandler cgi-script cgi pl Options Indexes FollowSymLinks ExecCGI =head4 Use from command line To run from the command line using the script I. In the process of being implemented using the environment variables. Usage: wd_shell.pl [options] file.pl options: -help - print help message -man - print man page -f file - set root [x]html file Options: -help Print a brief help message and exits -man Prints manual page and exits -f filename Set filename set root [x]html file for load domain See also: L. =end pod