Skip to content

Instantly share code, notes, and snippets.

@dannguyen
Last active November 27, 2023 15:43
Show Gist options
  • Star 7 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save dannguyen/5415628 to your computer and use it in GitHub Desktop.
Save dannguyen/5415628 to your computer and use it in GitHub Desktop.
Setting up Ruby 1.9.3 stable, RVM, nginx, passenger on Amazon Linux AMI (CentOS)

Ruby 1.9.3 stable, RVM, nginx, passenger on Amazon Linux AMI (CentOS, 03-2013)

This combines the instructions on a few different tutorials:

Loadout:

  • Linux: Amazon Linux AMI 2013.03, CentOS
  • Ruby: 1.9.3p392 (2013-02-22 revision 39386) [x86_64-linux] in ~/.rvm/rubies/ruby-1.9.3-p392/bin/ruby
  • RVM: 1.19.5 in ~/.rvm/bin/rvm
  • Rubygems: 1.8.25 in ~/.rvm/rubies/ruby-1.9.3-p392/bin/gem
  • Passenger: 3.0.19 in ~/.rvm/gems/ruby-1.9.3-p392/bin/passenger
  • nginx: 1.2.6 in /opt/nginx/sbin/nginx

Basic setup

Install some dev utilities

sudo yum update -y
sudo yum groupinstall -y  'Development Tools' 
sudo yum groupinstall -y  development-libs
sudo yum install -y  libffi-devel
sudo yum install -y  libyaml-devel 

sudo yum install -y gcc-c++ patch readline readline-devel zlib zlib-devel openssl-devel libxml2-devel libxslt-devel libcurl-devel make bzip2 autoconf automake libtool bison iconv-devel

Install RVM

Note: RVM and its rubies are installed as the current user and not root

curl -L get.rvm.io | bash -s stable
source ~/.rvm/scripts/rvm

Install Ruby and Ruby gems

rvm install 1.9.3 
rvm rubygems latest
rvm use --default 1.9.3
gem install bundler

Setting up nginx

Instructions from here, even though it applies to Ubuntu http://codebyzack.com/2012/08/18/setting-up-passenger-with-rvm-on-ubuntu/

rvmsudo passenger-install-nginx-module

Setting up nginx centos

Using a config template originally outlined at SliceHost, we point it to where nginx is installed in this particular set up. See the modified script at my gist here: https://gist.github.com/dannguyen/5415991

sudo nano /etc/init.d/nginx

# Make script executable
sudo chmod +x /etc/init.d/nginx

sudo /sbin/chkconfig nginx on

# sanity check
sudo /sbin/chkconfig --list nginx

# should output:
#	nginx           0:off   1:off   2:on    3:on    4:on    5:on    6:off

Running nginx

Reboot the instance

These commands should work:

sudo /etc/init.d/nginx start
sudo /etc/init.d/nginx stop
sudo /etc/init.d/nginx restart
sudo /etc/init.d/nginx reload
sudo /etc/init.d/nginx status
sudo /etc/init.d/nginx configtest
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment