如何在Bluehost上部暑rails 应用?

发布于 2022-08-21 12:27:46 字数 65 浏览 15 评论 2

Google找了很多方法,都没部暑成功,包括用SSH。Segment Fault的朋友有没有成功的部暑经验可以分享。

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

忆沫 2022-08-27 04:16:54

Digital Ocean 的文档还是不错的

https://www.digitalocean.com/community/tags/ruby-on-rails

顺便推广下Ruby-China社区和我开发的社区的Android开源客户端

灯下孤影 2022-08-26 04:42:22

经过测试,发现bluehost上面目前不支持rails3,主要是由于bluehost使用了dispatch。rails2.3.5的程序可以部署。
不使用SSH也可以部署Rails2的项目。
如果你没有SSH权限。建议跟在线客服联系,开通权限,因为涉及到一些操作会比较方便。

在有SSH权限的情况下部署rails2项目。
在bluehost的管理平台创建项目指向路径 /rails_apps/bilinguis ,选择 生产环境,然后系统就会帮你自动生成项目了。
创建一个软连接来指向你的项目。这样我们才能够访问到它。

确认/home2/{帐号名称}/public_html/ 目录下没有bilinguis,如果有的话,删除掉它。
使用rm bilinguis
ln -s /home2/{帐号名称}/rails_apps/bilinguis/public /home2/{帐号名称}/public_html/bilinguis

上传之后,访问一下这个php 文件。
正常是个空白页面,如果不正常,会有错误代码。

好了。这个时候你就可以访问到 rails的欢迎界面了。

由于需要使用到dispatch.fcgi

接下来你需要做的就是 修改 /rails_apps/bilinguis/public/.htaccess 文件

内容如下

  • General Apache options

AddHandler fcgid-script .fcgi
AddHandler cgi-script .cgi

  • Options +FollowSymLinks +ExecCGI
  • If you don't want Rails to look in certain directories,
  • use the following rewrite rules so that Apache won't rewrite certain requests

#

  • Example:
  • RewriteCond %{REQUEST_URI} ^/notrails.*
  • RewriteRule .* - [L]
  • Redirect all requests not available on the filesystem to Rails
  • By default the cgi dispatcher is used which is very slow

#

  • For better performance replace the dispatcher with the fastcgi one

#

  • Example:
  • RewriteRule ^(.*)$ dispatch.fcgi [QSA,L]

RewriteEngine On

  • If your Rails application is accessed via an Alias directive,
  • then you MUST also set the RewriteBase in this htaccess file.

#

  • Example:
  • Alias /myrailsapp /path/to/myrailsapp/public
  • RewriteBase /myrailsapp

RewriteBase /
RewriteRule ^$ index.html [QSA]
RewriteRule ^([^.]+)$ $1.html [QSA]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ dispatch.fcgi [QSA,L]

  • In case Rails experiences terminal errors
  • Instead of displaying this message you can supply a file here which will be rendered instead

#

  • Example:
  • ErrorDocument 500 /500.html

ErrorDocument 500 "<h2>Application error</h2>Rails application failed to start properly"

然后你就可以自己去创建一些controller,view去玩拉。

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文