wwwsrv

Home (Japanese)

<URL:http://www.freedom.ne.jp/toki/ruby.html#ruby:script:wwwsrv>

Release version (English)

<URL:http://www.ruby-lang.org/en/raa-list.rhtml?name=wwwsrv>

Development version (English)

<URL:http://218.219.149.23/wwwsrv/>

CVS

<URL:http://218.219.149.23/cvsweb/>

How to use

Default port of wwwsrv is 8888, and you can access http://localhost:8888/... in following examples. If you will prepare a configuration file of wwwsrv, you can use -f option.

To publish local files and directories

You can mount a local directory of $HOME/public_html to web server's root directory of /.

Example of command line options.

wwwsrv --mount-local=/:$HOME/public_html

Example of configuration file.

__SERVER__

require 'wwwsrv/local'
local_path = File::join(ENV['HOME'], 'public_html')
local_doc = WWWsrv::LocalFileDocument::new(local_path)
SERVER.mount(local_doc, '/')

To execute CGI scripts

You can mount a local CGI directory of $HOME/cgi to web server's CGI directory of /cgi.

Example of command line options.

wwwsrv --mount-cgi=/cgi:$HOME/cgi

Example of configuration file.

__SERVER__

require 'wwwsrv/cgi'
cgi_path = File::join(ENV['HOME'], 'cgi')
cgi_doc = WWWsrv::CGIdocument::new(cgi_path)
SERVER.mount(cgi_doc, '/cgi')

To publish local files and directories with CGI scripts

You can mount a local directory of $HOME/public_html to web server's root directory of /, and you can mount a local CGI directory of $HOME/cgi to web server's CGI directory of $HOME/cgi.

Example of command line options.

wwwsrv --mount-local=/:$HOME/public_html --mount-cgi=/cgi:$HOME/cgi

Example of configuration file.

__SERVER__

require 'wwwsrv/local'
local_path = File::join(ENV['HOME'], 'public_html')
local_doc = WWWsrv::LocalFileDocument::new(local_path)
SERVER.mount(local_doc, '/')

require 'wwwsrv/cgi'
cgi_path = File::join(ENV['HOME'], 'cgi')
cgi_doc = WWWsrv::CGIdocument::new(cgi_path)
SERVER.mount(cgi_doc, '/cgi')

To execute CGI scripts with suffix of .cgi

You can execute CGI scripts that have suffix of .cgi in local $HOME/public_html directory. Other suffix files are published as itself.

Example of command line options.

wwwsrv --mount-local=/:$HOME/public_html --mount-cgi=/:$HOME/public_html:'\.cgi(/|$)'

Example of configuration file.

__SERVER__

local_path = File::join(ENV['HOME'], 'public_html')

require 'wwwsrv/local'
local_doc = WWWsrv::LocalFileDocument::new(local_path)
SERVER.mount('/', local_doc)

require 'wwwsrv/cgi'
cgi_doc = WWWsrv::CGIdocument::new(local_path)
SERVER.mount('/', cgi_doc, :mask => %r!\.cgi(/|$)!)
# NOTE: regular expression of `(/|$)' is required to get a PATH_INFO.

To execute SSI documents with suffix of .shtml

You can execute SSI documents that have suffix of .shtml in local $HOME/public_html directory. Other suffix files are published as itself.

Example of command line options.

wwwsrv --mount-local=/:$HOME/public_html --attach-ssi=/:'\.shtml$'

Example of configuration file.

__SERVER__

# NOTE: It is necessary to mount local files ahead of SSI.
require 'wwwsrv/local'
local_path = File::join(ENV['HOME'], 'public_html')
local_doc = WWWsrv::LocalFileDocument::new(local_path)
SERVER.mount(local_doc, '/')

require 'wwwsrv/ssi'
SERVER.attach('/', :mask => %r!\.shtml$!) { |document|
  WWWsrv::SSIdocument::new(document)
}

To publish local files and directories with CGI scripts and SSI documents.

There are files in a local directory of $HOME/public_html, files that have suffix of .cgi are executed as CGI scripts, files that have suffix of .shtml are executed as SSI document, and other files are published as itself.

Example of command line options.

wwwsrv --mount-local=/:$HOME/public_html --mount-cgi=/:$HOME/public_html:'\.cgi(/|$)' --attach-ssi=/:'\.shtml?$'

Example of configuration file.

__SERVER__

local_path = File::join(ENV['HOME'], 'public_html')

require 'wwwsrv/local'
local_doc = WWWsrv::LocalFileDocument::new(local_path)
SERVER.mount(local_doc, '/')

requre 'wwwsrv/cgi'
cgi_doc = WWWsrv::CGIdocument::new(local_path)
SERVER.mount(cgi_doc, '/', :mask => %r!\.cgi(/|$)!)

require 'wwwsrv/ssi'
SERVER.attach('/', :mask => %r!\.shtml?$!) { |document|
  WWWsrv::SSIdocument::new(document)
}

To use FastCGI application

You can mount a FastCGI application to web server's root directory of /, and that FastCGI application is running with port number of 5678 on localhost.

Example of command line options.

wwwsrv --mount-fcgi=/::inet:localhost:5678

Example of configuration file.

__SERVER__

require 'socket'
require 'wwwsrv/fastcgi'
# NOTE: Some FastCGI applications may not be able to run if keep_conn is true.
fcgi_doc = WWWsrv::FastCGIDocument::new(:keep_conn => true) {
  TCPsocket::new('localhost', 5678)
}
SERVER.mount(fcgi_doc, '/')

If a FastCGI application cannot open a socket by itself, it is need that you use assistant tool of run_fcgi.rb that is placed at misc directory of wwwsrv distribution. If you install wwwsrv by installer, run_fcgi.rb is copyed to a directory in PATH.

run_fcgi inet 5678 '[command to run a FastCGI application]'