`
yang_kunlun
  • 浏览: 77212 次
  • 性别: Icon_minigender_1
  • 来自: 地球
最近访客 更多访客>>
社区版块
存档分类
最新评论

ROR安装过程

    博客分类:
  • ROR
阅读更多
Step 1: As usual, the first thing we'll want to do is make sure your version of Hardy Heron 8.04 is up to date.:

sudo apt-get update
sudo apt-get dist-upgrade

Step 2: We'll be installing some software that needs to be built so we'll need to get packages required for compiling. In one swoop, you can type this command and get everything you need:

sudo apt-get install build-essential

Step 3: Once you've got the tools, it's time to grab MySQL and Ruby. Just copy and paste this command into your terminal if you're in a hurry.

sudo apt-get install ruby ri rdoc mysql-server libmysql-ruby ruby1.8-dev irb1.8 libdbd-mysql-perl libdbi-perl libmysql-ruby1.8 libmysqlclient15off libnet-daemon-perl libplrpc-perl libreadline-ruby1.8 libruby1.8 mysql-client-5.0 mysql-common mysql-server-5.0 rdoc1.8 ri1.8 ruby1.8 irb libopenssl-ruby libopenssl-ruby1.8 psmisc

If you hadn't previously installed MySQL you'll be asked to set a root password. Don't forget what you choose!

Step 4: Grab the latest ruby gems and install them. As always be sure to check rubyforge.org to make sure you're grabbing the latest one. As of this writing it's 1.1.1 but it never hurts to check.

wget http://rubyforge.org/frs/download.php/35283/rubygems-1.1.1.tgz
tar xvzf  rubygems-1.1.1.tgz
cd rubygems-1.1.1
sudo ruby setup.rb

Once it's done you can remove the .tgz file and erase the rubygems-1.1.1 directory too.

Step 5: Make symlinks. Just in case the symlinks did not get created for you (the symlink for gem was missing for me so don't assume) go ahead and create them with these commands:

sudo ln -s /usr/bin/gem1.8 /usr/local/bin/gem
sudo ln -s /usr/bin/ruby1.8 /usr/local/bin/ruby
sudo ln -s /usr/bin/rdoc1.8 /usr/local/bin/rdoc
sudo ln -s /usr/bin/ri1.8 /usr/local/bin/ri
sudo ln -s /usr/bin/irb1.8 /usr/local/bin/irb

Step 6: Install ruby on rails!! I installed this on a minimal Slicehost install and it took forever because of the limited ram. I'm going to suggest you run the command and skip the rdoc and ri installs unless you really want them. (in which case the below command is simply sudo gem install rails)

sudo gem install rails --no-rdoc --no-ri

Step 7: Let's install mongrel now that we've got ruby gems and rails working. If you've done this before you'll be happy to see that it's getting easier as rubygems is now grabbing dependencies and also checking your architecture.

sudo gem install mongrel --no-rdoc --no-ri

At this point you have a complete rails stack ready for local development on Hardy, Sidux, or Debian. If you want to get things going for a server (install nginx, mongrel cluster) then read on. Otherwise you're done, so happy developing!

Step 8: The first thing in preparing to deploy this sucker is to grab a real web server. I'm still using Nginx.. haven't been disappointed with performance in the slightest.

sudo apt-get install libpcre3 nginx libfcgi-dev libfcgi-ruby1.8 libfcgi0ldbl

When it asks you what webserver to pre-configure leave everything blank. We're using nginx not apache this time. (Apache 2 with Ruby on Rails for Gutsy is covered here.)

Step 9: Let's install and configure mongrel cluster. This is a lengthy set of tasks each of which is important so please pay special attention and seek help in your favorite forums if you aren't familiar with linux. For new users: tab-autocomplete is your friend.

sudo gem install mongrel_cluster --no-rdoc --no-ri

Copy the init file over to /etc/init.d/ by typing this all on one line:

sudo cp /usr/lib/ruby/gems/1.8/gems/mongrel_cluster-1.0.5/resources/mongrel_cluster /etc/init.d/mongrel_cluster

You may need to change the above command if a version other than mongrel_cluster-1.0.5 was installed.

Next, add a path statement to mongrel_cluster file just above the CONF_DIR variable:

sudo vi /etc/init.d/mongrel_cluster
PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local:/usr/local/sbin:/usr/local/bin

You may also want to change the USER=mongrel to USER=www-data but I'll leave that up to you.

Let's modify permissions and make sure we boot mongrel on startup:

sudo chmod +x /etc/init.d/mongrel_cluster
sudo update-rc.d mongrel_cluster defaults

We're not quite done yet -- we need to setup the mongrel cluster correctly [source]. This assumes your primary rails app is in /var/www/myrailsapp. Modify the below line according to your setup.

sudo mongrel_rails cluster::configure -e production \ -p 8000 -N 3 -c /var/www/myrailsapp -a 127.0.0.1 \ --user www-data --group www-data

Now let's create a symlink to that file from within /etc where all our configs live:

sudo mkdir /etc/mongrel_cluster
cd /etc/mongrel_cluster/
sudo ln -s /var/www/myrailsapp/config/mongrel_cluster.yml

You can download a sample mongrel_cluster file HERE. Regardless, I think it's a good idea to download it and compare it to what the above command produced.

Step 10: We're *almost* done. Next step is to configure Nginx. Here's a sample nginx.conf file for your /etc/nginx/ folder. It's set up to handle one rails app and phpmyadmin. Adding additional servers just means more server blocks. I strongly suggest backing up your original nginx.conf file before copying this over.

The last step is to turn everything off and then turn it on again:
Mongrel (stop): sudo /etc/init.d/mongrel_cluster stop
Mongrel (start): sudo /etc/init.d/mongrel_cluster start
Nginx (stop):sudo /etc/init.d/nginx stop
Nginx (start): sudo /etc/init.d/nginx start

Bonus: Right now you're ready to go, but you should consider installing the mysql gem as well to boost performance. Do that by grabbing the headers and installing the gem.

sudo apt-get install libmysqlclient-dev
sudo gem install mysql --no-rdoc --no-ri

Troubleshooting: If your rails app fails to start:

    * Make sure your database settings are correct in your config/database.yml file. Especially look at the socket and mysql password.
    * Be sure that your rails app has the correct permissions. You can do that by running sudo chown -R www-data:www-data /var/www/railsapp This command may change depending on how you set up nginx and mongrel!
    * Check to see all the gems you need for your app are installed
    * Check to see if your app starts in development mode with a simple sudo ruby script/server. If not, check the output message
    * Always check your production log. If you don't have one, create it using sudo touch production.log and set it using sudo chmod 0666 production.log

That should be it. I always seem to miss some small detail or another so feel free to leave a comment if I overlooked or skipped a step. Happy coding!
分享到:
评论

相关推荐

    ROR安装必备所有架包

    在Ruby on Rails(ROR)开发环境中,安装和配置正确的依赖包是至关重要的。这个压缩包包含了一系列用于ROR框架的基础组件,但不包括Ruby本身。让我们深入了解一下这些包的作用和重要性。 首先,`actionpack`是Rails...

    ror中文资料

    Ruby on Rails(RoR)是一个基于Ruby编程语言的开源Web应用框架,遵循MVC(Model-View-Controller)架构模式,旨在简化Web开发过程,提高开发效率。RoR强调“约定优于配置”,提供了一套完整的工具链,使得开发者...

    ror留言板程序

    "ror留言板程序"是一个基于Ruby on Rails框架开发的简单应用,它主要用于实现用户在网站上留言和查看他人留言的功能。Ruby on Rails(简称RoR)是用Ruby语言编写的开源Web应用程序框架,遵循MVC(Model-View-...

    Windows 上搭建 ROR环境

    - **安装过程**:Ruby的安装相对简单,只需访问官方提供的下载页面,选择适合Windows系统的安装包进行下载。安装过程中,默认选项即可,如有特殊需求可自行调整。 ##### 2. 安装DevKit - **DevKit作用**:DevKit是...

    RoR选题方向—源代码

    Ruby on Rails(RoR)是一种基于Ruby语言的开源Web应用程序框架,它遵循MVC(Model-View-Controller)架构模式,旨在简化Web开发过程。在这个选题方向中,我们主要探讨的是与RoR相关的源代码分析和学习。源代码是...

    ROR环境配置

    确保在安装过程中勾选添加Ruby到系统路径选项,以便于后续命令行调用。 接下来,安装Rails框架。打开终端或命令提示符,运行`gem install rails`命令,这会安装最新版本的Rails。如果遇到权限问题,可能需要加上`...

    ubuntu 10.10系统安装及vim(ROR)开发环境完整配置

    6. **安装过程**:输入用户信息,包括用户名、密码等,然后等待安装程序完成所有步骤。 7. **首次启动**:安装完成后,拔掉安装介质,重启电脑,即可进入新安装的Ubuntu 10.10系统。 **二、Vim编辑器的安装** 1. ...

    RoR 培训课程PPT

    - **哲学思想与MVC模式**:阐述了RoR的设计哲学,强调代码简洁性与可读性,通过模型-视图-控制器(Model-View-Controller, MVC)模式实现应用程序结构的清晰划分。 - **创建第一个应用**:演示如何利用Rails提供的...

    我的ror的第一天

    标题 "我的ror的第一天" 暗示了这是一个关于Ruby on Rails(简称RoR)的初学者经验分享,RoR是基于Ruby语言的开源Web应用框架,它遵循MVC(模型-视图-控制器)架构模式,使得开发过程更加高效。 在描述中提到的...

    mysqlDriver4ror.rar

    通常,安装过程会涉及使用`gem install`命令,例如,如果要在命令行中安装mysql-2.8.1.gem,用户可能需要输入`gem install mysql-2.8.1.gem`,但具体步骤可能根据用户的操作系统和环境设置有所不同。 4. **使用...

    ROR 学习笔记系列一 Windows XP下环境安装配置(2)

    安装过程中,记得勾选添加Ruby到系统路径的选项,以便于在命令行中直接使用Ruby。 接下来,我们需要安装Ruby的包管理器Gem。Gem用于管理和安装Ruby库,包括Rails框架。在安装Ruby后,Gem通常会自动安装。你可以在...

    ror文本编辑插件

    在Rails环境中,插件通常是用于扩展或修改框架功能的代码库,它们可以很容易地通过Gemfile添加到项目中,并通过`bundle install`命令安装。 "active_scaffold"是一个常见的Rails插件,它提供了一种快速生成CRUD...

    excel lib ror ruby

    标题 "excel lib ror ruby" 暗示我们要讨论的是在Ruby on Rails(简称RoR)框架中使用库来处理Excel文件的相关知识。RoR是一个流行的开源Web开发框架,而Ruby语言本身支持与Microsoft Excel文件交互,这在数据导入...

    5890打印机 win7 64位系统 驱动及安装说明.rar

    3. **关闭防火墙和杀毒软件**:为了防止安全软件阻止驱动程序的安装,建议在安装过程中暂时禁用防火墙和杀毒软件。 4. **运行安装程序**:找到解压后的安装程序(可能是.exe文件),双击运行。按照屏幕上的提示进行...

    使用ROR编写ORACLE WEB应用

    标题“使用ROR编写ORACLE WEB应用”表明我们要探讨的是如何使用Ruby on Rails(简称ROR)框架来构建与Oracle数据库交互的Web应用程序。Ruby on Rails是一个基于Ruby语言的开源Web开发框架,它遵循MVC(Model-View-...

    计算机软件-编程源码-FOXPRO ROR WINDOWS 高级成程序设计技术.zip

    10. **程序部署与打包**:在实际应用中,源码可能还包括了程序打包和安装脚本,以便于用户安装和使用。 这个压缩包对于学习和研究FOXPRO编程,特别是在Windows环境下的高级应用,具有很高的价值。通过对这些源码的...

Global site tag (gtag.js) - Google Analytics