Created
October 28, 2012 10:28
-
-
Save jverdeyen/3968266 to your computer and use it in GitHub Desktop.
Webistano setup: ruby/nginx/mysql/unicorn on Ubuntu 12.04
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# install packages | |
sudo apt-get update | |
sudo apt-get upgrade | |
sudo apt-get install -y build-essential git-core wget curl gcc checkinstall libxml2-dev libxslt-dev sqlite3 libsqlite3-dev libcurl4-openssl-dev libreadline-dev libc6-dev libssl-dev libmysql++-dev make build-essential zlib1g-dev libicu-dev openssh-server git-core python-dev python-pip libyaml-dev sendmail mysql-server mysql-client libmysqlclient-dev | |
# install ruby from source | |
wget http://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.2-p290.tar.gz | |
tar xzfv ruby-1.9.2-p290.tar.gz | |
cd ruby-1.9.2-p290 | |
./configure | |
make | |
sudo make install | |
# install latest nginx stable | |
sudo apt-get install -y python-software-properties | |
sudo add-apt-repository ppa:nginx/stable | |
sudo apt-key adv --recv-keys --keyserver keyserver.ubuntu.com 00A6F0A3C300EE8C | |
sudo apt-get update | |
sudo apt-get install -y nginx | |
# we need bundler and rails | |
gem install bundler --no-rdoc --no-ri; | |
gem install rails --no-rdoc --no-ri; | |
# make mysql database | |
mysql -u root -p | |
create database webistrano_production; | |
exit; | |
# clone webistrano | |
# setup database file | |
# confile file | |
cd /opt/ | |
sudo git clone https://github.com/jverdeyen/webistrano.git | |
sudo chown -R `whoami`:`whoami` webistrano && cd webistrano | |
bundle install | |
bundle exec rake db:migrate RAILS_ENV=production | |
# make some files for unicorn | |
mkdir -p unicorn | |
cd unicorn | |
touch err.log out.log | |
mkdir ../tmp; cd ../tmp; mkdir -p pids | |
cd pids; touch unicorn.pid | |
# unicorn.rb -> webistrano/config | |
working_directory "/opt/webistrano" | |
pid "/opt/webistrano/tmp/pids/unicorn.pid" | |
stderr_path "/opt/webistrano/unicorn/err.log" | |
stdout_path "/opt/webistrano/unicorn/out.log" | |
listen "/tmp/unicorn.webistrano.socket" | |
worker_processes 2 | |
timeout 30 | |
# start unicorn (this well later be done better) | |
bundle exec unicorn_rails -c config/unicorn.rb -E production | |
kill -9 `cat /opt/webistrano/tmp/pids/unicorn.pid` | |
# nginx config | |
upstream webistrano { | |
server unix:/tmp/unicorn.webistrano.socket fail_timeout=0; | |
} | |
server { | |
listen 80; | |
server_name deploy.jverdeyen.be; | |
root /opt/webistrano/public; | |
access_log /var/log/nginx/webistrano_access.log; | |
error_log /var/log/nginx/webistrano_error.log; | |
location / { | |
try_files $uri $uri/index.html $uri.html @webistrano; | |
} | |
location @webistrano { | |
proxy_redirect off; | |
# you need to change this to "https", if you set "ssl" directive to "on" | |
proxy_set_header X-FORWARDED_PROTO http; | |
proxy_set_header Host deploy.domain.com:80; | |
proxy_set_header X-Real-IP $remote_addr; | |
proxy_pass http://webistrano; | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment