Skip to content

Instantly share code, notes, and snippets.

@chyld
Created August 10, 2012 19:49
Show Gist options
  • Save chyld/3317324 to your computer and use it in GitHub Desktop.
Save chyld/3317324 to your computer and use it in GitHub Desktop.
New rails server for chyld.net
# new rails server for chyld.net
# amazon allows you to create external EBS volumes that automatically attach to your EC2 instance
# 8 GB root device for application & 50 GB EBS for database
ssh -i ~/Documents/ssh-keys/chyldnet.pem [email protected]
# Welcome to Ubuntu 12.04 LTS (GNU/Linux 3.2.0-25-virtual x86_64)
# mounts /dev/sdf to /dev/xvdf (ubuntu internal name is different)
sudo mkfs.ext4 /dev/xvdf
# make a directory to mount on
sudo mkdir /data
# edit fstab file
sudo vi /etc/fstab
/dev/xvdf /data auto noatime 0 0
# manually mount
sudo mount -a
# check for successful mount
df -H
# /dev/xvdf 54G 927M 50G 2% /data
# pre rails install
sudo apt-get update
sudo apt-get install build-essential
sudo apt-get install zlib1g-dev
sudo apt-get install tcl8.5
sudo apt-get install libreadline6 libreadline6-dev
sudo apt-get install libssl-dev
sudo apt-get install libcurl4-openssl-dev
sudo apt-get install git
# install rails
curl -L https://get.rvm.io | bash -s stable --rails
# needed for sqlite3
sudo apt-get install libsqlite3-dev
# install node.js
sudo apt-get install python-software-properties
sudo add-apt-repository ppa:chris-lea/node.js
sudo apt-get update
sudo apt-get install nodejs npm
# install passenger and apache
gem install passenger
sudo apt-get install apache2-mpm-prefork
sudo apt-get install apache2-prefork-dev
passenger-install-apache2-module
# edit apache2.conf file (put at bottom)
sudo vi /etc/apache2/apache2.conf
LoadModule passenger_module /home/ubuntu/.rvm/gems/ruby-1.9.3-p194/gems/passenger-3.0.15/ext/apache2/mod_passenger.so
PassengerRoot /home/ubuntu/.rvm/gems/ruby-1.9.3-p194/gems/passenger-3.0.15
PassengerRuby /home/ubuntu/.rvm/wrappers/ruby-1.9.3-p194/ruby
# edit virtual host file
sudo vi /etc/apache2/sites-available/default
<VirtualHost *:80>
ServerAdmin [email protected]
# Possible values include: debug, info, notice, warn, error, crit, alert, emerg.
LogLevel info
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
ServerName chyld.net
RailsEnv production
DocumentRoot /data/rails/chyld/public
<Directory /data/rails/chyld/public>
AllowOverride all
Options -MultiViews
</Directory>
</VirtualHost>
# make rails directory
cd /data
sudo mkdir rails
sudo chown ubuntu:ubuntu rails
cd rails
rails new chyld
# start apache
sudo service apache2 restart
# install postgresql
sudo apt-get install postgresql-9.1
# change data directory
sudo vi /etc/postgresql/9.1/main/postgresql.conf
data_directory = '/data/postgres/db' # use data in another directory
# create data directory
cd /data
mkdir postgres
sudo chown postgres:postgres postgres
sudo su - postgres
cd /data/postgres
mkdir db
# drop old cluster and create a new one
sudo su - postgres
pg_dropcluster --stop 9.1 main
rm -rf /var/lib/postgresql/9.1/main
pg_createcluster 9.1 main -l /data/postgres/log/postgres.log -d /data/postgres/db --start
# setting up a user
sudo su - postgres
createuser -P dbuser
exit
# setup login permissions
sudo vi /etc/postgresql/9.1/main/pg_hba.conf
local all all peer
# - to -
local all all md5
# restart db
sudo service postgresql restart
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment