Nginx vs Unicorn
2015/03/29 KhanhPham
Step1: Install nginx
1. Install nginx
sudo apt-get update
sudo apt-get install nginx
2. Display your ip
sudo service nginx start
Step1: Install nginx
3. Start nginx
sudo service nginx start
4. Create new config nginx for your app
sudo vim /etc/nginx/conf.d/sieunhac.conf
Step1: Install nginx
This is file sample config nginx
upstream sieunhac {
server unix:/tmp/sieunhac.sock fail_timeout=0;
}
server {
listen 80;
server_name 192.168.1.2;
root /home/khanhpn/Project/sieunhac_v1/public;
try_files $uri/index.html $uri @sieunhac;
location @sieunhac {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_pass http://sieunhac;
}
error_log /var/log/nginx/sieunhac_error.log;
access_log /var/log/nginx/sieunhac_access.log;
error_page 500 502 503 504 /500.html;
Step1: Install nginx
5. If you have nginx, you can remove all via this
command bellow:
sudo apt-get remove nginx nginx-full nginx-light nginx-naxsi nginx-common
Step2: Install unicorn
1. Go to your app, and add gem ‘unicorn’
2. Create new file config/unicorn.rb with
content as bellow:
Step2: Install unicorn
app_name = 'sieunhac'
root = "/home/khanhpn/Project/sieunhac_v1"
working_directory root
pid_file = "#{root}/tmp/pids/#{app_name}.pid"
stderr_path "#{root}/log/#{app_name}_stderr.log"
stdout_path "#{root}/log/#{app_name}_stdout.log"
old_pid = pid_file + '.oldbin'
pid pid_file
listen "/tmp/#{app_name}.sock", backlog: 64
listen(3000, backlog: 64) if ENV['RAILS_ENV'] == 'development'
worker_processes ENV['RAILS_ENV'] == "production" ? 5 : 3
preload_app true
timeout 60
before_fork do |server, worker|
if defined?(ActiveRecord::Base)
ActiveRecord::Base.connection.disconnect!
end
if File.exists?(old_pid) && server.pid != old_pid
begin
Process.kill("QUIT", File.read(old_pid).to_i)
rescue Errno::ENOENT, Errno::ESRCH
Step2: Install unicorn
3. Start unicorn via this command
bundle exec unicorn -E development -c
config/unicorn.rb
Step2: Install unicorn
4. Start unicorn via service of ubuntu
Create new file vim /etc/init.d/unicorn_sieunhac
Step2: Install unicorn
# Provides: unicorn
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Manage unicorn server
# Description: Start, stop, restart unicorn server for a specific application.
### END INIT INFO
set -e
# Feel free to change any of the following variables for your app:
TIMEOUT=${TIMEOUT-60}
APP_ROOT=/home/khanhpn/Project/sieunhac_v1
PID=$APP_ROOT/tmp/pids/sieunhac.pid
CMD="cd $APP_ROOT; bundle exec unicorn -D -c $APP_ROOT/config/unicorn.rb -E development"
AS_USER=khanhpn
set -u
OLD_PIN="$PID.oldbin"
sig () {
Step2: Install unicorn
5. Start unicorn via this command
sudo /etc/init.d/unicorn_sieunhac start

More Related Content

ODP
Elastic search
ODT
Squid file
PDF
Config websocket on apache
PDF
Aeon mike guide transparent ssl filtering
PDF
Aeon mike guide transparent ssl filtering (1)
PDF
PPS
Squidinstallation
PDF
Rdo mitaka
Elastic search
Squid file
Config websocket on apache
Aeon mike guide transparent ssl filtering
Aeon mike guide transparent ssl filtering (1)
Squidinstallation
Rdo mitaka

What's hot (18)

PDF
PPT
How To Deploy A Cloud Based Webserver in 5 minutes - LAMP
TXT
Commands
PDF
Step by-step installation of a secure linux web dns- and mail server
PDF
How To Install and Configure Apache SSL on CentOS 7
TXT
Intalacion de owncloud
PDF
How to Install MariaDB Server or MySQL Server on CentOS 7
PPTX
nginx + uwsgi emperor + bottle
PDF
Ajenti control panel
PDF
Jones_Lamp_Tutorial
PPTX
Installing hive on ubuntu 16
PPTX
Installing hadoop on ubuntu 16
PPTX
Simple webapps with nginx, uwsgi emperor and bottle
PDF
How to contribute Apache CloudStack
PPTX
Installing apache sqoop
PDF
Services: Web Webmail Proxy
PDF
bivou.ac
PDF
VPNaaS neutron
How To Deploy A Cloud Based Webserver in 5 minutes - LAMP
Commands
Step by-step installation of a secure linux web dns- and mail server
How To Install and Configure Apache SSL on CentOS 7
Intalacion de owncloud
How to Install MariaDB Server or MySQL Server on CentOS 7
nginx + uwsgi emperor + bottle
Ajenti control panel
Jones_Lamp_Tutorial
Installing hive on ubuntu 16
Installing hadoop on ubuntu 16
Simple webapps with nginx, uwsgi emperor and bottle
How to contribute Apache CloudStack
Installing apache sqoop
Services: Web Webmail Proxy
bivou.ac
VPNaaS neutron
Ad

Viewers also liked (6)

PDF
Tìm đường đi xe buýt trong TPHCM bằng Google Map
PDF
Subprogram
PDF
Untitled Presentation
PDF
Nhập môn công tác kỹ sư
PDF
Control structure
PPTX
Bus tracking application in Android
Tìm đường đi xe buýt trong TPHCM bằng Google Map
Subprogram
Untitled Presentation
Nhập môn công tác kỹ sư
Control structure
Bus tracking application in Android
Ad

Similar to How to install nginx vs unicorn (20)

PDF
ITB2019 NGINX Overview and Technical Aspects - Kevin Jones
PPTX
Nginx-deploy on linux server with 80 and 442
PDF
How to Set Up Nginx Server Blocks on Ubuntu 2404.pdf
PDF
Install nginx on ubuntu 21.04 server
PPTX
Nginx [engine x] and you (and WordPress)
PDF
Multiple django applications on a single server with nginx
PPT
Real World Rails Deployment
PDF
NGINX ADC: Basics and Best Practices – EMEA
PPTX
NGINX: Basics & Best Practices - EMEA Broadcast
PDF
NGINX: Basics and Best Practices EMEA
PDF
How to Get Started With NGINX
PPTX
Django Deployment-in-AWS
ODP
Introduction to Nginx
PDF
NGINX ADC: Basics and Best Practices
PPTX
Nginx A High Performance Load Balancer, Web Server & Reverse Proxy
PPTX
NGINX Installation and Tuning
DOC
Nginx 0.8.x + php 5.2.13 (fast cgi) setup web server
PPTX
NGINX: High Performance Load Balancing
PPTX
NGINX: Basics and Best Practices
PPTX
NGINX 101 - now with more Docker
ITB2019 NGINX Overview and Technical Aspects - Kevin Jones
Nginx-deploy on linux server with 80 and 442
How to Set Up Nginx Server Blocks on Ubuntu 2404.pdf
Install nginx on ubuntu 21.04 server
Nginx [engine x] and you (and WordPress)
Multiple django applications on a single server with nginx
Real World Rails Deployment
NGINX ADC: Basics and Best Practices – EMEA
NGINX: Basics & Best Practices - EMEA Broadcast
NGINX: Basics and Best Practices EMEA
How to Get Started With NGINX
Django Deployment-in-AWS
Introduction to Nginx
NGINX ADC: Basics and Best Practices
Nginx A High Performance Load Balancer, Web Server & Reverse Proxy
NGINX Installation and Tuning
Nginx 0.8.x + php 5.2.13 (fast cgi) setup web server
NGINX: High Performance Load Balancing
NGINX: Basics and Best Practices
NGINX 101 - now with more Docker

More from baran19901990 (17)

PDF
How to build a news website use CMS wordpress
PDF
Lexical
PDF
Introduction
PDF
Datatype
PDF
10 logic+programming+with+prolog
PDF
09 implementing+subprograms
PDF
08 subprograms
PDF
07 control+structures
PDF
How to install git on ubuntu
DOC
Ruby notification
DOC
Rails notification
DOC
Linux notification
PDF
PDF
DOCX
Báo cáo mô hình quản lý khách sạn
PPTX
MDA Framework
How to build a news website use CMS wordpress
Lexical
Introduction
Datatype
10 logic+programming+with+prolog
09 implementing+subprograms
08 subprograms
07 control+structures
How to install git on ubuntu
Ruby notification
Rails notification
Linux notification
Báo cáo mô hình quản lý khách sạn
MDA Framework

Recently uploaded (20)

PPTX
LiFi Technology an effective way of Communication
PDF
Toolkit of the MultiCloud DevOps Professional.pdf
PPTX
Going_to_Greece presentation Greek mythology
PDF
How Technology Shapes Our Information Age
PPTX
DAY 1 - Introduction to Git.pptxttttttttttttttttttttttttttttt
PDF
JuanConnect E-Wallet Guide for new users.pdf
PDF
Testing & QA Checklist for Magento to Shopify Migration Success.pdf
PPTX
BIOS-and-VDU-The-Foundations-of-Computer-Startup-and-Display (1).pptx
DOCX
MLS 113 Medical Parasitology (LECTURE).docx
PPTX
Chapter 1_Overview hhhhhhhhhhhhhhhhhhhhhhhhhh
PDF
Technical SEO Explained: How To Make Your Website Search-Friendly
PDF
Tailieuhoctiengnhat.com__(N5) 1021 từ vựng tổng hợp.pdf
PDF
Curriculum Vitae: McGee Steve Resume.pdf
PPTX
IOT LECTURE IOT LECTURE IOT LECTURE IOT LECTURE
PPTX
北安普顿大学毕业证UoN成绩单GPA修改北安普顿大学i20学历认证文凭
PPTX
Dating App Development Cost: Factors, Features & Estimates
PDF
ilide.info-huawei-odn-solution-introduction-pdf-pr_a17152ead66ea2617ffbd01e8c...
PDF
Information Technology practical assignment
PPT
chapter 5: system unit computing essentials
PPTX
WEEK 15.pptx WEEK 15.pptx WEEK 15.pptx WEEK 15.pptx
LiFi Technology an effective way of Communication
Toolkit of the MultiCloud DevOps Professional.pdf
Going_to_Greece presentation Greek mythology
How Technology Shapes Our Information Age
DAY 1 - Introduction to Git.pptxttttttttttttttttttttttttttttt
JuanConnect E-Wallet Guide for new users.pdf
Testing & QA Checklist for Magento to Shopify Migration Success.pdf
BIOS-and-VDU-The-Foundations-of-Computer-Startup-and-Display (1).pptx
MLS 113 Medical Parasitology (LECTURE).docx
Chapter 1_Overview hhhhhhhhhhhhhhhhhhhhhhhhhh
Technical SEO Explained: How To Make Your Website Search-Friendly
Tailieuhoctiengnhat.com__(N5) 1021 từ vựng tổng hợp.pdf
Curriculum Vitae: McGee Steve Resume.pdf
IOT LECTURE IOT LECTURE IOT LECTURE IOT LECTURE
北安普顿大学毕业证UoN成绩单GPA修改北安普顿大学i20学历认证文凭
Dating App Development Cost: Factors, Features & Estimates
ilide.info-huawei-odn-solution-introduction-pdf-pr_a17152ead66ea2617ffbd01e8c...
Information Technology practical assignment
chapter 5: system unit computing essentials
WEEK 15.pptx WEEK 15.pptx WEEK 15.pptx WEEK 15.pptx

How to install nginx vs unicorn

  • 2. Step1: Install nginx 1. Install nginx sudo apt-get update sudo apt-get install nginx 2. Display your ip sudo service nginx start
  • 3. Step1: Install nginx 3. Start nginx sudo service nginx start 4. Create new config nginx for your app sudo vim /etc/nginx/conf.d/sieunhac.conf
  • 4. Step1: Install nginx This is file sample config nginx upstream sieunhac { server unix:/tmp/sieunhac.sock fail_timeout=0; } server { listen 80; server_name 192.168.1.2; root /home/khanhpn/Project/sieunhac_v1/public; try_files $uri/index.html $uri @sieunhac; location @sieunhac { proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $http_host; proxy_redirect off; proxy_pass http://sieunhac; } error_log /var/log/nginx/sieunhac_error.log; access_log /var/log/nginx/sieunhac_access.log; error_page 500 502 503 504 /500.html;
  • 5. Step1: Install nginx 5. If you have nginx, you can remove all via this command bellow: sudo apt-get remove nginx nginx-full nginx-light nginx-naxsi nginx-common
  • 6. Step2: Install unicorn 1. Go to your app, and add gem ‘unicorn’ 2. Create new file config/unicorn.rb with content as bellow:
  • 7. Step2: Install unicorn app_name = 'sieunhac' root = "/home/khanhpn/Project/sieunhac_v1" working_directory root pid_file = "#{root}/tmp/pids/#{app_name}.pid" stderr_path "#{root}/log/#{app_name}_stderr.log" stdout_path "#{root}/log/#{app_name}_stdout.log" old_pid = pid_file + '.oldbin' pid pid_file listen "/tmp/#{app_name}.sock", backlog: 64 listen(3000, backlog: 64) if ENV['RAILS_ENV'] == 'development' worker_processes ENV['RAILS_ENV'] == "production" ? 5 : 3 preload_app true timeout 60 before_fork do |server, worker| if defined?(ActiveRecord::Base) ActiveRecord::Base.connection.disconnect! end if File.exists?(old_pid) && server.pid != old_pid begin Process.kill("QUIT", File.read(old_pid).to_i) rescue Errno::ENOENT, Errno::ESRCH
  • 8. Step2: Install unicorn 3. Start unicorn via this command bundle exec unicorn -E development -c config/unicorn.rb
  • 9. Step2: Install unicorn 4. Start unicorn via service of ubuntu Create new file vim /etc/init.d/unicorn_sieunhac
  • 10. Step2: Install unicorn # Provides: unicorn # Required-Start: $remote_fs $syslog # Required-Stop: $remote_fs $syslog # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: Manage unicorn server # Description: Start, stop, restart unicorn server for a specific application. ### END INIT INFO set -e # Feel free to change any of the following variables for your app: TIMEOUT=${TIMEOUT-60} APP_ROOT=/home/khanhpn/Project/sieunhac_v1 PID=$APP_ROOT/tmp/pids/sieunhac.pid CMD="cd $APP_ROOT; bundle exec unicorn -D -c $APP_ROOT/config/unicorn.rb -E development" AS_USER=khanhpn set -u OLD_PIN="$PID.oldbin" sig () {
  • 11. Step2: Install unicorn 5. Start unicorn via this command sudo /etc/init.d/unicorn_sieunhac start