To get php support in webrick, you can use a handler for php files. To do this, you need to expand HttpServlet::AbstractServletand implement the methods do_GETand do_POST. These methods are called for GET and POST requests from the browser. There you just need to file an incoming request at php-cgi.
For PHPHandler to process php files, you must add it to a HandlerTablespecific mount. You can do it as follows:
s = HTTPServer.new(
:Port => port,
:DocumentRoot => dir,
:PHPPath => phppath
)
s.mount("/", HTTPServlet::FileHandler, dir,
{:FancyIndexing => true, :HandlerTable => {"php" => HTTPServlet::PHPHandler}})
The first statement initializes the server. The second adds mounting options DocumentRoot. Here it allows you to list directories and process php files with PHPHandler. After that, the server can be started with s.start().
PHPHandler , - . webricks CGIHandler, , php-cgi. PHPHandler GitHub:
https://github.com/questmaster/WEBrickPHPHandler