# Webrick serving php pages?

**URL:** <https://www.ruby-forum.com/t/webrick-serving-php-pages/100502>\
**Category:** Ruby\
**Created:** [July 29, 2006, 5:11pm UTC](https://www.ruby-forum.com/t/webrick-serving-php-pages/100502 "2006-07-29T17:11:51Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![quik77](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/q/dec6dc/32.png) [@quik77](https://www.ruby-forum.com/u/quik77)\
**Post date:** [July 29, 2006, 5:11pm UTC](https://www.ruby-forum.com/t/webrick-serving-php-pages/100502/1 "2006-07-29T17:11:51Z")

</div>

I carry many .php pages, but I mostly write in Ruby these days.

My question is if webrick could be used to serve php pages.

Right now I use apache, but I want to be flexible and become less  
dependant on apache. (Actually, that apache sends the pages to the php  
interpreter, is pretty much the only reason I use apache).

Is it possible to send .php pages to the php parser, and have webrick  
serve the resulting html “string” to the “visitor”? (“Visitor” because  
these pages arent really for everyone, its mostly a local faq for me  
which i wrote in php some years ago)

---

<div class="post-metadata">

**Author:** ![quik77](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/q/dec6dc/32.png) [@quik77](https://www.ruby-forum.com/u/quik77)\
**Post date:** [July 29, 2006, 5:58pm UTC](https://www.ruby-forum.com/t/webrick-serving-php-pages/100502/2 "2006-07-29T17:58:06Z")

</div>

On 7/29/06, Marc H. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> I carry many .php pages, but I mostly write in Ruby these days.
> 
> My question is if webrick could be used to serve php pages.
> 
> Right now I use apache, but I want to be flexible and become less  
> dependant on apache. (Actually, that apache sends the pages to the php  
> interpreter, is pretty much the only reason I use apache).

It should be possible to use command line php (php.exe on win)  
together with WEBrick::CGIHandler:

[http://microjet.ath.cx/webrickguide/html/CGIHandler.html](http://microjet.ath.cx/webrickguide/html/CGIHandler.html)

That way, you’ll call your php scripts as  
…/cgi/php.cgi/tada.php?fsgsdfg  
(or similar, I haven’t tried)

Additionally, you can write PHPHandler \< CGIHandler, that will call  
php for you, and add it to the FileHandler configuration  
(:HandlerTable,  
[http://microjet.ath.cx/webrickguide/html/FileHandler\_Configuration.html](http://microjet.ath.cx/webrickguide/html/FileHandler_Configuration.html))

Anyway, I expect it to be pretty slow, as php will be started each  
time anew. Try, and you’ll see. (It’d be nice if you’d post your  
findings, as I haven’t done this and I’m curious)

HTH,  
Jano

---

<div class="post-metadata">

**Author:** ![quik77](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/q/dec6dc/32.png) [@quik77](https://www.ruby-forum.com/u/quik77)\
**Post date:** [July 29, 2006, 7:35pm UTC](https://www.ruby-forum.com/t/webrick-serving-php-pages/100502/3 "2006-07-29T19:35:42Z")

</div>

Mongrel’s plugin support will be available soon, and I’m going to take  
a shot at getting a PHP interpreter working with that, but as for  
right now, your best bet is to look up NanoWeb. It’s a mini webserver  
written in PHP, much like Webrick is to Ruby. It seems to perform very  
well. If nothing else, you can configure it on a different port and do  
some form of proxying to that port for getting the PHP pages served.

M.T.
