`
love~ruby+rails
  • 浏览: 852119 次
  • 性别: Icon_minigender_1
  • 来自: lanzhou
社区版块
存档分类
最新评论

Installing Rails on CentOS 5

阅读更多

Note: Since this post originally went up, some of the packages have changed/updated. I’ve kept things pretty well up-to-date, but you might want to double check the latest versions and alter the bash commands accordingly. Be aware that as of this writing, the Ruby team has made 1.9.1 the latest stable and only Rails itself is deemed compatible with Ruby 1.9x. I.e., Rails passes all its own tests on 1.9.1, but most plugins, libraries, etc are likely to give you problems right now. So your best bet is to use 1.8.7 for awhile until your favorite libraries jump on board the 1.9 wagon.       –Trevor (August 17, 2009)

I recently had to roll a new VM for work in order to run Rails and Sinatra apps on Apache/Passenger . My company favors CentOS as the default distro for all our boxes, so I wasn’t able to use all the super-up-to-date packages that Ubuntu makes available, and I ended up building everything from source. For posterity and for anyone else who needs it, here’s a list of what to do and how to do it.

Dependencies

You’ll need several libraries and the MySQL server, and you can use yum to install them all at once. This set includes the gcc compiler, the gcc-c++ compiler, and the zlib development headers for Ruby. Remember: not all libraries are the same — you’re going to need to make sure that you’re compiling Ruby w/ 32 or 64-bit development headers as appropriate for your architecture.

1
2
3
4
5
6
7
8
9
10
sudo yum install httpd-devel\
  openssl-devel\
  zlib-devel\
  gcc\
  gcc-c++\
  curl-devel\
  expat-devel\
  gettext-devel\
  mysql-server\
  mysql-devel

Ruby

Next up is Ruby. We’ll install 1.8.7-p72, the latest stable as of this writing. First, we’ll make a “src” directory in /usr/local to hold everything:

1
2
3
4
5
6
7
8
sudo mkdir /usr/local/src
  cd /usr/local/src
  sudo curl -O ftp://ftp.ruby-lang.org/pub/ruby/1.8/ruby-1.8.7-p72.tar.gz
  sudo tar xzvf ruby-1.8.7-p72.tar.gz
  cd ruby-1.8.7-p72
  sudo ./configure --enable-shared --enable-pthread
  sudo make
  sudo make install

Ok now for a weird thing — you need to remake and re-install Ruby after using it to run a script that helps you make a new makefile. This is so that you can tell it where the zlib headers live:

1
2
3
4
5
cd ext/zlib
  ruby extconf.rb --with-zlib-include=/usr/include --with-zlib-lib=/usr/lib
  cd ../../
  sudo make
  sudo make install

After all that happens, you should have Ruby installed. Check and see by doing:

1
ruby --version

You should see something like:

1
ruby 1.8.7 (2008-08-11 patchlevel 72) [i686-linux]

Rubygems

Now that you have Ruby installed, Rubygems is easy — the whole thing is in Ruby so there’s nothing to build/compile.

1
2
3
4
5
cd /usr/local/src
  sudo wget http://rubyforge.org/frs/download.php/60718/rubygems-1.3.5.tgz
  sudo tar xzvf rubygems-1.3.5.tgz
  cd rubygems-1.3.5.tgz
  sudo ruby setup.rb

Rails, Passenger, MySQL and Sinatra

Now that Ruby and Rubygems are installed, you can install Rails, Passenger, and Sinatra as gems:

1
sudo gem install rails passenger sinatra

That will take awhile, as there’s a ton of documentation to build for Rails, and Passenger has to compile some native extensions.

Once that’s done, finish the Passenger installation with their nifty installer tool:

1
sudo passenger-install-apache2-module

Follow the provided instructions at the end of the installer for adding lines to httpd.conf:

1
2
3
LoadModule passenger_module /usr/local/lib/ruby/gems/1.8/gems/passenger-2.0.6/ext/apache2/mod_passenger.so
PassengerRoot /usr/local/lib/ruby/gems/1.8/gems/passenger-2.0.6
PassengerRuby /usr/local/bin/ruby

After that, install the MySQL gem, making sure to specify where the config is:

1
sudo gem install mysql -- --with-mysql-config=/usr/bin/mysql_config

Disabling SEL inux

The RedHat family of distros (RHEL, CentOS, Fedora) come with SEL inux enabled by default. If you want to learn how to make it work with Passenger, you can try this tip from the Passenger user’s guide. I just turned it off because the box is only going to be used for these apps, and SEL inux seems like overkill. Here’s how to shut it down:

First, disable it temporarily:

1
sudo echo 0 >/selinux/enforce

That’s not a permanent fix though, because the next time the server boots, it’ll be turned back on again. You need to edit the config file and turn it off. Open it with your favorite editor and change one line. You need to be root or running as sudo to edit this file, and I prefer Vim when on remote servers, so it’s:

1
sudo vim /etc/sysconfig/selinux

Change this:

1
SELINUX=enforcing

to this:

1
SELINUX=disabled

Restart Apache

You should be able to restart Apache now and have Passenger come up no problem. There are several ways to restart Apache, but I like to use the service way to keep it simple:

1
sudo /sbin/service httpd restart

Optional: Installing Git

For SCM, there are a lot of reasons why I like Git better than Subversion. It’s got a bit of a learning curve, but once you go Git, you never go back.

1
2
3
4
5
6
cd /usr/local/src
curl -O http://www.kernel.org/pub/software/scm/git/git-1.6.0.4.tar.gz
tar zxf git-1.6.0.4.tar.gz
cd git-1.6.0.4.tar.gz
sudo make all
sudo make install

And the man pages:

1
2
3
4
cd /usr/local/src
curl -O http://www.kernel.org/pub/software/scm/git/git-manpages-1.6.0.4.tar.gz
cd /usr/local/share/man
tar -zxf /usr/local/src/git-manpages-1.6.0.4.tar.gz

Now you should have Git installed and ready. Prove it:

1
git --version

You should see something like:

1
git version 1.6.0.4

And that’s it — you now have a full Ruby stack ready to go on CentOS 5. Much of this tutorial was adapted from the awesome Hivelogic post on installing the stack on OS X Leopard.

分享到:
评论

相关推荐

    Beginning Ruby on Rails

    Ruby on Rails is the revolutionary online programming tool that makes creating functional e-commerce web sites faster and easier than ever. With the intuitive, straightforward nature of Ruby and the ...

    Installing RAC on AIX

    本篇将基于提供的文档摘要,深入解析安装Oracle RAC on AIX的关键步骤与注意事项,为读者提供一份详尽的操作指南。 ### 安装准备阶段 #### 1. 下载并解压安装介质 首先,需要从Oracle官方网站的edelivery服务下载...

    Agile Web Development with Rails Final

    - Installing Rails on Windows requires setting up Ruby, installing gems like `bundler`, and configuring the environment. Developers often use tools like RubyInstaller and DevKit for Windows. 2. **...

    CentOS 7 Server Deployment Cookbook

    Starting with installing CentOS, this book will walk you through the networking aspects of CentOS. You will then learn how to manage users and their permissions, software installs, disks, filesystems...

    Microsoft Windows 2000 Scripting Guide - Installing Software on a Remote Computer

    Microsoft Windows 2000 Scripting Guide - Installing Software on a Remote Computer

    Requirements For Installing Oracle10gR2 On RHEL 5&OEL 5 (x86_64)

    ### 安装Oracle 10g R2在RHEL 5 & OEL 5 (x86_64)上的需求 #### 概述 本文档详细介绍了在Red Hat Enterprise Linux(RHEL)5和Oracle Enterprise Linux(OEL)5(x86_64架构)上安装Oracle 10g Release 2数据库的...

    ruby安装升级及命令自行编译安装非APTGET方式安装升级的办法

    执行命令`gem install rails -y`即可一键安装Rails及其所有依赖包。例如: ```bash gem install rails -y ``` 安装完成后,可以使用`gem list`命令查看已安装的所有gem包。 通过上述步骤,不仅能够实现Ruby的定制...

    ruby on rails安装环境.txt

    标题与描述均提到了“ruby on rails安装环境”,这表明文档主要关注的是如何在特定的环境中设置Ruby on Rails。Ruby on Rails(常简称为Rails)是一种用于开发Web应用程序的开源框架,采用Ruby语言编写,遵循MVC...

    Installing Your Driver on Windows Millennium

    Installing Your Driver on Windows Millennium INF File Guide

    \Installing RAC on AIX 001.pdf

    根据提供的文档信息,本文将详细解析安装 Oracle RAC (Real Application Clusters) 在 AIX 操作系统上的步骤、注意事项及关键技术点。 ### 安装前准备 #### 下载安装介质与补丁集 ... - 示例文件包括:`B24442-01_1...

    Installing MIUI on Meizu MX2

    在IT领域,将一款设备刷入不同的操作系统或定制ROM是一种常见的技术操作,它允许用户根据个人喜好和需求自定义手机的界面与功能。本篇内容将深入解析如何在魅族MX2上安装MIUI系统,这是一项对于Android发烧友而言极...

    installing samba on ubuntu

    面是我在Ubuntu6.06 LTS 下源码编译安装samba主要安装过程,本人第一次用Ubuntu,刚装上去时候,没有gcc编译环境。郁闷了半天。找出这一过程发了不少的时间。可能还有些不妥,不过我经过这样的安装达到了向windows共享...

    anaconda安装 - Installing Anaconda on Ubuntu

    5. **等待安装完成**:安装过程可能需要几分钟时间,请耐心等待直至安装完成。 #### 六、验证安装结果 为了确保安装成功,可以在终端中运行以下命令检查Anaconda的版本信息: ``` conda --version ``` 如果安装...

    Installing Activ Test on Your PC

    ### 安装Activ Test软件至个人电脑的知识点详解 #### 一、背景介绍 随着信息技术的发展,越来越多的专业技能认证考试采用计算机化的方式进行。其中,ECDL(欧洲计算机驾驶执照)作为一项广泛认可的计算机操作技能...

    CentOS5.3 操作系统应用打包

    cat install.log | grep Installing | sed 's/Installing//g' > /home/packages.list ``` #### 五、完整性检查与打包 1. **完整性检查**: - 完成所有文件和 RPM 包的复制后,需确保 `/home/OS/CentOS` 目录下的...

    MySQL V5.5帮助文档

    2.4.1. General Notes on Installing MySQL on Mac OS X 2.4.2. Installing MySQL on Mac OS X Using Native Packages 2.4.3. Installing the MySQL Startup Item 2.4.4. Installing and Using the MySQL Preference...

    Docker Linux Centos6.5离线安装

    1、已安装的linux (以centos7为例) 2、离线安装包: ①、docker-engine-1.7.1-1.el7.centos.x86_64.rpm(可从以下链接下载http://www.oschina.net/news/64267/docker-1-7-1-final,centos7对应下载链接: ...

Global site tag (gtag.js) - Google Analytics