Skip to content

Instantly share code, notes, and snippets.

@Dimtree
Last active February 28, 2022 09:16
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 Dimtree/d07a537bcdfa6fe672b99ad08d93ceee to your computer and use it in GitHub Desktop.
Save Dimtree/d07a537bcdfa6fe672b99ad08d93ceee to your computer and use it in GitHub Desktop.
Compile ngx-fancyindex dynamically for current nginx version
#!/bin/bash -e
#echo "Please enter NGINX version:"
#read version
version=$(nginx -v 2>&1 | egrep -o "([0-9]{1,}\.)+[0-9]{1,}")
echo "Read NGINX version as \"$version\""
tmpdir=$(mktemp -d)
pushd "$tmpdir"
wget "http://nginx.org/download/nginx-${version}.tar.gz"
tar -xzf "nginx-${version}.tar.gz"
git clone --depth=1 "https://github.com/aperezdc/ngx-fancyindex.git"
pushd "nginx-${version}"
./configure --with-compat --add-dynamic-module=../ngx-fancyindex/
make modules
sudo mv -v "/etc/nginx/modules/ngx_http_fancyindex_module.so" "/etc/nginx/modules/ngx_http_fancyindex_module.so.bak" || true
sudo mv -v "./objs/ngx_http_fancyindex_module.so" "/etc/nginx/modules/"
sudo nginx -t
sudo systemctl restart nginx
popd
rm -rf "$tmpdir"
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment