-
-
Save jtgeibel/5456493 to your computer and use it in GitHub Desktop.
Install the latest nginx with passenger and some extensions.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/sh | |
### BEGIN INIT INFO | |
# Provides: nginx | |
# Required-Start: $all | |
# Required-Stop: $all | |
# Default-Start: 2 3 4 5 | |
# Default-Stop: 0 1 6 | |
# Short-Description: starts the nginx web server | |
# Description: starts nginx using start-stop-daemon | |
### END INIT INFO | |
PATH=/usr/local/rvm/bin:/sbin:/bin:/usr/sbin:/usr/bin | |
DAEMON=/usr/sbin/nginx | |
NAME=nginx | |
DESC=nginx | |
PID_FILE=/var/run/$NAME.pid | |
test -x $DAEMON || exit 0 | |
# Include nginx defaults if available | |
if [ -f /etc/default/nginx ] ; then | |
. /etc/default/nginx | |
fi | |
set -e | |
case "$1" in | |
start) | |
echo -n "Starting $DESC: " | |
start-stop-daemon --start --quiet --pidfile $PID_FILE \ | |
--exec $DAEMON -- $DAEMON_OPTS | |
echo "$NAME." | |
;; | |
stop) | |
echo -n "Stopping $DESC: " | |
start-stop-daemon --stop --quiet --pidfile $PID_FILE \ | |
--exec $DAEMON | |
echo "$NAME." | |
;; | |
restart|force-reload) | |
echo -n "Restarting $DESC: " | |
start-stop-daemon --stop --quiet --pidfile $PID_FILE \ | |
--exec $DAEMON | |
sleep 1 | |
start-stop-daemon --start --quiet --pidfile $PID_FILE\ | |
--exec $DAEMON -- $DAEMON_OPTS | |
echo "$NAME." | |
;; | |
reload) | |
echo -n "Reloading $DESC configuration: " | |
start-stop-daemon --stop --signal HUP --quiet --pidfile $PID_FILE \ | |
--exec $DAEMON | |
echo "$NAME." | |
;; | |
*) | |
N=/etc/init.d/$NAME | |
echo "Usage: $N {start|stop|restart|reload|force-reload}" >&2 | |
exit 1 | |
;; | |
esac | |
exit 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
server { | |
listen 443 ssl spdy; | |
server_name example.com; | |
passenger_ruby /usr/local/rvm/wrappers/ruby-2.1.1/ruby; | |
ssl_certificate ssl/certs/ssl1-4096.crt; | |
ssl_certificate_key ssl/private/ssl1-4096.key; | |
add_header Strict-Transport-Security "max-age=31536000"; | |
root /home/app-name/app/public; | |
passenger_enabled on; | |
passenger_min_instances 1; | |
passenger_set_cgi_param HTTP_X_FORWARDED_PROTO $scheme; | |
passenger_user app-name; | |
passenger_group app-name; | |
access_log /home/app-name/access.log; | |
error_log /home/app-name/error.log; | |
location ~ ^/assets/ { | |
gzip_static on; | |
expires 1y; | |
add_header Cache-Control public; | |
add_header ETag ""; | |
} | |
} | |
server { | |
listen 80; | |
server_name example.com; | |
return 301 https://example.com; | |
} | |
passenger_pre_start https://example.com/; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
NGINX_VERSION=1.5.12 | |
DL_PATH=~/nginx | |
# Fetch and extract Nginx | |
cd $DL_PATH | |
if [ ! -d "nginx-$NGINX_VERSION" ]; then | |
wget http://nginx.org/download/nginx-$NGINX_VERSION.tar.gz | |
tar xvfz nginx-$NGINX_VERSION.tar.gz | |
fi | |
cd nginx-$NGINX_VERSION | |
# Install the latest passenger gem | |
gem install passenger | |
# Configure passenger (with ubuntu-style paths) | |
rvmsudo passenger-install-nginx-module \ | |
--auto \ | |
--nginx-source-dir=$DL_PATH/nginx-$NGINX_VERSION \ | |
--prefix=/usr \ | |
--extra-configure-flags=" \ | |
--conf-path=/etc/nginx/nginx.conf \ | |
--pid-path=/var/run/nginx.pid \ | |
--sbin-path=/usr/sbin \ | |
--error-log-path=/var/log/nginx/error.log \ | |
--http-log-path=/var/log/nginx/access.log \ | |
--with-http_spdy_module \ | |
--with-http_realip_module \ | |
--with-http_gzip_static_module \ | |
--without-mail_pop3_module \ | |
--without-mail_smtp_module \ | |
--without-mail_imap_module" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment