aboutsummaryrefslogtreecommitdiff
path: root/nginx_unicorn/README.rdoc
diff options
context:
space:
mode:
authorMiquel Sabaté <mikisabate@gmail.com>2011-11-04 20:48:16 +0100
committerMiquel Sabaté <mikisabate@gmail.com>2011-11-04 20:48:16 +0100
commit93de9728efb0e689ce413e980dae685ac0b4b9c3 (patch)
tree18bbb262eeeab567f2438d38c7f8134391a67ad8 /nginx_unicorn/README.rdoc
parent173bf566f6a82d578780fad9b14b42f20b704161 (diff)
downloaddotfiles-93de9728efb0e689ce413e980dae685ac0b4b9c3.tar.gz
dotfiles-93de9728efb0e689ce413e980dae685ac0b4b9c3.zip
Added my nginx/unicorn configuration
Diffstat (limited to 'nginx_unicorn/README.rdoc')
-rw-r--r--nginx_unicorn/README.rdoc59
1 files changed, 59 insertions, 0 deletions
diff --git a/nginx_unicorn/README.rdoc b/nginx_unicorn/README.rdoc
new file mode 100644
index 0000000..8b5af0e
--- /dev/null
+++ b/nginx_unicorn/README.rdoc
@@ -0,0 +1,59 @@
+= Nginx / Unicorn
+
+== Words of Warning
+
+I have decided to upload the configuration of my Nginx/Unicorn setup. Please
+be aware that:
+
+- I'm using Archlinux and, therefore, the directory hierarchy may change (even for other Linux distros such as Ubuntu).
+- I'll assume that your Rails app is located at /home/mssola/myapp, change it for your own needs.
+- I'm not saying that NGinx/Unicorn is the best combo ever. Be sure to understand what is NGinx and Unicorn before going any further.
+
+== Setting up NGinx
+
+My Nginx configuration may seem tricky but it's quite clean. My point is that
+you just want to have a basic configuration on your /etc/nginx/conf directory
+and then enable sites by linking more configuration (specific for each app)
+inside the /etc/nginx/sites-enabled directory (not created by default). Here
+it goes:
+
+ # Setting up the basic HTTP configuration
+ $ sudo cp -f nginx.http.conf /etc/nginx/conf/nginx.conf
+ $ sudo mkdir /etc/nginx/sites-enabled
+
+ # Copy the nginx.server.conf to your Rails application config directory.
+ # After doing this, you have to edit this file and change the root with
+ # the public path of your Rails application, in our case /home/mssola/myapp/public
+ $ cp nginx.server.conf /home/mssola/myapp/config/nginx.conf
+ $ vim /home/mssola/myapp/config/nginx.conf
+
+After going through the steps shown above, you should be able to start the
+nginx daemon successfully. If you try to access to localhost, you'll see the
+500 page, because Unicorn is not configured yet, but at least it poves that
+NGinx is properly running.
+
+== Setting up Unicorn
+
+My Unicorn configuration assumes that you want as many worker processes as
+CPU cores you have (using a linux-specific command). In order to do this and
+more, please configure the unicorn.rb file. In this file you also have to
+change the working directory (WD constant) with the path of your Rails
+application (/home/mssola/myapp in our case). After editing this file, you
+have to edit the unicorn_init.sh script and change the APP_ROOT variable
+with the path of your Rails application (/home/mssola/myapp again :) ). I
+usually place both unicorn files to the config directory of my Rails
+application. However it's a good practice to copy the script file to the
+daemons directory in order to start unicorn at startup (assuming that you
+also start the nginx daemon at startup).
+
+With this script you can start, stop, restart, upgrade,... In fact this script
+is quite similar to the example provided by the Unicorn folks.
+
+== And now what?
+
+Please be sure to understand what's going on the configurators. In order to
+fully understand it, check out the awesome documentation for the NGinx and
+Unicorn projects. Furthermore, there're more interesting unicorn configurators
+on the Unicorn repository, showing more possible scenarios and use cases.
+
+I hope this is helpful :)