Setting up Unicorn with Nginx

时间:2023-01-23 16:41:02
gem install unicorn
or
gem 'un*n'

1 install Nginx

yum install ...

2 Configuration

vi /etc/nginx/nginx.conf

It's adviced to run as a seperae user.

Here is a example:

sudo user add -s /sbin/nologin -r nginx
sudo usermod -a -G web nginx ; add nginx user into web group
sudo mkdir /var/www ;this should be the static path in nginx.conf
sudo chgrp -R web /var/www ;set this path to group "web"
sudo chmod -R 775 /var/www ;set group write permission
sudo usermod -a -G web yourusername; Add your current use to be able to modify the contents of this part

3 Install unicorn

gem install unicorn
or
gem 'unicron'

install unicorn file

curl -o config/unicorn.rb https://raw.github.com/defunkt/unicorn/master/examples/unicorn.conf.rb

4. The very basic of the unicorn

APP_PATH = "/var/www/unicorn"
working_directory APP_PATH stderr_path APP_PATH + "/log/unicorn.stderr.log"
stdout_path APP_PATH + "/log/unicorn.stderr.log" pid APP_PATH + "/tmp/pid/unicorn.pid"

5 Startup unicorn

unicorn_rails -c /var/www/unicorn/config/unicorn.rb -D