Skip to content

Instantly share code, notes, and snippets.

@josephscott
Last active March 28, 2016 10:47
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save josephscott/b79e79a8b7e17ca1bdb7 to your computer and use it in GitHub Desktop.
Save josephscott/b79e79a8b7e17ca1bdb7 to your computer and use it in GitHub Desktop.
Nginx Test Build
#!/bin/sh
NGINX_VER=1.7.7
apt-get update
apt-get -y upgrade
apt-get -y install build-essential zlib1g-dev libpcre3 libpcre3-dev libbz2-dev libssl-dev tar unzip openssl
mkdir -p dev/nginx
cd dev/nginx
curl -O http://nginx.org/download/nginx-${NGINX_VER}.tar.gz
tar -xzvf nginx-${NGINX_VER}.tar.gz
cd nginx-${NGINX_VER}/
./configure --with-debug --prefix=/etc/nginx --sbin-path=/usr/sbin/nginx --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx.pid --lock-path=/var/run/nginx.lock --http-client-body-temp-path=/var/cache/nginx/client_temp --http-proxy-temp-path=/var/cache/nginx/proxy_temp --http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp --http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp --http-scgi-temp-path=/var/cache/nginx/scgi_temp --user=nginx --group=nginx --with-http_ssl_module --with-http_realip_module --with-http_addition_module --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_mp4_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_random_index_module --with-http_secure_link_module --with-http_stub_status_module --with-http_auth_request_module --with-mail --with-mail_ssl_module --with-file-aio --with-http_spdy_module --with-cc-opt='-g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2' --with-ld-opt='-Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,--as-needed' --with-ipv6
make
make install
mkdir /var/cache/nginx
mkdir /etc/nginx/ssl
cd /etc/nginx/ssl
echo "\n** HTTPS cert **\n"
openssl req -nodes -x509 -sha256 -newkey rsa:4096 -keyout "nginx.test.key" -out "nginx.test.crt" -days 3650 -subj "/C=US/ST=UT/L=Place/O=Me/OU=You/CN=nginx.test"
echo "\n ** editing /etc/nginx/nginx.conf **"
perl -pi -e 's/^\#user\s+nobody\;/user www-data\;/' /etc/nginx/nginx.conf
perl -pi -e 's/listen\s+80\;/listen 443 ssl spdy\;/' /etc/nginx/nginx.conf
perl -pi -e 's/server_name\s+localhost\;/server_name nginx.test\;/' /etc/nginx/nginx.conf
perl -pi -e "s/^(\s+)server\s+{/\1server {\n\1\1ssl_certificate \/etc\/nginx\/ssl\/nginx\.test\.crt\;\n\1\1ssl_certificate_key \/etc\/nginx\/ssl\/nginx\.test\.key\;\n/" /etc/nginx/nginx.conf
echo "\n ** Time to start nginx **"
# nginx
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment