This repository has been archived by the owner on Sep 7, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
How to set up and deploy a production server
Patrick Stoica edited this page Nov 14, 2013
·
1 revision
Capistrano is used to deploy the application. We're using nginx, Unicorn, and Ruby 2 (through rvm), and MySQL in production with a node.js runtime for uglifier. The server was setup with the tips outlined in this article with some modifications. To set up the server:
- Create a user for deployment (with sudo privileges).
- Update packages and install curl:
sudo apt-get update
sudo apt-get install curl
- Install rvm (Ruby Version Manager):
curl -L get.rvm.io | bash -s stable
- Load RVM and install dependencies
source ~/.rvm/scripts/rvm
rvm requirements
- Install Ruby 2.0
rvm install 2.0.0
rvm use 2.0.0 --default
- Install rubygems, rails, and mysql2.
rvm rubygems current
gem install rails --no-ri --no-rdoc
sudo apt-get install libmysqlclient-dev
gem install mysql2
- Install git-core:
sudo apt-get install git-core
- Install bundler:
gem install bundler
- Setup nginx
sudo apt-get install nginx
nginx -h
cat /etc/init.d/nginx
/etc/init.d/nginx -h
sudo service nginx start
cd /etc/nginx
The application has everything it needs in terms of unicorn and nginx configurations:
-
config/nginx.conf
: nginx configuration which redirects requests to the Unicorn server. config/unicorn.rb
- 'config/unicorn_init.sh': establishes commands for controlling Unicorn.
Generate an SSH key to use with the server. You can follow this guide. Add it to the server with the corresponding username.
cap deploy:setup
cap deploy:setup_config
cap deploy:cold
sudo rm /etc/nginx/sites-enabled/default
sudo service nginx restart
sudo update-rc.d -f unicorn_projectname defaults
After pushing your commits, simply run:
cap deploy
To update configuration files (database.yml
, application.yml
, ldap.yml
):
cap deploy:setup_config