I am about to start learning ruby...

everything I've read so far, was about running ruby on the console, I want to save it and upload it to my server, so I can allow anyone to run the script, then I could write a website or application of some sort with it.

So, what file extension does it need to be saved as, and what are the proper ways to start a ruby file?

Can ruby be used to write a website? meaning could I have valid XHTML strict and all that stuff, with proper HTML codes, yet still harness ruby's functionality?

Thanks,

Edit:

here, I can sum it up:
Can I use Ruby in basically the same way I use PHP?