Skip to content

Instantly share code, notes, and snippets.

@YellowSharkMT
Last active December 6, 2015 21:53
Show Gist options
  • Save YellowSharkMT/7c70c202d5c66320cda5 to your computer and use it in GitHub Desktop.
Save YellowSharkMT/7c70c202d5c66320cda5 to your computer and use it in GitHub Desktop.
Compile Nginx for Webfaction
#!/bin/bash
# This script is intended to be executed from the root directory of
# the extracted Nginx ZIP file. The ZIP file is available http://nginx.org/en/download.html
# The Nginx config dir will be ~/etc/nginx.
# The default HTML directory will be ~/htdocs/html.
#
# IMPORTANT NOTE: this script makes an attempt to be "upgrade-friendly". It backs up
# up the existing nginx directory, prior to upgrading, and also makes a copy of the
# existing ~/etc/nginx/nginx.conf file.
#
# WARNING: YOU WILL NEED TO RESTORE YOUR ORIGINAL NGINX, after you run `make install`
if [ -e $HOME/etc/nginx ]; then
NG_DIR="$(pwd)"
cd $HOME/etc
TIMESTAMP=$(date +"%Y%m%d-%H%M")
tar -czvf ./nginx.bak.$TIMESTAMP.tar.gz ./nginx/
cp nginx/nginx.conf{,.bak.$TIMESTAMP}
cd $NG_DIR
fi
# Creates the following directories:
# - ~/htdocs/html/
# - ~/logs/user/nginx/
# - ~/run/nginx/
# - ~/lock/
# - ~/tmp/nginx/
# - |- client/
# - |- proxy/
# - |- fcgi/
# - |- uwsgi/
# - |- scgi/
mkdir -p $HOME/{htdocs/html,logs/user/nginx,run/nginx,lock,tmp/nginx/{client,proxy,fcgi,uwsgi,scgi}}
./configure --prefix=$HOME/htdocs/html \
--sbin-path=$HOME/sbin/nginx \
--conf-path=$HOME/etc/nginx/nginx.conf \
--error-log-path=$HOME/logs/user/nginx/error.log \
--http-log-path=$HOME/logs/user/nginx/access.log \
--pid-path=$HOME/run/nginx/nginx.pid \
--lock-path=$HOME/lock/nginx.lock \
--http-client-body-temp-path=$HOME/tmp/nginx/client/ \
--http-proxy-temp-path=$HOME/tmp/nginx/proxy/ \
--http-fastcgi-temp-path=$HOME/tmp/nginx/fcgi/ \
--http-uwsgi-temp-path=$HOME/tmp/nginx/uwsgi/ \
--http-scgi-temp-path=$HOME/tmp/nginx/scgi/ \
--with-http_flv_module \
--with-http_ssl_module \
--with-http_gzip_static_module
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment