Skip to content

Instantly share code, notes, and snippets.

View imarcelolz's full-sized avatar
😃

Marcelo Zaniolo imarcelolz

😃
View GitHub Profile
@imarcelolz
imarcelolz / unicorn.rake
Created August 2, 2013 14:35
Unicorn rake tasks
namespace :unicorn do
desc "Start unicorn"
task(:start) {
config = "#{Rails.root}/config/unicorn.rb"
sh "cd #{Rails.root}; bundle exec unicorn_rails --daemonize --config-file #{config}"
p "Unicorn started"
}
desc "Stop unicorn"
server {
# we want to listen on port 80 on all IPs on our system - both IPv4 and IPv6
listen [::]:80;
# our primary server name is the first, aliases simply come after it. you can also include wildcards like *.example.com
server_name blog.chrismeller.com new.chrismeller.com;
# where are our site files stored?
root /media/www/public_html/blog.chrismeller.com/public;
# define our access and error logs for this vhost
server {
# the same as for non-ssl, except we indicate that when listening on port
# 443, it should use ssl
listen [::]:443 ssl;
server_name blog.chrismeller.com new.chrismeller.com;
# turn ssl on, and specify the certificate (chain) and key file
ssl on;
ssl_certificate ssl/chrismeller.com.2012.pem;
ssl_certificate_key ssl/chrismeller.com.2012.key;
client_max_body_size 32m;
@imarcelolz
imarcelolz / ssl.conf
Last active December 20, 2015 18:19 — forked from chrismeller/gist:4748033
# we want to enable ssl session resumption to avoid
# having to start the handshake from scratch each page load
# so first we enable a shared cache, named SSL (creative!) that is 10mb large
ssl_session_cache shared:SSL:10m;
# save things in the cache for 3 minutes
# if you're not making a request at least every 3 minutes, this isn't going
# to accomplish anything anyway
ssl_session_timeout 3m;
# most people include something like this. don't.
# check your default nginx.conf, it's already covered in a much better way.
#gzip_disable "MSIE [1-6]\.(?!.*SV1)";
# compress proxied requests too.
# it doesn't actually matter if the request is proxied, we still want it compressed.
gzip_proxied any;
# a pretty comprehensive list of content mime types that we want to compress
# there's a lot of repetition here because different applications might use different
expires max;
charset utf-8;
upstream php {
server unix:/var/run/php5-fpm.socket;
}
# make sure index.php is first in all our vhosts
index index.php index.html index.htm;
[www]
; at any time, there can be no more than 5 child processes
; if you know how much memory each process consumes regularly
; and how much free memory you have on your system, this is how
; you set a "hard limit" on the amount of memory php-fpm will be able to consume
pm.max_children = 5
; when php-fpm first starts, how many processes should
; it immediately generate to handle requests?
; when you restart php-fpm, there may be an influx of requests.