我的项目做了很久了,可惜没有rails环境支持,迟迟没有上线。最近买了hostmonster的虚拟主机,买它之前据说它是支持ror的,搞了大半天,全是扯淡…还得自己动手。
首先,你要去hostmonster申请SSH,去提交个Ticket就行了,很快的。
首先用ssh登陆服务器,为rails application创建一个工作区,
xx@xx.com [~]# mkdir rails
xx@xx.com [~]# cd rails
xx@xx.com [~]# rails inlocals
xx@xx.com [~]# cd inlocals
接下来,建立一个子域名供这个程序运行。登入cPanel,,点击 ’subdomains’,在第一个文本框中输入’inlocals’点击’Add’即可。
删除inlocals子域名创建的文件夹。将inlocals应用的public目录设为inlocals.xx.com的根根目录。
xx@xx.com [~]# rm -r ~/public_html/inlocals
xx@xx.com [~]# cd ~/public_html/
xx@xx.com [~]# ln -s ~/rails/inlocals/public inlocals
打开inlocals.xx.com可以看到我的Ruby on Rails的欢迎语。接下来将你的代码全部上传到rails/inlocals目录,把rails/inlocals/public /dispatch.cgi的权限设为755,在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"
打开浏览器,输入http://inlocals.xx.com,over了。
我将我自己的域名www.inlocals.com绑定到inlocals.xx.com,就可以使用www.inlocals.com访问偶的网站了…
原文地址:
http://www.kokkowon.com/archives/118
分享到:
相关推荐
- **原因**:本书推荐使用Hostmonster.com作为首选托管服务提供商之一,可能是因为该公司的服务质量高、支持好以及价格合理等因素。 ### 关于作者及写作背景 - **作者简介**:Robert Schifreen是一位经验丰富的...
要将cPanel界面改为中文,只需进入设置选项,选择“Language”(语言),然后选择“简体中文”即可。这一更改将立即生效,并使整个控制面板界面变为中文显示。 #### Cpanel错误页 cPanel允许用户自定义错误页,这...
1. 使用FTP客户端软件(如FileZilla、WinSCP等)连接到FTP服务器。 2. 将压缩后的Joomla网站文件上传至之前设置的根目录。 3. 上传完成后,通过FTP客户端或托管商提供的旧版文件管理器(Legacy File Manager)解压缩...
市面上有许多提供WordPress专属易安装包的服务商,如Bluehost、HostMonster和DreamHost等,它们通常会附带大幅度折扣。 2. **域名选择与设置**:域名不仅关系到品牌形象,还直接影响搜索引擎排名。本书将介绍如何...