Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save infinityhacks/98c4312ea8999c867d4f0b737bbc37cd to your computer and use it in GitHub Desktop.
Save infinityhacks/98c4312ea8999c867d4f0b737bbc37cd to your computer and use it in GitHub Desktop.
Set up nginx with Lua, Pagespeed, et al.
# Ubuntu instructions
# Get the pre-reqs for this (Ubuntu)
sudo apt-get install git-core build-essential zlib1g-dev libpcre3 libpcre3-dev redis-server libssl-dev libgeoip-dev libgoogle-perftools-dev geoip-database lua5.1 liblua5.1-0 liblua5.1-0-dev lua-iconv-dev libghc-iconv-dev luarocks libpcre3-dev libghc-zlib-bindings-dev
# For Centos:
sudo yum install wget
wget http://ftp.riken.jp/Linux/fedora/epel/RPM-GPG-KEY-EPEL-6
wget http://dl.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm
rpm -ivh epel-release-6-8.noarch.rpm
sudo yum groupinstall "Development Tools"
sudo yum install git pcre-devel openssl-devel gperftools-devel
sudo yum --enablerepo=epel install GeoIP GeoIP-devel GeoIP-data
# Now get hold of the latest build of nginx from http://nginx.org/en/download.html
# At time of writing this was 1.3.12
wget http://nginx.org/download/nginx-1.3.12.tar.gz
tar xzvf nginx-1.3.12.tar.gz
cd nginx-1.3.12
# Get the SPDY patch: refer to http://nginx.org/patches/spdy/README.txt for the latest documentation
wget http://nginx.org/patches/spdy/patch.spdy.txt
patch -p1 < patch.spdy.txt
cd ..
# Now, get the other useful modules that we want to use so that nginx can handle CSRF, geoIP, etc
# First, we will need the nginx development kit - find the latest version at https://github.com/simpl/ngx_devel_kit/tags
wget -O ngx_devel_kit.tar.gz https://github.com/simpl/ngx_devel_kit/archive/v0.2.18.tar.gz
tar xvzf ngx_devel_kit.tar.gz
# Get the headers more module (latest available from https://github.com/agentzh/headers-more-nginx-module/tags)
wget -O ngx_headers_more.tar.gz https://github.com/agentzh/headers-more-nginx-module/archive/v0.19rc1.tar.gz
tar xvzf ngx_headers_more.tar.gz
# Get the user agent module:
git clone git://github.com/taobao/nginx-http-user-agent.git
# Get the iconv module
git clone git://github.com/calio/iconv-nginx-module.git
# Get the form input module
git clone git://github.com/calio/form-input-nginx-module.git
# Nginx pagespeed
git clone https://github.com/pagespeed/ngx_pagespeed.git
git clone http://luajit.org/git/luajit-2.0.git
cd luajit-2.0
sudo make install
export LUAJIT_LIB=/usr/local/bin/luajit
export LUAJIT_INC=/usr/local/include/luajit-2.0
cd ..
# Get Redis2
wget -O ngx_redis2.tar.gz https://github.com/agentzh/redis2-nginx-module/archive/v0.09.tar.gz
tar xzvf ngx_redis2.tar.gz
cd nginx-1.3.12
./configure --with-http_geoip_module --with-http_ssl_module --with-http_spdy_module --with-http_gzip_static_module --with-google_perftools_module --add-module=../ngx_devel_kit-0.2.18 --add-module=../headers-more-nginx-module-0.19rc1 --add-module=../iconv-nginx-module --add-module=../ngx_pagespeed --add-module=../redis2-nginx-module-0.09 --add-module=../nginx-http-user-agent --add-module=../form-input-nginx-module
make -j2
sudo make install
# Test that it starts:
/usr/local/nginx/sbin/nginx
# Test you get the nginx page:
curl http://localhost
# You may need to run this as well before you can remotely:
service iptables stop
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment