-
-
Save knowncolor/c07521c69108de53e167 to your computer and use it in GitHub Desktop.
Bash script to download, configure and install the latest OpenSSL configured nginx on your Raspbian Raspberry Pi
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
#!/usr/bin/env bash | |
# install and remove nginx via apt-get | |
# this sets up a lot of things which we would have to do manually otherwise | |
sudo apt-get -y install nginx | |
sudo apt-get -y remove nginx | |
# set up build directories | |
export BUILD_DIR=nginx-build | |
rm -rf $BUILD_DIR | |
mkdir $BUILD_DIR | |
cd $BUILD_DIR | |
export BUILD_PATH=$(pwd) | |
# latest versions of each package | |
export VERSION_PCRE=pcre-8.36 | |
export VERSION_OPENSSL=openssl-1.0.2 | |
export VERSION_NGINX=nginx-1.7.10 | |
# URLs to the source for each package | |
export SOURCE_OPENSSL=https://www.openssl.org/source/ | |
export SOURCE_PCRE=ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/ | |
export SOURCE_NGINX=http://nginx.org/download/ | |
# ensure that we have the required software to compile our own nginx | |
apt-get -y install curl build-essential geoip-database libgd2-noxpm libgeoip1 libxml2 libxslt1.1 sgml-base xml-core | |
# grab the source files | |
curl -O $SOURCE_PCRE$VERSION_PCRE.tar.gz | |
curl -O $SOURCE_OPENSSL$VERSION_OPENSSL.tar.gz | |
curl -O $SOURCE_NGINX$VERSION_NGINX.tar.gz | |
# expand the source files | |
tar xzf $VERSION_NGINX.tar.gz | |
tar xzf $VERSION_OPENSSL.tar.gz | |
tar xzf $VERSION_PCRE.tar.gz | |
# build static openssl | |
export STATICLIBSSL="$BUILD_PATH/staticlibssl" | |
cd $VERSION_OPENSSL | |
mkdir "$STATICLIBSSL" | |
make clean | |
./config --prefix=$STATICLIBSSL no-shared \ | |
&& make depend \ | |
&& make \ | |
&& make install_sw | |
# build nginx with some module customisations | |
cd $BUILD_PATH/$VERSION_NGINX | |
mkdir -p $BUILD_PATH/nginx | |
./configure --with-cc-opt="-I $STATICLIBSSL/include -I/usr/include" \ | |
--with-ld-opt="-L $STATICLIBSSL/lib -Wl,-rpath -lssl -lcrypto -ldl -lz" \ | |
--sbin-path=/usr/sbin/nginx \ | |
--conf-path=/etc/nginx/nginx.conf \ | |
--pid-path=/var/run/nginx.pid \ | |
--error-log-path=/var/log/nginx/error.log \ | |
--http-log-path=/var/log/nginx/access.log \ | |
--with-pcre=$BUILD_PATH/$VERSION_PCRE \ | |
--with-http_gzip_static_module \ | |
--with-http_spdy_module \ | |
--with-http_ssl_module \ | |
--with-ipv6 \ | |
--with-file-aio \ | |
--without-http_access_module \ | |
--without-http_ssi_module \ | |
--without-http_uwsgi_module \ | |
--without-http_split_clients_module \ | |
--without-http_upstream_ip_hash_module \ | |
--without-http_upstream_least_conn_module \ | |
--without-http_upstream_keepalive_module \ | |
--without-http_limit_req_module \ | |
--without-http_limit_conn_module \ | |
--without-mail_pop3_module \ | |
--without-mail_smtp_module \ | |
--without-mail_imap_module \ | |
&& make && make install |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment