Skip to content

Instantly share code, notes, and snippets.

@iterion

iterion/nginx.conf

Created Feb 23, 2012
Embed
What would you like to do?
Basic nginx conf file
worker_processes 1;
user nginx web;
pid /tmp/nginx.pid;
error_log /tmp/nginx.error.log;
events {
worker_connections 1024;
accept_mutex off;
use epoll;
}
http {
include mime.types;
default_type application/octet-stream;
access_log /tmp/nginx.access.log combined;
sendfile on;
tcp_nopush on;
tcp_nodelay off;
gzip on;
gzip_http_version 1.0;
gzip_proxied any;
gzip_min_length 500;
gzip_disable "MSIE [1-6]\.";
gzip_types text/plain text/xml text/css
text/comma-separated-values
text/javascript application/x-javascript
application/atom+xml;
include /etc/nginx/sites-enabled/*;
}
description "nginx http daemon"
start on runlevel [2]
stop on runlevel [016]
console owner
exec /usr/local/nginx/sbin/nginx -c /etc/nginx/nginx.conf -g "daemon off;"
respawn
#!/bin/sh
#
# nginx - this script starts and stops the nginx daemin
#
# chkconfig: - 85 15
# description: Nginx is an HTTP(S) server, HTTP(S) reverse \
# proxy and IMAP/POP3 proxy server
# processname: nginx
# config: /usr/local/nginx/conf/nginx.conf
# pidfile: /usr/local/nginx/logs/nginx.pid
# Source function library.
. /etc/rc.d/init.d/functions
# Source networking configuration.
. /etc/sysconfig/network
# Check that networking is up.
[ "$NETWORKING" = "no" ] && exit 0
nginx="/usr/local/nginx/sbin/nginx"
prog=$(basename $nginx)
NGINX_CONF_FILE="/etc/nginx/nginx.conf"
lockfile=/var/lock/subsys/nginx
start() {
[ -x $nginx ] || exit 5
[ -f $NGINX_CONF_FILE ] || exit 6
echo -n $"Starting $prog: "
daemon $nginx -c $NGINX_CONF_FILE
retval=$?
echo
[ $retval -eq 0 ] && touch $lockfile
return $retval
}
stop() {
echo -n $"Stopping $prog: "
killproc $prog -QUIT
retval=$?
echo
[ $retval -eq 0 ] && rm -f $lockfile
return $retval
}
restart() {
configtest || return $?
stop
start
}
reload() {
configtest || return $?
echo -n $"Reloading $prog: "
killproc $nginx -HUP
RETVAL=$?
echo
}
force_reload() {
restart
}
configtest() {
$nginx -t -c $NGINX_CONF_FILE
}
rh_status() {
status $prog
}
rh_status_q() {
rh_status >/dev/null 2>&1
}
case "$1" in
start)
rh_status_q && exit 0
$1
;;
stop)
rh_status_q || exit 0
$1
;;
restart|configtest)
$1
;;
reload)
rh_status_q || exit 7
$1
;;
force-reload)
force_reload
;;
status)
rh_status
;;
condrestart|try-restart)
rh_status_q || exit 0
;;
*)
echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload|configtest}"
exit 2
esac
sudo apt-get update
sudo apt-get install build-essential bison openssl libreadline6 libreadline6-dev curl git-core zlib1g zlib1g-dev libssl-dev libyaml-dev libxml2-dev libxslt-dev autoconf libc6-dev libmysqlclient-dev libpcre3 libpcre3-dev libpcrecpp0 libssl-dev libapr1 libaprutil1 libltdl-dev libltdl7 libneon27-gnutls libsqlite3-dev libsvn1 libtool sqlite3 subversion
sudo apt-get upgrade
sudo groupadd web
sudo useradd -G web -s /usr/sbin/nologin nginx
wget http://nginx.org/download/nginx-1.0.12.tar.gz
tar -xvf nginx-1.0.12.tar.gz
cd nginx-1.0.12
./configure --user=nginx --group=web --conf-path=/etc/nginx/nginx.conf
make
sudo make install
wget https://gist.github.com/raw/1893745/0d5b164921b3c3b3d1066b8cf06acd115b78e4d5/nginx.conf
sudo cp nginx.conf /etc/nginx/nginx.conf
wget https://gist.github.com/raw/1893745/0eaece4bf2e03f16e75355d3e29aa3874d0483fc/nginx_init.conf
sudo cp nginx_init.conf /etc/init/nginx.conf
sudo mkdir /web_apps
sudo useradd -G web -d /web_apps/collanthropy -m -s /bin/bash collanthropy
sudo su collanthropy
cd ~
bash -s stable < <(curl -s https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer)
source ~/.bashrc
source ~/.bash_login
rvm install 1.9.3
rvm use 1.9.3@global --default
rvm gemset create collanthropy
gem install bundler unicorn
rvm wrapper 1.9.3@global collanthropy unicorn
#copy key to server
scp -i ~/Downloads/pc_web.pem ~/collanthropy.pub ubuntu@ec2-23-20-111-47.compute-1.amazonaws.com:~/collanthropy.pub
sudo mkdir /web_apps/collanthropy/.ssh
sudo touch /web_apps/collanthropy/.ssh/authorized_keys
sudo chmod 777 /web_apps/collanthropy/.ssh/authorized_keys
sudo cat collanthropy.pub >> /web_apps/collanthropy/.ssh/authorized_keys
sudo chown collanthropy:collanthropy -R /web_apps/collanthropy/.ssh
sudo chmod 700 -R /web_apps/collanthropy/.ssh
sudo chmod 600 -R /web_apps/collanthropy/.ssh/authorized_keys
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment