Skip to content

Instantly share code, notes, and snippets.

@sirodoht
Forked from ninjarobot/Makefile
Created September 6, 2022 04:55
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 sirodoht/e802d76b4132f390fe63650924511587 to your computer and use it in GitHub Desktop.
Save sirodoht/e802d76b4132f390fe63650924511587 to your computer and use it in GitHub Desktop.
Building nginx for macOS without homebrew
# default target so running 'make' by itself wll download and build nginx
build: nginx
cd nginx && ./configure --with-pcre=../pcre2 && make
nginx: pcre2
curl -O https://nginx.org/download/nginx-1.21.6.tar.gz
tar -xzvf nginx-*.tar.gz
mv nginx-*/ nginx
rm nginx-*.tar.gz
pcre2:
curl -OL https://github.com/PCRE2Project/pcre2/releases/download/pcre2-10.40/pcre2-10.40.tar.gz
tar -xzvf pcre2-*.tar.gz
mv pcre2-*/ pcre2
rm pcre2-*.tar.gz
# clean removes files used to build nginx to allow for a fresh build
clean:
rm -rf nginx* *.tar.gz pcre2*
# install requires elevated permissions and installs to the default /usr/local/nginx
install: build
cd nginx && sudo make install
# some handy symlinks
symlinks:
ln -s /usr/local/nginx/logs/access.log access.log
ln -s /usr/local/nginx/conf/nginx.conf nginx.conf
ln -s /usr/local/nginx/logs/error.log error.log
# purge will stop nginx and remove everything created when installing
purge: clean
rm -f *.log nginx.conf
sudo /usr/local/nginx/sbin/nginx -s quit
sudo rm -rf /usr/local/nginx
# backup makes a copy of nginx.conf
backup:
cp /usr/local/nginx/conf/nginx.conf backup.nginx.conf
# restore puts the backup of nginx.conf back into place
restore:
sudo cp backup.nginx.conf /usr/local/nginx/conf/nginx.conf
start:
sudo /usr/local/nginx/sbin/nginx
stop:
sudo /usr/local/nginx/sbin/nginx -s quit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment