This workshop will be retired on May 1, 2025.
Heads up! To view this whole video, sign in with your Courses Plus account or enroll in your free 7-day trial. Sign In Enroll
Start a free Courses trial
to watch this video
Next we'll show you how to install Unicorn on your server, and configure your Rails app to use Unicorn instead of Puma in production.
On your server, in your Rails app directory, add the following to your Gemfile
:
group :production do
gem 'unicorn', '~> 5.2'
end
Next, edit config/unicorn.rb
:
working_directory "/home/deploy/guestbook"
pid "/home/deploy/guestbook/tmp/pids/unicorn.pid"
stderr_path "/home/deploy/guestbook/unicorn/unicorn.log"
stdout_path "/home/deploy/guestbook/unicorn/unicorn.log"
listen "/tmp/unicorn.guestbook.sock"
worker_processes 2
timeout 30
Modify config/nginx.conf
to read:
upstream unicorn {
server unix:/tmp/unicorn.guestbook.sock fail_timeout=0;
}
server {
listen 80 default;
root /home/deploy/guestbook/public;
try_files $uri/index.html $uri @unicorn;
location @unicorn {
proxy_pass http://unicorn;
}
}
Run the following from your Rails app directory:
bundle install
mkdir unicorn
sudo service nginx restart
RAILS_ENV=production bundle exec unicorn -c config/unicorn.rb -D
At this point, if you type your server's address into your browser, you should see your app, but this time it will be running under Unicorn instead of Puma.
Related Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign upRelated Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign up
You need to sign up for Treehouse in order to download course files.
Sign upYou need to sign up for Treehouse in order to set up Workspace
Sign up