Klaus Demo nginx / 6d2a14a
nginx-0.1.0-2004-09-27-20:03:21 import Igor Sysoev 17 years ago
11 changed file(s) with 228 addition(s) and 161 deletion(s). Raw diff Collapse all Expand all
3030
3131 . auto/make
3232 . auto/lib/make
33 . auto/install
3334
3435 if [ "$PLATFORM" != win32 ]; then
3536 . auto/unix
0
1 cat << END >> $MAKEFILE
2 install:
3 test -d $PREFIX || mkdir -p $PREFIX
4
5 test -d `dirname $SBIN_PATH` || mkdir -p `dirname $SBIN_PATH`
6 cp nginx $SBIN_PATH
7
8 test -d `dirname $CONF_PATH` || mkdir -p `dirname $CONF_PATH`
9
10 cp conf/koi-win `dirname $CONF_PATH`
11
12 test -f `dirname $CONF_PATH`/mime.types || \
13 cp conf/mime.types `dirname $CONF_PATH`/mime.types
14 cp conf/mime.types `dirname $CONF_PATH`/mime.types.default
15
16 test -f $CONF_PATH || cp conf/nginx.conf $CONF_PATH
17 cp conf/nginx.conf `dirname $CONF_PATH`/nginx.conf.default
18
19 test -d `dirname $PID_PATH` || mkdir -p `dirname $PID_PATH`
20 test -d `dirname $ERROR_LOG_PATH` || mkdir -p `dirname $ERROR_LOG_PATH`
21 test -d `dirname $HTTP_LOG_PATH` || mkdir -p `dirname $HTTP_LOG_PATH`
22
23 test -d $PREFIX/html || cp -r html $PREFIX
24
25 #test -d $PREFIX/temp || mkdir -p $PREFIX/temp
26 END
27
28
29 if test ! -f Makefile; then
30
31 cat << END > Makefile
32
33 build:
34 \$(MAKE) -f $OBJS/Makefile
35
36 install:
37 \$(MAKE) -f $OBJS/Makefile install
38
39 clean:
40 rm -rf Makefile $OBJS
41
42 END
43
44 fi
3232 HTTP_CHARSET=YES
3333 HTTP_GZIP=YES
3434 HTTP_SSL=NO
35 HTTP_SSI=YES
35 HTTP_SSI=NO
3636 HTTP_ACCESS=YES
3737 HTTP_USERID=YES
38 HTTP_STATUS=YES
38 HTTP_STATUS=NO
3939 HTTP_REWRITE=YES
4040 HTTP_PROXY=YES
4141
182182 PREFIX=/usr/local/nginx
183183 fi
184184
185 if [ ".$SBIN_PATH" = "." ]; then
186 SBIN_PATH=$PREFIX/sbin/nginx
187 fi
188
189 if [ ".$CONF_PATH" = "." ]; then
190 CONF_PATH=$PREFIX/conf/nginx.conf
191 fi
192
193 if [ ".$PID_PATH" = "." ]; then
194 PID_PATH=$PREFIX/logs/nginx.pid
195 fi
196
197 if [ ".$ERROR_LOG_PATH" = "." ]; then
198 ERROR_LOG_PATH=$PREFIX/logs/error.log
199 fi
200
201 if [ ".$HTTP_LOG_PATH" = "." ]; then
202 HTTP_LOG_PATH=$PREFIX/logs/access.log
203 fi
185
186 case ".$SBIN_PATH" in
187 ./*)
188 ;;
189
190 .)
191 SBIN_PATH=$PREFIX/sbin/nginx
192 ;;
193
194 *)
195 SBIN_PATH=$PREFIX/$SBIN_PATH
196 ;;
197 esac
198
199
200 case ".$CONF_PATH" in
201 ./*)
202 ;;
203
204 .)
205 CONF_PATH=$PREFIX/conf/nginx.conf
206 ;;
207
208 *)
209 CONF_PATH=$PREFIX/$CONF_PATH
210 ;;
211 esac
212
213
214 case ".$PID_PATH" in
215 ./*)
216 ;;
217
218 .)
219 PID_PATH=$PREFIX/logs/nginx.pid
220 ;;
221
222 *)
223 PID_PATH=$PREFIX/$PID_PATH
224 ;;
225 esac
226
227
228 case ".$ERROR_LOG_PATH" in
229 ./*)
230 ;;
231
232 .)
233 ERROR_LOG_PATH=$PREFIX/logs/error.log
234 ;;
235
236 *)
237 ERROR_LOG_PATH=$PREFIX/$ERROR_LOG_PATH
238 ;;
239 esac
240
241
242 case ".$HTTP_LOG_PATH" in
243 ./*)
244 ;;
245
246 .)
247 HTTP_LOG_PATH=$PREFIX/logs/access.log
248 ;;
249
250 *)
251 HTTP_LOG_PATH=$PREFIX/$HTTP_LOG_PATH
252 ;;
253 esac
127127 ctx.argc = argc;
128128 ctx.argv = argv;
129129
130 if (ngx_os_init(log) == NGX_ERROR) {
131 return 1;
132 }
133
134 if (!(init_cycle.pool = ngx_create_pool(1024, log))) {
135 return 1;
136 }
137
130138 if (ngx_getopt(&ctx, &init_cycle) == NGX_ERROR) {
131 return 1;
132 }
133
134 if (ngx_os_init(log) == NGX_ERROR) {
135 return 1;
136 }
137
138 if (!(init_cycle.pool = ngx_create_pool(1024, log))) {
139139 return 1;
140140 }
141141
335335 if (cycle->conf_file.data == NULL) {
336336 cycle->conf_file.len = sizeof(NGX_CONF_PATH) - 1;
337337 cycle->conf_file.data = (u_char *) NGX_CONF_PATH;
338 }
339
340 if (ngx_conf_full_name(cycle, &cycle->conf_file) == NGX_ERROR) {
341 return NGX_ERROR;
338342 }
339343
340344 return NGX_OK;
371375 {
372376 ngx_core_conf_t *ccf = conf;
373377
378 #if !(WIN32)
379 struct passwd *pwd;
380 struct group *grp;
381 #endif
382
374383 ngx_conf_init_value(ccf->daemon, 1);
375384 ngx_conf_init_value(ccf->master, 1);
376385 ngx_conf_init_value(ccf->worker_processes, 1);
383392
384393 #if !(WIN32)
385394
386 /* TODO: default "nobody" user */
395 if (ccf->user == (uid_t) NGX_CONF_UNSET) {
396
397 pwd = getpwnam("nobody");
398 if (pwd == NULL) {
399 ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_errno,
400 "getpwnam(\"nobody\") failed");
401 return NGX_CONF_ERROR;
402 }
403
404 ccf->user = pwd->pw_uid;
405
406 grp = getgrnam("nobody");
407 if (grp == NULL) {
408 ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_errno,
409 "getgrnam(\"nobody\") failed");
410 return NGX_CONF_ERROR;
411 }
412
413 ccf->group = grp->gr_gid;
414 }
387415
388416 if (ccf->pid.len == 0) {
389417 ccf->pid.len = sizeof(NGX_PID_PATH) - 1;
390418 ccf->pid.data = NGX_PID_PATH;
391 ccf->newpid.len = sizeof(NGX_PID_PATH NGX_NEWPID_EXT) - 1;
392 ccf->newpid.data = NGX_PID_PATH NGX_NEWPID_EXT;
393
394 } else {
395 ccf->newpid.len = ccf->pid.len + sizeof(NGX_NEWPID_EXT);
396
397 if (!(ccf->newpid.data = ngx_palloc(cycle->pool, ccf->newpid.len))) {
398 return NGX_CONF_ERROR;
399 }
400
401 ngx_memcpy(ngx_cpymem(ccf->newpid.data, ccf->pid.data, ccf->pid.len),
402 NGX_NEWPID_EXT, sizeof(NGX_NEWPID_EXT));
403 }
419 }
420
421 if (ngx_conf_full_name(cycle, &ccf->pid) == NGX_ERROR) {
422 return NGX_CONF_ERROR;
423 }
424
425 ccf->newpid.len = ccf->pid.len + sizeof(NGX_NEWPID_EXT);
426
427 if (!(ccf->newpid.data = ngx_palloc(cycle->pool, ccf->newpid.len))) {
428 return NGX_CONF_ERROR;
429 }
430
431 ngx_memcpy(ngx_cpymem(ccf->newpid.data, ccf->pid.data, ccf->pid.len),
432 NGX_NEWPID_EXT, sizeof(NGX_NEWPID_EXT));
433
404434 #endif
405435
406436 return NGX_CONF_OK;
11 #define _NGINX_H_INCLUDED_
22
33
4 #define NGINX_VER "nginx/0.0.12"
4 #define NGINX_VER "nginx/0.1.0"
55
66 #define NGINX_VAR "NGINX"
77 #define NGX_NEWPID_EXT ".newbin"
548548 ngx_str_t *value, file;
549549
550550 value = cf->args->elts;
551
552 if (value[1].data[0] == '/') {
553 return ngx_conf_parse(cf, &value[1]);
554 }
555
556 file.len = cf->cycle->root.len + value[1].len;
557 if (!(file.data = ngx_palloc(cf->pool, file.len + 1))) {
551 file = value[1];
552
553 if (ngx_conf_full_name(cf->cycle, &file) == NGX_ERROR){
558554 return NGX_CONF_ERROR;
559555 }
560556
561 ngx_cpystrn(ngx_cpymem(file.data, cf->cycle->root.data,
562 cf->cycle->root.len),
563 value[1].data, value[1].len + 1);
564
565557 ngx_log_error(NGX_LOG_INFO, cf->log, 0, "include %s", file.data);
566558
567559 return ngx_conf_parse(cf, &file);
568560 }
569561
570562
563 ngx_int_t ngx_conf_full_name(ngx_cycle_t *cycle, ngx_str_t *name)
564 {
565 u_char *p;
566 ngx_str_t old;
567
568 if (name->data[0] == '/') {
569 return NGX_OK;
570 }
571
572 old = *name;
573
574 name->len = cycle->root.len + old.len;
575
576 if (!(name->data = ngx_palloc(cycle->pool, name->len + 1))) {
577 return NGX_ERROR;
578 }
579
580 p = ngx_cpymem(name->data, cycle->root.data, cycle->root.len),
581 ngx_cpystrn(p, old.data, old.len + 1);
582
583 return NGX_OK;
584 }
585
586
571587 ngx_open_file_t *ngx_conf_open_file(ngx_cycle_t *cycle, ngx_str_t *name)
572588 {
589 ngx_str_t full;
573590 ngx_uint_t i;
574591 ngx_list_part_t *part;
575592 ngx_open_file_t *file;
576593
577594 if (name) {
595 full = *name;
596
597 if (ngx_conf_full_name(cycle, &full) == NGX_ERROR) {
598 return NULL;
599 }
600
578601 part = &cycle->open_files.part;
579602 file = part->elts;
580603
589612 i = 0;
590613 }
591614
592 if (name->len != file[i].name.len) {
593 continue;
594 }
595
596 if (ngx_strcmp(name->data, file[i].name.data) == 0) {
615 if (full.len != file[i].name.len) {
616 continue;
617 }
618
619 if (ngx_strcmp(full.data, file[i].name.data) == 0) {
597620 return &file[i];
598621 }
599622 }
606629 file->fd = NGX_INVALID_FILE;
607630
608631 if (name) {
609 file->name = *name;
632 file->name = full;
633
610634 } else {
635
636 /* stderr */
637
611638 file->name.len = 0;
612639 file->name.data = NULL;
613640 }
264264 char *ngx_conf_parse(ngx_conf_t *cf, ngx_str_t *filename);
265265
266266
267 ngx_int_t ngx_conf_full_name(ngx_cycle_t *cycle, ngx_str_t *name);
267268 ngx_open_file_t *ngx_conf_open_file(ngx_cycle_t *cycle, ngx_str_t *name);
268269 void ngx_conf_log_error(ngx_uint_t level, ngx_conf_t *cf, ngx_err_t err,
269270 char *fmt, ...);
529529 if (ccf->pid.len == old_ccf->pid.len
530530 && ngx_strcmp(ccf->pid.data, old_ccf->pid.data) == 0)
531531 {
532
533 /* pid file name is the same */
534
532535 return NGX_OK;
533536 }
534537 }
374374
375375 } else {
376376 cf->cycle->new_log->file->name = value[1];
377
378 if (ngx_conf_full_name(cf->cycle, &cf->cycle->new_log->file->name)
379 == NGX_ERROR)
380 {
381 return NGX_CONF_ERROR;
382 }
377383 }
378384
379385 return ngx_set_error_log_levels(cf, cf->cycle->new_log);
+0
-100
src/core/ngx_modules.c less more
0
1 #include <ngx_config.h>
2 #include <ngx_core.h>
3
4
5 extern ngx_module_t ngx_core_module;
6 extern ngx_module_t ngx_errlog_module;
7
8 extern ngx_module_t ngx_events_module;
9 extern ngx_module_t ngx_event_core_module;
10 extern ngx_module_t ngx_select_module;
11 #if (HAVE_POLL)
12 extern ngx_module_t ngx_poll_module;
13 #endif
14 #if (HAVE_KQUEUE)
15 extern ngx_module_t ngx_kqueue_module;
16 #endif
17 #if (HAVE_DEVPOLL)
18 extern ngx_module_t ngx_devpoll_module;
19 #endif
20 #if (HAVE_IOCP)
21 extern ngx_module_t ngx_iocp_module;
22 #elif (HAVE_AIO)
23 extern ngx_module_t ngx_aio_module;
24 #endif
25
26
27 extern ngx_module_t ngx_http_module;
28 extern ngx_module_t ngx_http_core_module;
29 extern ngx_module_t ngx_http_log_module;
30 extern ngx_module_t ngx_http_cache_module;
31
32 extern ngx_module_t ngx_http_write_filter_module;
33 extern ngx_module_t ngx_http_output_filter_module;
34 extern ngx_module_t ngx_http_header_filter_module;
35
36 extern ngx_module_t ngx_http_chunked_filter_module;
37 extern ngx_module_t ngx_http_gzip_filter_module;
38 extern ngx_module_t ngx_http_not_modified_filter_module;
39 extern ngx_module_t ngx_http_range_filter_module;
40 extern ngx_module_t ngx_http_charset_filter_module;
41
42 extern ngx_module_t ngx_http_static_module;
43 extern ngx_module_t ngx_http_index_module;
44 extern ngx_module_t ngx_http_proxy_module;
45
46
47 ngx_module_t *ngx_modules[] = {
48
49 /* core */
50
51 &ngx_core_module,
52 &ngx_errlog_module,
53
54 /* events */
55
56 &ngx_events_module,
57 &ngx_event_core_module,
58
59 &ngx_select_module,
60 #if (HAVE_POLL)
61 &ngx_poll_module,
62 #endif
63 #if (HAVE_KQUEUE)
64 &ngx_kqueue_module,
65 #endif
66 #if (HAVE_DEVPOLL)
67 &ngx_devpoll_module,
68 #endif
69 #if (HAVE_IOCP)
70 &ngx_iocp_module,
71 #elif (HAVE_AIO)
72 &ngx_aio_module,
73 #endif
74
75 /* http */
76
77 &ngx_http_module,
78
79 &ngx_http_core_module,
80 &ngx_http_log_module,
81 &ngx_http_cache_module,
82
83 &ngx_http_write_filter_module,
84 &ngx_http_output_filter_module,
85 &ngx_http_header_filter_module,
86
87 &ngx_http_chunked_filter_module,
88 &ngx_http_gzip_filter_module,
89 &ngx_http_not_modified_filter_module,
90 &ngx_http_range_filter_module,
91 /* &ngx_http_ssi_filter_module, */
92 &ngx_http_charset_filter_module,
93
94 &ngx_http_static_module,
95 &ngx_http_index_module,
96 &ngx_http_proxy_module,
97
98 NULL
99 };
14141414 ngx_http_type_t *t;
14151415
14161416 ngx_conf_merge_str_value(conf->root, prev->root, "html");
1417
1418 if (ngx_conf_full_name(cf->cycle, &conf->root) == NGX_ERROR) {
1419 return NGX_CONF_ERROR;
1420 }
14171421
14181422 if (conf->types == NULL) {
14191423 if (prev->types) {