Skip to content

Instantly share code, notes, and snippets.

@ErebusBat
Created August 18, 2011 20:31
Show Gist options
  • Save ErebusBat/1155107 to your computer and use it in GitHub Desktop.
Save ErebusBat/1155107 to your computer and use it in GitHub Desktop.
Ubuntu Lucid Rails Server Configs
# Sanity
sudo apt-get install vim curl
# As wheel user:
mkdir .ssh && chmod 700 .ssh
curl -L https://gist.github.com/raw/1155107/b7fb69f30e1404691441b294cf98e1a346e21664/authorized_keys >> .ssh/authorized_keys
chmod 600 .ssh/authorized_keys
# Setup root access
sudo su -
mkdir .ssh && chmod 700 .ssh
curl -L https://gist.github.com/raw/1155107/b7fb69f30e1404691441b294cf98e1a346e21664/authorized_keys >> .ssh/authorized_keys
chmod 600 .ssh/authorized_keys
# Setup SKEL remote access for new users
cd /etc/skel
mkdir .ssh && chmod 700 .ssh
cp /root/.ssh/authorized_keys .ssh/
# Use proxy for RubyGems
echo "export HTTP_PROXY=http://10.32.10.47:8000/" >> .bashrc
echo "export HTTP_PROXY=http://10.32.10.47:8000/" >> /root/.bashrc
export HTTP_PROXY=http://10.32.10.47:8000/
# rc files
curl -L https://gist.github.com/raw/1155107/35a866936e6adfc7ae2e726567f74b39851ad711/etc/gemrc >> /etc/gemrc
curl -L https://gist.github.com/raw/1155107/29fd11222ff68bfb6612965bfa28d965b6bef11b/etc/rvmrc >> /etc/rvmrc
# nginx - install
echo "deb http://ppa.launchpad.net/nginx/stable/ubuntu $(lsb_release -cs) main" > /etc/apt/sources.list.d/nginx-stable-$(lsb_release -cs).list
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys C300EE8C
apt-get update
apt-get -y install nginx
curl -L https://gist.github.com/raw/1155107/97f3cddf08fcf2ccbca74f00f872f123a799683b/etc/nginx/nginx.conf > /etc/nginx/nginx.conf
# nginx - to Upstart
sudo rm /etc/init.d/nginx
for file in $(ls /etc/rc*/*nginx); do sudo rm $file; done
sudo bash -c 'curl -L https://gist.github.com/raw/802568/e210f8754abdf137027daeb4c41db8cc301b36ad/nginx.conf > /etc/init/nginx.conf'
sudo start nginx
# Install RVM/build dependancies
apt-get -y install curl git-core #build-essential zlib1g-dev libssl-dev libreadline5-dev
# Install RVM
bash < <(curl -s https://rvm.beginrescueend.com/install/rvm)
# Dependancies recommended by RVM
apt-get -y install build-essential bison openssl libreadline6 libreadline6-dev curl git-core \
zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-0 libsqlite3-dev sqlite3 libxml2-dev \
libxslt-dev autoconf libc6-dev ncurses-dev automake
# Create Application User
adduser app1 --gecos "Application User" <<END
password
password
END
usermod -aG rvm app1
id app1 #verify
cat << END
#
# >> Log out and back in to SSH (as root) , open a new shell, etc. -- something to reload your environment
# then run to complete the provisioning:
# curl -L https://gist.github.com/raw/1155107/64a41d5635d7c2fc17207b9450cba8435faabf87/scripts/01_post-rvm.sh
#
END
rvm install ruby-1.9.2
rvm use ruby-1.9.2 --default
su - app1
# Install Unicorn in the global gemset, and create a wrapper (yo yo yo in the hooouuuuuse!?)
rvm use ruby-1.9.2-p136@global
gem install unicorn --no-ri --no-rdoc
rvm wrapper ruby-1.9.2-p136 r192 unicorn
# Create Gemset for app / install Rails
#rvm gemset create app1 && rvm gemset use app1
rvm use 1.9.2@app1 --create
rvm gem install rails --no-ri --no-rdoc --version 3.0.9
# Sanity
sudo apt-get install vim curl
# As wheel user:
mkdir .ssh && chmod 700 .ssh
curl -L https://gist.github.com/raw/1155107/b7fb69f30e1404691441b294cf98e1a346e21664/authorized_keys >> .ssh/authorized_keys
chmod 600 .ssh/authorized_keys
# Setup root access
sudo su -
mkdir .ssh && chmod 700 .ssh
curl -L https://gist.github.com/raw/1155107/b7fb69f30e1404691441b294cf98e1a346e21664/authorized_keys >> .ssh/authorized_keys
chmod 600 .ssh/authorized_keys
# Setup SKEL remote access for new users
cd /etc/skel
mkdir .ssh && chmod 700 .ssh
cp /root/.ssh/authorized_keys .ssh/
# Use proxy for RubyGems
echo "export HTTP_PROXY=http://10.32.10.47:8000/" >> .bashrc
echo "export HTTP_PROXY=http://10.32.10.47:8000/" >> /root/.bashrc
export HTTP_PROXY=http://10.32.10.47:8000/
# gemrc
curl -L https://gist.github.com/raw/1155107/35a866936e6adfc7ae2e726567f74b39851ad711/etc/gemrc >> /etc/gemrc
# rvmrc
curl -L https://gist.github.com/raw/1155107/29fd11222ff68bfb6612965bfa28d965b6bef11b/etc/rvmrc >> /etc/rvmrc
echo "deb http://ppa.launchpad.net/nginx/stable/ubuntu $(lsb_release -cs) main" > /etc/apt/sources.list.d/nginx-stable-$(lsb_release -cs).list
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys C300EE8C
apt-get update
apt-get -y install nginx
curl -L https://gist.github.com/raw/1155107/97f3cddf08fcf2ccbca74f00f872f123a799683b/etc/nginx/nginx.conf > /etc/nginx/nginx.conf
Directly robbed from <script src="https://gist.github.com/802568.js?file=02_nginx_upstart.sh"></script>
# Install RVM/build dependancies
apt-get -y install curl git-core #build-essential zlib1g-dev libssl-dev libreadline5-dev
# Install RVM
bash < <(curl -s https://rvm.beginrescueend.com/install/rvm)
# Dependancies recommended by RVM
apt-get -y install build-essential bison openssl libreadline6 libreadline6-dev curl git-core \
zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-0 libsqlite3-dev sqlite3 libxml2-dev \
libxslt-dev autoconf libc6-dev ncurses-dev automake
# Create Application User
adduser app1 --gecos "Application User" <<END
password
password
END
usermod -aG rvm app1
id app1 #verify
#
# >> Log out and back in to SSH, open a new shell, etc. -- something to reload your environment
#
rvm install ruby-1.9.2
rvm use ruby-1.9.2 --default
# Create Gemset for app / install Rails
#rvm gemset create app1 && rvm gemset use app1
rvm use 1.9.2@app1 --create
rvm gem install rails --no-ri --no-rdoc --version 3.0.9
ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA0S8+uPIdo1tKkk4xHk8YpaTR2RHRCyj5EB5B5i9ZjgQtDANma5wyjnUZ23qrVlyAdkZwhsTnSmqK1YxxGQOYHzltSiYYFYB27q92Te1AUEZFleH2k/dtB/hws8l9Gnfvb6wGzQa/mPglVmmW0Xp8PFT093tmtQLqdHIkb9zDnj2sN9K/qq8JX7/PICqm8BelWC+5w1ftGcDrpZ0OWFmvwMH/TUwREf0xwf6pS/A1UxOqWTUV1paKz1v/LAOYy3JOsg+fLW5F02K3hufyC0YCPi+yj4nj09+FBNp1rkXxuYuKnQgn5uWGTNJabcJIDCHKKqRZ9Vt3qd0WCXTVVtRSAQ== [email protected]
# This will install pre-reqs and download the first script and run it
#
# MAKE SURE YOU ARE RUNNING THIS AS A WHEEL USER!
sudo apt-get install vim curl
bash -c 'curl -L https://gist.github.com/raw/1155107/5f4c9e6502271d018c84c2deaa11adc71c1be967/scripts/00_provision.sh'
echo
echo # Logging you out, MAKE SURE YOU LOGIN AS ROOT (or wheel then sudo su -)
logout
---
gem: --no-ri --no-rdoc 
#!/bin/bash
if [ $EUID -ne 0 ]; then
echo "***ERROR: This must be ran as root!"
exit
fi
# Create source file for OpsView Repositories and add keys
echo "deb http://downloads.opsera.com/opsview-community/latest/apt lucid main" > /etc/apt/sources.list.d/opsview.list
gpg --keyserver subkeys.pgp.net --recv-key 77CB2CF6
gpg --export --armor 77CB2CF6 | sudo apt-key add -
# Enable Partner Repository
sed -i 's@^# deb http://archive.canonical.com/ubuntu lucid partner@deb http://archive.canonical.com/ubuntu lucid partner@g' /etc/apt/sources.list
apt-get update
apt-get -y install opsview
description "nginx http daemon"
start on runlevel [2]
stop on runlevel [016]
console owner
exec /usr/sbin/nginx -c /etc/nginx/nginx.conf -g "daemon off;"
respawn
worker_processes 1;
user www-data www-data;
pid /tmp/nginx.pid;
error_log /tmp/nginx.error.log;
events {
worker_connections 1024;
accept_mutex off;
}
http {
include mime.types;
default_type application/octet-stream;
access_log /tmp/nginx.access.log combined;
sendfile on;
tcp_nopush on;
tcp_nodelay off;
gzip on;
gzip_http_version 1.0;
gzip_proxied any;
gzip_min_length 500;
gzip_disable "MSIE [1-6]\.";
gzip_types text/plain text/html text/xml text/css
text/comma-separated-values
text/javascript application/x-javascript
application/atom+xml;
upstream unicorn_test {
server unix:/var/www/app1/tmp/sockets/unicorn.sock fail_timeout=0;
}
server {
listen 80;
client_max_body_size 4G;
server_name _;
keepalive_timeout 5;
root /var/www/app1/public;
location / {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
if (!-f $request_filename) {
proxy_pass http://unicorn_test;
break;
}
}
error_page 500 502 503 504 /500.html;
location = /500.html {
root /var/www/app1/public;
}
}
}
export rvm_pretty_print_flag=1
export rvm_project_rvmrc=1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment