views:

121

answers:

1

I played around with Rails on my laptop (running Linux + Apache + MySQL) and had no trouble getting the Getting Started with Rails tutorial to work locally. Now I'm trying the same thing at work on a remote Mac OS X + Apache server, and things aren't quite so rosy.

I typed rails blog -d mysql to create a directory called blog in /Library/WebServer/Documents/mydirectory. The trouble is, if I go to server.com/mydirectory/public, I get the public/index.html in my browser. But, I don't get this file if I go to server.com/mydirectory/. Instead, I get a 403 error. Also, when I:

script/generate controller home index

to create:

app/views/home/index.html.erb

I am unable to view this file, whether I go to server.com/mydirectory/home/index, or if I add a new line (map.root :controller => "home") to config/routes.rb and go to server.com/mydirectory.

Am I missing something really obvious about Apache and Rails?

+1  A: 

Apache does not support Rails out of the box. You have to get mod_rails aka Passenger installed. Or, you could just use the server that comes with Rails, which is much easier (but not suitable for production). To do this, go to your directory and do ./script/server.

ryeguy
Does this mean that rails would start another server on top of Apache? The Apache server isn't mine. I just have a little corner of it to play around in. Am I able to run another server in this directory?Also, does this mean I would access this rails server at server.com/mydirectory:3000?Thanks for your help!
paracaudex
I haven't tried it, but apparently other people have used mod_php and mod_rails along side successfully: http://railsforum.com/viewtopic.php?id=24584. Is this for production or what? Keep in mind there are other servers out there, like Thin, but then you'd have to handle the proxying yourself.
ryeguy
I'm writing a web app in mysql and php and was thinking of moving it to rails. The dept. at the university let me put the web app on one of their apache servers. I was curious if I could just start running rails in my directory. It seems like there might be more server issues though. I can't just run rails remotely on this Apache installation?
paracaudex
What do you mean remotely? You run it in the same way as PHP. You define a virtual host, and point the directory to the public folder of the rails app.
ryeguy
Sorry, let me rephrase. Am I going to break anything outside of my own directory if I:1. Log into the server, which is already running Apache.2. Go to my rails directory.3. Type /script/serverAnd, if I do this, how will I access the rails server?
paracaudex
No, `./script/server` is it's own process and doesn't use Apache.It uses a server called WEBrick, which comes with Rails. It launches a server on port 3000 by default, so you would just navigate to `server:3000`. This is great for development or really low traffic apps, but once you put it in production you will want to use a real server like Apache.
ryeguy
Thanks! You've been really helpful.
paracaudex