This combines the instructions on a few different tutorials:
- Tabula EC2 AMI quickstart - A nice illustrated How-To for a basic EC2 setup, including permissions setup. The instructions apply to a specific demo app but apply to any EC2 usage
- Code by Zack » Getting RVM set up on Amazon EC2 - How to install the latest stable version of Ruby (1.9.3p392) with RVM
- Code by Zack » Setting up Passenger with rvm on Ubuntu - Installing Passenger and using it to set up nginx. The instructions at the end of Zack's guide on creating an init script apply to Ubuntu only.
- Slicehost Articles: CentOS - Adding an Nginx Init Script - Setting up the nginx init script for CentOS.
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
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
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
rvm install 1.9.3
rvm rubygems latest
rvm use --default 1.9.3
gem install bundler
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
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
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