GithubHelp home page GithubHelp logo

rails3-nginx-unicorn's Introduction

rails3-nginx-unicorn

enter sudo shell

sudo -s

upgrade system

apt-get update
apt-get -y upgrade
apt-get -y install python-software-properties language-pack-en curl git-core build-essential

install sqlite3 if you want to use it

apt-get -y install libsqlite3-dev

set language for system

echo "LC_ALL=en_US.utf8" >> /etc/environment

add repository

add-apt-repository -y ppa:nginx/stable
add-apt-repository -y ppa:chris-lea/node.js
apt-get update

nginx

apt-get -y install nginx

nodejs

apt-get -y install nodejs npm

reboot system

reboot

now stay in the deploy user

rbenv

curl -L https://raw.github.com/fesplugas/rbenv-installer/master/bin/rbenv-installer | bash

put lines from

wget -O - https://raw.github.com/davidebettio/rails3-nginx-unicorn/master/.bashrc

in your .bashrc before

# If not running interactively, don't do anything
[ -z "$PS1" ] && return

and reload bash

source .bashrc

install and set ruby version

rbenv bootstrap-ubuntu-12-04
rbenv install 1.9.3-p194
rbenv global 1.9.3-p194
wget -O ~/.gemrc https://raw.github.com/davidebettio/rails3-nginx-unicorn/master/.gemrc
gem install bundler --no-ri --no-rdoc
rbenv rehash

rails

gem install rails

unicorn

gem install unicorn

enter sudo shell

sudo -s

backup original nginx.conf and mime.types

mv /etc/nginx/nginx.conf /etc/nginx/nginx.conf.orig
mv /etc/nginx/mime.types /etc/nginx/mime.types.orig

get conf files for nginx

wget -O /etc/nginx/mime.types https://raw.github.com/davidebettio/rails3-nginx-unicorn/master/mime.types
wget -O /etc/nginx/nginx.conf https://raw.github.com/davidebettio/rails3-nginx-unicorn/master/nginx.conf

remove default site

rm /etc/nginx/sites-enabled/default

restart nginx

service nginx restart

add ubuntu user to www-data group

usermod -a -G www-data ubuntu

create www folder

mkdir /var/www

change owner of www folder

chown ubuntu:www-data /var/www

create a test app

sudo apt-get install libsqlite3-dev
wget -O /etc/nginx/sites-available/example.com https://raw.github.com/davidebettio/rails3-nginx-unicorn/master/example.com
ln -s /etc/nginx/sites-available/example.com /etc/nginx/sites-enabled/example.com
service nginx restart

exit and return to deploy user

cd /var/www
rails new example
wget -O /var/www/example/config/unicorn.rb https://raw.github.com/davidebettio/rails3-nginx-unicorn/master/unicorn.rb
wget -O /var/www/example/config/unicorn_init.sh https://raw.github.com/davidebettio/rails3-nginx-unicorn/master/unicorn_init.sh
cd example
echo "gem 'unicorn'" >> Gemfile
echo "gem 'capistrano'" >> Gemfile
bundle
rm public/index.html


chmod +x config/unicorn_init.sh
mkdir tmp/pids
./config/unicorn_init.sh

TODO:

cd /etc/nginx wget nginx.conf

enable example site

cd /etc/nginx/sites-available wget example.com cd /etc/nginx sudo ln -s /etc/nginx/sites-available/example.com sites-enabled/example.com cd mkdir www cd www sudo apt-get install libsqlite3-dev rails new example cd example echo "gem 'unicorn'" >> Gemfile echo "gem 'capistrano'" >> Gemfile bundle

wget extra conf

sudo mv /etc/nginx/conf.d /etc/nginx/conf cd /etc/nginx/conf sudo wget https://raw.github.com/h5bp/server-configs/master/nginx/conf/cache-busting.conf sudo wget https://raw.github.com/h5bp/server-configs/master/nginx/conf/cross-domain-ajax.conf sudo wget https://raw.github.com/h5bp/server-configs/master/nginx/conf/cross-domain-fonts.conf sudo wget https://raw.github.com/h5bp/server-configs/master/nginx/conf/expires.conf sudo wget https://raw.github.com/h5bp/server-configs/master/nginx/conf/h5bp.conf sudo wget https://raw.github.com/h5bp/server-configs/master/nginx/conf/no-transform.conf sudo wget https://raw.github.com/h5bp/server-configs/master/nginx/conf/protect-system-files.conf sudo wget https://raw.github.com/h5bp/server-configs/master/nginx/conf/x-ua-compatible.conf

remove default nginx site

sudo rm /etc/nginx/sites-enabled/default

restart nginx

sudo service nginx restart

rails3-nginx-unicorn's People

Contributors

davidebettio avatar

Watchers

David Willoughby avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.