Created
July 9, 2012 20:02
-
-
Save bordoni/3078569 to your computer and use it in GitHub Desktop.
Makefile for custom path NGINX
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
.SILENT: | |
workplace := $(CURDIR) | |
clean: | |
rm -rf server tmp | |
setup: | |
echo "Setting up NGINX" | |
mkdir -p tmp server conf sites | |
ifeq ("$(wildcard conf/default.conf)","") | |
echo -e "worker_processes 2;\n\nevents {\n\tworker_connections 1024;\n}\n\nhttp {\n\tinclude ../sites/*;\n}\n" > conf/default.conf | |
endif | |
ifeq ("$(wildcard tmp/pcre-8.31.tar.gz)","") | |
cd tmp/ && curl -O ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.31.tar.gz | |
endif | |
cd tmp/ \ | |
&& tar -zxf pcre-8.31.tar.gz | |
ifeq ("$(wildcard tmp/nginx-1.2.1.tar.gz)","") | |
cd tmp/ && curl -O http://nginx.org/download/nginx-1.2.1.tar.gz | |
endif | |
cd tmp/ \ | |
&& tar -zxf nginx-1.2.1.tar.gz \ | |
&& cd nginx-1.2.1 \ | |
&& ./configure \ | |
--with-pcre=$(workplace)/tmp/pcre-8.31 \ | |
--prefix=$(workplace)/server \ | |
--sbin-path=$(workplace)/server/nginx \ | |
--conf-path=$(workplace)/conf/default.conf \ | |
--pid-path=$(workplace)/server/nginx.pid \ | |
--with-http_ssl_module \ | |
--with-debug \ | |
&& make && make install | |
echo "NGINX setup, complete!" | |
start: | |
ifneq ("$(wildcard server/nginx.pid)","") | |
echo "NGINX already running" | |
else | |
sudo server/nginx | |
echo "NGINX started" | |
endif | |
stop: | |
ifneq ("$(wildcard server/nginx.pid)","") | |
ps -ef | grep nginx | grep -v grep | tr -s ' ' | cut -d ' ' -f 3 | xargs sudo kill -9 | |
rm -rf server/nginx.pid | |
echo "NGINX stopped" | |
sleep 2 | |
else | |
echo "NGINX not running" | |
endif | |
restart: stop start |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment