# Ruby like Php

**URL:** <https://www.ruby-forum.com/t/ruby-like-php/170633>\
**Category:** Ruby\
**Created:** [June 19, 2009, 9:54pm UTC](https://www.ruby-forum.com/t/ruby-like-php/170633 "2009-06-19T21:54:46Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![caruso\_g](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/848f3c/32.png) [@caruso\_g](https://www.ruby-forum.com/u/caruso_g)\
**Post date:** [June 19, 2009, 9:54pm UTC](https://www.ruby-forum.com/t/ruby-like-php/170633/1 "2009-06-19T21:54:46Z")

</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?

---

<div class="post-metadata">

**Author:** ![caruso\_g](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/848f3c/32.png) [@caruso\_g](https://www.ruby-forum.com/u/caruso_g)\
**Post date:** [June 19, 2009, 10:29pm UTC](https://www.ruby-forum.com/t/ruby-like-php/170633/2 "2009-06-19T22:29:45Z")

</div>

Giuseppe C. 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

---

<div class="post-metadata">

**Author:** ![caruso\_g](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/848f3c/32.png) [@caruso\_g](https://www.ruby-forum.com/u/caruso_g)\
**Post date:** [June 19, 2009, 10:49pm UTC](https://www.ruby-forum.com/t/ruby-like-php/170633/3 "2009-06-19T22:49:22Z")

</div>

Tony A. 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:

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

like I can do with Php?

---

<div class="post-metadata">

**Author:** ![caruso\_g](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/848f3c/32.png) [@caruso\_g](https://www.ruby-forum.com/u/caruso_g)\
**Post date:** [June 19, 2009, 10:35pm UTC](https://www.ruby-forum.com/t/ruby-like-php/170633/4 "2009-06-19T22:35:13Z")

</div>

On Fri, Jun 19, 2009 at 1:54 PM, Giuseppe C.  
\<removed\_email\_address@domain.invalid

> 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?

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.

---

<div class="post-metadata">

**Author:** ![caruso\_g](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/848f3c/32.png) [@caruso\_g](https://www.ruby-forum.com/u/caruso_g)\
**Post date:** [June 19, 2009, 11:03pm UTC](https://www.ruby-forum.com/t/ruby-like-php/170633/5 "2009-06-19T23:03:44Z")

</div>

On Sat, 20 Jun 2009, Giuseppe C. wrote:

> i.e. why I can’t just write:
> 
> What time is it? it is \<%= Time.now %\>

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

---

<div class="post-metadata">

**Author:** ![caruso\_g](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/848f3c/32.png) [@caruso\_g](https://www.ruby-forum.com/u/caruso_g)\
**Post date:** [June 19, 2009, 11:02pm UTC](https://www.ruby-forum.com/t/ruby-like-php/170633/6 "2009-06-19T23:02:33Z")

</div>

Giuseppe C. 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:
> 
> What time is it? it is \<%= Time.now %\>
> 
> like I can do with Php?

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:** ![caruso\_g](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/848f3c/32.png) [@caruso\_g](https://www.ruby-forum.com/u/caruso_g)\
**Post date:** [June 19, 2009, 11:04pm UTC](https://www.ruby-forum.com/t/ruby-like-php/170633/7 "2009-06-19T23:04:36Z")

</div>

Justin C. wrote:

> Giuseppe C. 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:
> > 
> > What time is it? it is \<%= Time.now %\>
> > 
> > like I can do with Php?
> 
> 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?

---

<div class="post-metadata">

**Author:** ![caruso\_g](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/848f3c/32.png) [@caruso\_g](https://www.ruby-forum.com/u/caruso_g)\
**Post date:** [June 20, 2009, 12:02am UTC](https://www.ruby-forum.com/t/ruby-like-php/170633/8 "2009-06-20T00:02:34Z")

</div>

Giuseppe C. wrote:

> > > like I can do with Php?  
> > > Justin, thanks.  
> > > Can you provide me a link to a tutorial/documentation to install it?  
> > > Can I also install Haml?

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
