简体   繁体   中英

Deploying rails application

I've been playing around with rails lately and wanted to go through the deploent process just to see how it worked. I created a simple app with a sIngle model from a scaffold. I uploaded it to my server and found I needed to add /public to the URL to get the 'welcome to rails' screen. However, if I attempted to access my model (public/messages) , I just got a 404 error. Can anyone advise me on what to do?

My server uses rails with fcgi.

Apologies for such a simple question, I've not used rails in the past and am not fully sure how it works yet.

Any advice appreciated.

Thanks.

您可能需要考虑使用Passenger的Apache模块(也称为mod_rails或mod_rack)来部署rails应用,它比fcgi更容易并且具有更好的性能。

setting up rails can be tricky and it varies greatly from host to host.

but if you have set it up correctly you shouldn't have to put /public in your URL. /public is the default directory. so if are looking for the default index.html that rails produces it should be #domain.com/index.html

You'll need to check with your host the correct way of uploading and setting up your app.

Did you simply upload the application into your website directory, or are you using symbolic links? Normally with cgi/fcgi, you're better off having the actual application in a non-web accessible directory, and a symlink from your public_html/ (or whatever the web directory is called), which points to the app/public/ directory. However, it could be possible to get it to work without symlinks.

Now, the following information is general/generic and encompasses several popular shared Rails hosts. However, it's certainly possible that your host have different settings. In that case, it would very much help if you could tell us which host you're using.

Inside your app/public/ directory, there should be a file called dispatch.fcgi. First of all, verify that this file is there. If it is, make sure that the file is chmodded to 755 and try changing the first line to:

#!/usr/bin/ruby18

if it is:

#!/usr/bin/ruby

(This may vary depending on your host.)

In your app/public/ directory, there should also be a file called .htaccess. In it, change the following line:

RewriteRule ^(.*)$ /dispatch.cgi?$1 [QSA,L]

to:

RewriteRule ^(.*)$ /dispatch.fcgi?$1 [QSA,L]

If neither of these changes work, please post the full contents of dispatch.fcgi, .htaccess and explain the directory structure of your hosting account. As previously stated, letting us know which host you're using would definitely be helpful too.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM