# Ruby like Php

**URL:** <https://rubytalk.org/t/ruby-like-php/54008>\
**Category:** ruby-talk\
**Created:** [19 June 2009 19:54 UTC](https://rubytalk.org/t/ruby-like-php/54008 "2009-06-19T19:54:50Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Giuseppe\_Caruso](https://avatars.discourse-cdn.com/v4/letter/g/919ad9/32.png) [@Giuseppe\_Caruso](https://rubytalk.org/u/Giuseppe_Caruso)\
**Post date:** [19 June 2009 19:54 UTC](https://rubytalk.org/t/ruby-like-php/54008/1 "2009-06-19T19:54:50Z")

</div>

Hi, I am studying Ruby for web development and I was guessing if there  
is a way to use Ruby, embedded into the html code like one can do with  
Php.  
I know that this could not be such a popular topic here, but I think it  
would be really great to use it "on the fly" in web pages.  
I knew that mod\_ruby is practically abandoned, could Phusion Passenger  
be a solution?

> **···**
>
> --  
> Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).

---

<div class="post-metadata">

**Author:** ![Paolo\_Montrasio](https://avatars.discourse-cdn.com/v4/letter/p/aca169/32.png) [@Paolo\_Montrasio](https://rubytalk.org/u/Paolo_Montrasio)\
**Post date:** [19 June 2009 20:29 UTC](https://rubytalk.org/t/ruby-like-php/54008/2 "2009-06-19T20:29:47Z")

</div>

Giuseppe Caruso wrote:

> Hi, I am studying Ruby for web development and I was guessing if there  
> is a way to use Ruby, embedded into the html code like one can do with  
> Php.  
> I know that this could not be such a popular topic here, but I think it  
> would be really great to use it "on the fly" in web pages.  
> I knew that mod\_ruby is practically abandoned, could Phusion Passenger  
> be a solution?

You may want to look at ERb (embedded Ruby) or at frameworks like Rails  
(which uses ERb).

In both ways you'll end up writing html pages with Ruby code embedded  
between \<% %\> pairs.

Paolo

> **···**
>
> --  
> Posted via [http://www.ruby-forum.com/\](http://www.ruby-forum.com/%5C).

---

<div class="post-metadata">

**Author:** ![Tony\_Arcieri6](https://avatars.discourse-cdn.com/v4/letter/t/ecccb3/32.png) [@Tony\_Arcieri6](https://rubytalk.org/u/Tony_Arcieri6)\
**Post date:** [19 June 2009 20:34 UTC](https://rubytalk.org/t/ruby-like-php/54008/3 "2009-06-19T20:34:07Z")

</div>

Phusion Passenger works much like PHP in that you can just point Apache at  
any Rack-based application and Passenger will automagically make it work  
just like PHP.

> **···**
>
> On Fri, Jun 19, 2009 at 1:54 PM, Giuseppe Caruso \<giuseppe@bonsai-studio.net \> wrote:
> 
> > Hi, I am studying Ruby for web development and I was guessing if there  
> > is a way to use Ruby, embedded into the html code like one can do with  
> > Php.  
> > I know that this could not be such a popular topic here, but I think it  
> > would be really great to use it "on the fly" in web pages.  
> > I knew that mod\_ruby is practically abandoned, could Phusion Passenger  
> > be a solution?
> 
> --  
> Tony Arcieri  
> medioh.com

---

<div class="post-metadata">

**Author:** ![Giuseppe\_Caruso](https://avatars.discourse-cdn.com/v4/letter/g/919ad9/32.png) [@Giuseppe\_Caruso](https://rubytalk.org/u/Giuseppe_Caruso)\
**Post date:** [19 June 2009 20:49 UTC](https://rubytalk.org/t/ruby-like-php/54008/4 "2009-06-19T20:49:24Z")

</div>

Tony Arcieri wrote:

> Phusion Passenger works much like PHP in that you can just point Apache  
> at  
> any Rack-based application and Passenger will automagically make it work  
> just like PHP.

Tony, please, edit the post to delete my email address… 😛

I mean, is there a way to use Ruby like I can do on every webhosting  
service out there?  
i.e. why I can't just write:

\<p\>What time is it? it is \<%= Time.now %\>\</p\>

like I can do with Php?

> **···**
>
> --  
> Posted via [http://www.ruby-forum.com/\](http://www.ruby-forum.com/%5C).

---

<div class="post-metadata">

**Author:** ![Justin\_Collins](https://avatars.discourse-cdn.com/v4/letter/j/3e96dc/32.png) [@Justin\_Collins](https://rubytalk.org/u/Justin_Collins)\
**Post date:** [19 June 2009 20:59 UTC](https://rubytalk.org/t/ruby-like-php/54008/5 "2009-06-19T20:59:45Z")

</div>

Giuseppe Caruso wrote:

> Tony Arcieri wrote:  
> &nbsp;&nbsp;
> 
> > Phusion Passenger works much like PHP in that you can just point Apache at  
> > any Rack-based application and Passenger will automagically make it work  
> > just like PHP.  
> > &nbsp;&nbsp;&nbsp;&nbsp;  
> > Tony, please, edit the post to delete my email address… 😛
> 
> I mean, is there a way to use Ruby like I can do on every webhosting service out there?  
> i.e. why I can't just write:
> 
> \<p\>What time is it? it is \<%= Time.now %\>\</p\>
> 
> like I can do with Php?  
> &nbsp;&nbsp;  
> You can do that because they have mod\_php set up for you. If your hosting service does not have mod\_ruby, but you have shell access, you may be able to (as I have) set up eruby to be used for .rhtml files through your .htaccess file.

-Justin

---

<div class="post-metadata">

**Author:** ![Matt\_Williams](https://avatars.discourse-cdn.com/v4/letter/m/a698b9/32.png) [@Matt\_Williams](https://rubytalk.org/u/Matt_Williams)\
**Post date:** [19 June 2009 21:01 UTC](https://rubytalk.org/t/ruby-like-php/54008/6 "2009-06-19T21:01:46Z")

</div>

You only can on php if mod\_php is installed.... But you could use fastcgi to invoke erb, assuming, of course, that ruby were installed on the hosting service.

Matt

> **···**
>
> On Sat, 20 Jun 2009, Giuseppe Caruso wrote:
> 
> > Tony Arcieri wrote:
> > 
> > > Phusion Passenger works much like PHP in that you can just point Apache  
> > > at  
> > > any Rack-based application and Passenger will automagically make it work  
> > > just like PHP.
> > 
> > Tony, please, edit the post to delete my email address… 😛
> > 
> > I mean, is there a way to use Ruby like I can do on every webhosting  
> > service out there?  
> > i.e. why I can't just write:
> > 
> > \<p\>What time is it? it is \<%= Time.now %\>\</p\>

---

<div class="post-metadata">

**Author:** ![Giuseppe\_Caruso](https://avatars.discourse-cdn.com/v4/letter/g/919ad9/32.png) [@Giuseppe\_Caruso](https://rubytalk.org/u/Giuseppe_Caruso)\
**Post date:** [19 June 2009 21:04 UTC](https://rubytalk.org/t/ruby-like-php/54008/7 "2009-06-19T21:04:38Z")

</div>

Justin Collins wrote:

> Giuseppe Caruso wrote:
> 
> > I mean, is there a way to use Ruby like I can do on every webhosting  
> > service out there?  
> > i.e. why I can't just write:
> > 
> > \<p\>What time is it? it is \<%= Time.now %\>\</p\>
> > 
> > like I can do with Php?  
> > &nbsp;&nbsp;  
> > You can do that because they have mod\_php set up for you. If your  
> > hosting service does not have mod\_ruby, but you have shell access, you  
> > may be able to (as I have) set up eruby to be used for .rhtml files  
> > through your .htaccess file.
> 
> -Justin

Justin, thanks.  
Can you provide me a link to a tutorial/documentation to install it?  
Can I also install Haml?

> **···**
>
> --  
> Posted via [http://www.ruby-forum.com/\](http://www.ruby-forum.com/%5C).

---

<div class="post-metadata">

**Author:** ![Justin\_Collins](https://avatars.discourse-cdn.com/v4/letter/j/3e96dc/32.png) [@Justin\_Collins](https://rubytalk.org/u/Justin_Collins)\
**Post date:** [19 June 2009 22:01 UTC](https://rubytalk.org/t/ruby-like-php/54008/8 "2009-06-19T22:01:46Z")

</div>

Giuseppe Caruso wrote:

> Justin Collins wrote:  
> &nbsp;&nbsp;
> 
> > Giuseppe Caruso wrote:  
> > &nbsp;&nbsp;&nbsp;&nbsp;
> > 
> > > I mean, is there a way to use Ruby like I can do on every webhosting service out there?  
> > > i.e. why I can't just write:
> > > 
> > > \<p\>What time is it? it is \<%= Time.now %\>\</p\>
> > > 
> > > like I can do with Php?  
> > > &nbsp;&nbsp;
> > 
> > You can do that because they have mod\_php set up for you. If your  
> > hosting service does not have mod\_ruby, but you have shell access, you  
> > may be able to (as I have) set up eruby to be used for .rhtml files  
> > through your .htaccess file.
> > 
> > -Justin  
> > &nbsp;&nbsp;&nbsp;&nbsp;  
> > Justin, thanks.  
> > Can you provide me a link to a tutorial/documentation to install it?  
> > Can I also install Haml?  
> > &nbsp;&nbsp;  
> > About halfway down this page should do it: [http://www.hiveminds.co.uk/node/3094](http://www.hiveminds.co.uk/node/3094)

Don't know about Haml. You will need to have its libraries installed where eruby can find them, I guess.

-Justin
