Skip to content

Instantly share code, notes, and snippets.

@stevenyap
Created November 21, 2013 02:04
Show Gist options
  • Save stevenyap/7574900 to your computer and use it in GitHub Desktop.
Save stevenyap/7574900 to your computer and use it in GitHub Desktop.
Server Setup for Rails: Guide to installing Apache, Passenger, RVM and Rails

This guide setup Apache2/Passenger/Ruby/Rails on a CentOS 6.4 LiveCD.
You can test it yourself using VirtualBox to run all the scripts - read VirtualBox.md for more info.

# install the necessary libraries
yum clean all
yum -y update
yum -y install curl-devel git sqlite-devel libxml2-devel
yum -y install libxml2 libxml2-devel libxslt libxslt-devel
yum -y install nodejs # If this does not work, do it again after you installed RVM

# install RVM
curl -L https://get.rvm.io | bash -s stable
source /etc/profile.d/rvm.sh
rvm requirements --autolibs=enable

# Install Ruby
rvm install 2.0.0
rvm --default use 2.0.0

# Install bundler
gem install bundler

# Install Rails gem
gem install rails --version 4.0.0 --no-ri --no-rdoc

# You can verify rails successful installation
# You should install all the gems necessary (in global gemset) for your app using your Gemfile
# so that later deployment will not face bundling issues
rails -v

# Install Apache
yum install httpd httpd-devel

# Allow port 80 to server webpage
iptables -I INPUT -p tcp -m tcp --dport 80 -j ACCEPT
# Or to turn off firewall completely: service iptables stop

# starts the service
chkconfig httpd on
service httpd start

# You can check if your apache is running by viewing http://localhost:8888 on your browser

# Install passenger
# There will be more requirements to install
# Just follow the instructions
gem install passenger --version 4.0.8
passenger-install-apache2-module

# There will be instructions to load your passenger module via http conf
# Put the config in a new file at /etc/httpd/conf.d/passenger.conf

# Restart the service
service httpd restart

# Install postgres
yum install postgres postgres-server postgres-contrib
service postgresql initdb
service postgresql start
# Look at Postgres.md to setup users/database

# All done! Now to deployment!!

Diagnostic

# see httpd error log
cat /var/log/httpd/error_log

# Error with yum update
yum clean all
yum check-update

# find out your server IP
ifconfig eth0 | grep inet | awk '{ print $2 }'

# If there are error loading passenger
passenger-config --root
chcon -R -h -t httpd_sys_content_t /path-to-passenger-root

# Ensure your rvm gemset use default before you do passenger-install-apache2-module
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment