@@ -7,6 +7,7 @@ use Getopt::Std qw(getopts);
77use Cwd qw/ cwd/ ;
88
99sub sh ($);
10+ sub write_config_file ($);
1011
1112my %opts ;
1213getopts(" lf:" , \%opts ) or die " Usage: $0 [-f] [-l] <cores>\n " ;
@@ -44,15 +45,34 @@ if ($^O eq 'solaris') {
4445 $cfg_opts .= " --with-cc=gcc" ;
4546}
4647
48+ if ($^O eq ' darwin' ) {
49+ $cfg_opts .= " --with-cc-opt='-I/usr/local/include'"
50+ . " --with-ld-opt='-L/usr/local/lib'" ;
51+ }
52+
4753my $prefix ;
4854
55+ my $config = do { local $/ ; <DATA > };
56+
57+ sub write_config_file ($) {
58+ my $outfile = shift ;
59+ warn " Writing file $outfile \n " ;
60+ open my $out , " >$outfile " or
61+ die " Cannot open $outfile for writing: $! \n " ;
62+ print $out $config ;
63+ close $out ;
64+ }
65+
66+ write_config_file " /tmp/nginx.conf" ;
67+
4968warn " === Without Gzip ===\n " ;
5069$prefix = " /usr/local/openresty-nogzip" ;
5170unless ($opts {f }) {
5271 sh " ./configure $cfg_opts --without-http_gzip_module --prefix=$prefix -j$jobs > /dev/null" ;
5372}
5473sh " $make -j$jobs > /dev/null" ;
5574sh " sudo $make install > /dev/null" ;
75+ sh " sudo cp /tmp/nginx.conf $prefix /nginx/conf/nginx.conf" ;
5676sh " $prefix /nginx/sbin/nginx -V 2>&1 |grep $ver " ;
5777sh " $prefix /nginx/sbin/nginx -V 2>&1 |grep '\\ --without-http_gzip_module'" ;
5878system " sudo killall nginx > /dev/null 2>&1" ;
@@ -70,6 +90,7 @@ unless ($opts{f}) {
7090}
7191sh " $make -j$jobs > /dev/null" ;
7292sh " sudo $make install > /dev/null" ;
93+ sh " sudo cp /tmp/nginx.conf $prefix /nginx/conf/nginx.conf" ;
7394sh " $prefix /nginx/sbin/nginx -V 2>&1 |grep $ver " ;
7495# sh "$prefix/nginx/sbin/nginx -V 2>&1 |grep '\\--with-no-pool-patch'";
7596system " sudo killall nginx > /dev/null 2>&1" ;
@@ -88,6 +109,7 @@ unless ($opts{f}) {
88109}
89110sh " $make -j$jobs > /dev/null" ;
90111sh " sudo $make install > /dev/null" ;
112+ sh " sudo cp /tmp/nginx.conf $prefix /nginx/conf/nginx.conf" ;
91113sh " $prefix /nginx/sbin/nginx -V 2>&1 |grep $ver " ;
92114system " sudo killall nginx > /dev/null 2>&1" ;
93115sh " sudo $prefix /nginx/sbin/nginx" ;
@@ -108,6 +130,7 @@ unless ($opts{f}) {
108130}
109131sh " $make -j$jobs > /dev/null" ;
110132sh " sudo $make install > /dev/null" ;
133+ sh " sudo cp /tmp/nginx.conf $prefix /nginx/conf/nginx.conf" ;
111134sh " $prefix /nginx/sbin/nginx -V 2>&1 |grep $ver " ;
112135sh " $prefix /nginx/sbin/nginx -V 2>&1 |grep '\\ --with-debug'" ;
113136system " sudo killall nginx > /dev/null 2>&1" ;
@@ -125,6 +148,7 @@ unless ($opts{f}) {
125148}
126149sh " $make -j$jobs > /dev/null" ;
127150sh " sudo $make install > /dev/null" ;
151+ sh " sudo cp /tmp/nginx.conf $prefix /nginx/conf/nginx.conf" ;
128152sh " $prefix /nginx/sbin/nginx -V 2>&1 |grep $ver " ;
129153sh " $prefix /nginx/sbin/nginx -V 2>&1 |grep '\\ --with-dtrace-probes'" ;
130154system " sudo killall nginx > /dev/null 2>&1" ;
@@ -146,3 +170,49 @@ sub sh ($) {
146170 my $cmd = shift ;
147171 system ($cmd ) == 0 or die " Command \" $cmd \" failed" ;
148172}
173+
174+ __DATA__
175+
176+ user nobody;
177+ worker_processes 1;
178+ error_log logs/error.log;
179+ pid logs/nginx.pid;
180+
181+ events {
182+ accept_mutex off;
183+ worker_connections 256;
184+ }
185+
186+ http {
187+ include mime.types;
188+ default_type application/octet-stream;
189+
190+ init_by_lua '
191+ if jit then
192+ require "resty.core"
193+ end
194+ ';
195+
196+ server {
197+ listen *:80;
198+ server_name localhost;
199+
200+ location = /lua {
201+ content_by_lua '
202+ local upstream = require "ngx.upstream"
203+ if jit then
204+ ngx.say(jit.version)
205+ else
206+ ngx.say(_VERSION)
207+ end
208+ ';
209+ }
210+
211+ location = /cjson {
212+ content_by_lua '
213+ local json = require "cjson.safe"
214+ ngx.say("cjson.safe: ", json.encode{foo = 123})
215+ ';
216+ }
217+ }
218+ }
0 commit comments