]> git.kaiwu.me - nginx.git/commitdiff
--sysconfdir=DIR
authorIgor Sysoev <igor@sysoev.ru>
Sun, 29 Jul 2007 18:05:45 +0000 (18:05 +0000)
committerIgor Sysoev <igor@sysoev.ru>
Sun, 29 Jul 2007 18:05:45 +0000 (18:05 +0000)
17 files changed:
auto/configure
auto/install
auto/options
auto/summary
src/core/nginx.c
src/core/ngx_conf_file.c
src/core/ngx_conf_file.h
src/core/ngx_file.c
src/core/ngx_file.h
src/core/ngx_log.c
src/event/ngx_event_openssl.c
src/http/modules/ngx_http_auth_basic_module.c
src/http/modules/ngx_http_geo_module.c
src/http/modules/ngx_http_map_module.c
src/http/modules/perl/ngx_http_perl_module.c
src/http/ngx_http_core_module.c
src/http/ngx_http_variables.c

index bcb8aaa3a2e22d707e4ed23ad6ffb54fc332da52..00a7f48722ced335529786265cb1736b1bcad4fe 100755 (executable)
@@ -67,6 +67,7 @@ fi
 
 have=NGX_PREFIX value="\"$NGX_PREFIX/\"" . auto/define
 have=NGX_SBIN_PATH value="\"$NGX_SBIN_PATH\"" . auto/define
+have=NGX_CONF_PREFIX value="\"$NGX_CONF_PREFIX/\"" . auto/define
 have=NGX_CONF_PATH value="\"$NGX_CONF_PATH\"" . auto/define
 have=NGX_PID_PATH value="\"$NGX_PID_PATH\"" . auto/define
 have=NGX_LOCK_PATH value="\"$NGX_LOCK_PATH\"" . auto/define
index 3496c5b12b38d92d0df4dad3e9e64fb31578a404..e949aecccfaf8c8c5b027ea11818cd44590ae089 100644 (file)
@@ -26,19 +26,22 @@ install:    $NGX_OBJS${ngx_dirsep}nginx${ngx_binext}        \
        test ! -f '$NGX_SBIN_PATH' || mv '$NGX_SBIN_PATH' '$NGX_SBIN_PATH.old'
        cp $NGX_OBJS/nginx '$NGX_SBIN_PATH'
 
-       test -d '`dirname "$NGX_CONF_PATH"`' \
-               || mkdir -p '`dirname "$NGX_CONF_PATH"`'
+       test -d '$NGX_CONF_PREFIX' || mkdir -p '$NGX_CONF_PREFIX'
 
-       cp conf/koi-win '`dirname "$NGX_CONF_PATH"`'
-       cp conf/koi-utf '`dirname "$NGX_CONF_PATH"`'
-       cp conf/win-utf '`dirname "$NGX_CONF_PATH"`'
+       cp conf/koi-win '$NGX_CONF_PREFIX'
+       cp conf/koi-utf '$NGX_CONF_PREFIX'
+       cp conf/win-utf '$NGX_CONF_PREFIX'
 
-       test -f '`dirname "$NGX_CONF_PATH"`/mime.types' || \
-               cp conf/mime.types '`dirname "$NGX_CONF_PATH"`/mime.types'
-       cp conf/mime.types '`dirname "$NGX_CONF_PATH"`/mime.types.default'
+       test -f '$NGX_CONF_PREFIX/mime.types' \
+               || cp conf/mime.types '$NGX_CONF_PREFIX'
+       cp conf/mime.types '$NGX_CONF_PATH/mime.types.default'
 
-       test -f '$NGX_CONF_PATH' || cp conf/nginx.conf '$NGX_CONF_PATH'
-       cp conf/nginx.conf '`dirname "$NGX_CONF_PATH"`/nginx.conf.default'
+       test -f '$NGX_CONF_PREFIX/fastcgi_params' \
+               || cp conf/fastcgi_params '$NGX_CONF_PREFIX'
+       cp conf/fastcgi_params '$NGX_CONF_PATH/fastcgi_params.default'
+
+       test -f '$NGX_CONF_PATH' || cp conf/nginx.conf '$NGX_CONF_PREFIX'
+       cp conf/nginx.conf '$NGX_CONF_PREFIX/nginx.conf.default'
 
        test -d '`dirname "$NGX_PID_PATH"`' \
                || mkdir -p '`dirname "$NGX_PID_PATH"`'
index 7fb7131a0a2a78956204daf79f0be4c6b996b95c..0640f8c84d37fcf08e1818071840f98542cbc13a 100644 (file)
@@ -6,6 +6,7 @@ help=no
 
 NGX_PREFIX=
 NGX_SBIN_PATH=
+NGX_CONF_PREFIX=
 NGX_CONF_PATH=
 NGX_ERROR_LOG_PATH=
 NGX_PID_PATH=
@@ -123,6 +124,7 @@ do
 
         --prefix=*)                      NGX_PREFIX="$value"        ;;
         --sbin-path=*)                   NGX_SBIN_PATH="$value"     ;;
+        --sysconfdir=*)                  NGX_CONF_PREFIX="$value"   ;;
         --conf-path=*)                   NGX_CONF_PATH="$value"     ;;
         --error-log-path=*)              NGX_ERROR_LOG_PATH="$value";;
         --pid-path=*)                    NGX_PID_PATH="$value"      ;;
@@ -240,6 +242,7 @@ cat << END
 
   --prefix=PATH                      set the installation prefix
   --sbin-path=PATH                   set path to the nginx binary file
+  --sysconfdir=PATH                  set the configuration prefix
   --conf-path=PATH                   set path to the nginx.conf file
   --error-log-path=PATH              set path to the error log
   --pid-path=PATH                    set path to nginx.pid file
@@ -360,6 +363,7 @@ fi
 
 
 NGX_PREFIX=${NGX_PREFIX:-/usr/local/nginx}
+NGX_CONF_PREFIX=${NGX_CONF_PREFIX:-$NGX_PREFIX}
 
 
 case ".$NGX_SBIN_PATH" in
@@ -381,11 +385,11 @@ case ".$NGX_CONF_PATH" in
     ;;
 
     .)
-        NGX_CONF_PATH=$NGX_PREFIX/conf/nginx.conf
+        NGX_CONF_PATH=$NGX_CONF_PREFIX/conf/nginx.conf
     ;;
 
     *)
-        NGX_CONF_PATH=$NGX_PREFIX/$NGX_CONF_PATH
+        NGX_CONF_PATH=$NGX_CONF_PREFIX/$NGX_CONF_PATH
     ;;
 esac
 
index accb7b9ac803398a53bdb5661a821c1ee3825676..c220c71236aaea61a28b0b38742e6b2ac1882bbf 100644 (file)
@@ -148,6 +148,7 @@ fi
 cat << END
   nginx path prefix: "$NGX_PREFIX"
   nginx binary file: "$NGX_SBIN_PATH"
+  nginx configuration prefix: "$NGX_CONF_PREFIX"
   nginx configuration file: "$NGX_CONF_PATH"
   nginx pid file: "$NGX_PID_PATH"
 END
index b758775e3eca241892da0f52b034159759ca71d1..27cb80f851adceeab2a399f7f4edf15d49594805 100644 (file)
@@ -656,7 +656,7 @@ ngx_getopt(ngx_cycle_t *cycle, int argc, char *const *argv)
         cycle->conf_file.data = (u_char *) NGX_CONF_PATH;
     }
 
-    if (ngx_conf_full_name(cycle, &cycle->conf_file) == NGX_ERROR) {
+    if (ngx_conf_full_name(cycle, &cycle->conf_file, 1) == NGX_ERROR) {
         return NGX_ERROR;
     }
 
@@ -826,7 +826,7 @@ ngx_core_module_init_conf(ngx_cycle_t *cycle, void *conf)
         ccf->pid.data = (u_char *) NGX_PID_PATH;
     }
 
-    if (ngx_conf_full_name(cycle, &ccf->pid) == NGX_ERROR) {
+    if (ngx_conf_full_name(cycle, &ccf->pid, 0) == NGX_ERROR) {
         return NGX_CONF_ERROR;
     }
 
@@ -846,7 +846,7 @@ ngx_core_module_init_conf(ngx_cycle_t *cycle, void *conf)
         ccf->lock_file.data = (u_char *) NGX_LOCK_PATH;
     }
 
-    if (ngx_conf_full_name(cycle, &ccf->lock_file) == NGX_ERROR) {
+    if (ngx_conf_full_name(cycle, &ccf->lock_file, 0) == NGX_ERROR) {
         return NGX_CONF_ERROR;
     }
 
index a68192fe00552c7f6b59ec1eb5eb6f7d8dab0ee5..514d55badc4a692c4807dcd41a721776113bf764 100644 (file)
@@ -641,7 +641,7 @@ ngx_conf_include(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
 
     ngx_log_debug1(NGX_LOG_DEBUG_CORE, cf->log, 0, "include %s", file.data);
 
-    if (ngx_conf_full_name(cf->cycle, &file) == NGX_ERROR) {
+    if (ngx_conf_full_name(cf->cycle, &file, 1) == NGX_ERROR) {
         return NGX_CONF_ERROR;
     }
 
@@ -681,9 +681,10 @@ ngx_conf_include(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
 
 
 ngx_int_t
-ngx_conf_full_name(ngx_cycle_t *cycle, ngx_str_t *name)
+ngx_conf_full_name(ngx_cycle_t *cycle, ngx_str_t *name, ngx_uint_t conf_prefix)
 {
-    u_char     *p;
+    size_t      len;
+    u_char     *p, *prefix;
     ngx_str_t   old;
 
     if (name->data[0] == '/') {
@@ -704,14 +705,22 @@ ngx_conf_full_name(ngx_cycle_t *cycle, ngx_str_t *name)
 
     old = *name;
 
-    name->len = cycle->root.len + old.len;
+    if (conf_prefix) {
+        len = sizeof(NGX_CONF_PREFIX) - 1;
+        prefix = (u_char *) NGX_CONF_PREFIX;
 
+    } else {
+        len = cycle->root.len;
+        prefix = cycle->root.data;
+    }
+
+    name->len = len + old.len;
     name->data = ngx_palloc(cycle->pool, name->len + 1);
     if (name->data == NULL) {
         return  NGX_ERROR;
     }
 
-    p = ngx_cpymem(name->data, cycle->root.data, cycle->root.len),
+    p = ngx_cpymem(name->data, prefix, len);
     ngx_cpystrn(p, old.data, old.len + 1);
 
     return NGX_OK;
@@ -734,7 +743,7 @@ ngx_conf_open_file(ngx_cycle_t *cycle, ngx_str_t *name)
     if (name) {
         full = *name;
 
-        if (ngx_conf_full_name(cycle, &full) == NGX_ERROR) {
+        if (ngx_conf_full_name(cycle, &full, 0) == NGX_ERROR) {
             return NULL;
         }
 
index 7d5112919daf1de84722e8561f0c973f231944e2..2e91d0b8c6a5df97c4c608678203325b99f1e810 100644 (file)
@@ -320,7 +320,8 @@ char *ngx_conf_check_num_bounds(ngx_conf_t *cf, void *post, void *data);
 char *ngx_conf_parse(ngx_conf_t *cf, ngx_str_t *filename);
 
 
-ngx_int_t ngx_conf_full_name(ngx_cycle_t *cycle, ngx_str_t *name);
+ngx_int_t ngx_conf_full_name(ngx_cycle_t *cycle, ngx_str_t *name,
+    ngx_uint_t conf_prefix);
 ngx_open_file_t *ngx_conf_open_file(ngx_cycle_t *cycle, ngx_str_t *name);
 void ngx_cdecl ngx_conf_log_error(ngx_uint_t level, ngx_conf_t *cf,
     ngx_err_t err, char *fmt, ...);
index fcb8ff0802db85186210668f648b044ff2083774..f8557862316623c99396f9866a7c33f269df1edc 100644 (file)
@@ -260,7 +260,7 @@ ngx_conf_set_path_slot(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
         path->name.len--;
     }
 
-    if (ngx_conf_full_name(cf->cycle, &path->name) == NGX_ERROR) {
+    if (ngx_conf_full_name(cf->cycle, &path->name, 0) == NGX_ERROR) {
         return NULL;
     }
 
index 0f819a1b842b879198bc2ce0ec3a3010d466a452..063b0fb83cac523a29d76947685bb229c259bd3a 100644 (file)
@@ -109,7 +109,7 @@ char *ngx_conf_set_access_slot(ngx_conf_t *cf, ngx_command_t *cmd, void *conf);
             curr->name.len = sizeof(path) - 1;                                \
             curr->name.data = (u_char *) path;                                \
                                                                               \
-            if (ngx_conf_full_name(cf->cycle, &curr->name) == NGX_ERROR) {    \
+            if (ngx_conf_full_name(cf->cycle, &curr->name, 0) == NGX_ERROR) { \
                 return NGX_CONF_ERROR;                                        \
             }                                                                 \
                                                                               \
index 349ae7681923eb7c51f033360a5a92e728a3a00a..1059acf439618d5abe5376f1b3b9b52c16fdb410 100644 (file)
@@ -333,7 +333,7 @@ ngx_set_error_log(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
     } else {
         cf->cycle->new_log->file->name = value[1];
 
-        if (ngx_conf_full_name(cf->cycle, &cf->cycle->new_log->file->name)
+        if (ngx_conf_full_name(cf->cycle, &cf->cycle->new_log->file->name, 0)
             == NGX_ERROR)
         {
             return NGX_CONF_ERROR;
index d3119688736d22352bbc29bb3220612d4fc6b5d9..63e5ba95226bcacb750f5e3ac4fa93278164d061 100644 (file)
@@ -198,7 +198,7 @@ ngx_int_t
 ngx_ssl_certificate(ngx_conf_t *cf, ngx_ssl_t *ssl, ngx_str_t *cert,
     ngx_str_t *key)
 {
-    if (ngx_conf_full_name(cf->cycle, cert) == NGX_ERROR) {
+    if (ngx_conf_full_name(cf->cycle, cert, 1) == NGX_ERROR) {
         return NGX_ERROR;
     }
 
@@ -211,7 +211,7 @@ ngx_ssl_certificate(ngx_conf_t *cf, ngx_ssl_t *ssl, ngx_str_t *cert,
         return NGX_ERROR;
     }
 
-    if (ngx_conf_full_name(cf->cycle, key) == NGX_ERROR) {
+    if (ngx_conf_full_name(cf->cycle, key, 1) == NGX_ERROR) {
         return NGX_ERROR;
     }
 
@@ -242,7 +242,7 @@ ngx_ssl_client_certificate(ngx_conf_t *cf, ngx_ssl_t *ssl, ngx_str_t *cert,
         return NGX_OK;
     }
 
-    if (ngx_conf_full_name(cf->cycle, cert) == NGX_ERROR) {
+    if (ngx_conf_full_name(cf->cycle, cert, 1) == NGX_ERROR) {
         return NGX_ERROR;
     }
 
index 19bfe996e2ca6766f8bcdf9f023c8b5405803e64..72b4bbdcb276c5a580cc066f7332b17a94aed67c 100644 (file)
@@ -352,7 +352,7 @@ ngx_http_auth_basic_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child)
     }
 
     if (conf->user_file.data) {
-        if (ngx_conf_full_name(cf->cycle, &conf->user_file) != NGX_OK) {
+        if (ngx_conf_full_name(cf->cycle, &conf->user_file, 1) != NGX_OK) {
             return NGX_CONF_ERROR;
         }
 
index 62ef72cf956f8223cf9dcb95e4dc5d98fe09bd6e..9c43bd7165e315c79743feaee073d206d46cfc84 100644 (file)
@@ -198,7 +198,7 @@ ngx_http_geo(ngx_conf_t *cf, ngx_command_t *dummy, void *conf)
     if (ngx_strcmp(value[0].data, "include") == 0) {
         file = value[1];
 
-        if (ngx_conf_full_name(cf->cycle, &file) == NGX_ERROR){
+        if (ngx_conf_full_name(cf->cycle, &file, 1) == NGX_ERROR){
             return NGX_CONF_ERROR;
         }
 
index 4a8acd00dc41e747fdb480d48f6e5933841ceefa..7b3a363fc2b08c0254fca3ff0ed100f11bf4f686 100644 (file)
@@ -378,7 +378,7 @@ ngx_http_map(ngx_conf_t *cf, ngx_command_t *dummy, void *conf)
     if (ngx_strcmp(value[0].data, "include") == 0) {
         file = value[1];
 
-        if (ngx_conf_full_name(cf->cycle, &file) == NGX_ERROR){
+        if (ngx_conf_full_name(cf->cycle, &file, 1) == NGX_ERROR){
             return NGX_CONF_ERROR;
         }
 
index 248f5782390b3cb4ce67078d07b5177a3a5bd181..836a415c983e547b4065082af768ed37650a034c 100644 (file)
@@ -454,7 +454,7 @@ ngx_http_perl_init_interpreter(ngx_conf_t *cf, ngx_http_perl_main_conf_t *pmcf)
 #endif
 
     if (pmcf->modules.data) {
-        if (ngx_conf_full_name(cf->cycle, &pmcf->modules) != NGX_OK) {
+        if (ngx_conf_full_name(cf->cycle, &pmcf->modules, 0) != NGX_OK) {
             return NGX_CONF_ERROR;
         }
     }
index a903c9a2495008d985ad2f361851b02e94e21493..eb221395cea529cba6c9458a773363d46cdb29db 100644 (file)
@@ -1223,7 +1223,8 @@ ngx_http_map_uri_to_path(ngx_http_request_t *r, ngx_str_t *path,
             return NULL;
         }
 
-        if (ngx_conf_full_name((ngx_cycle_t *) ngx_cycle, path) == NGX_ERROR) {
+        if (ngx_conf_full_name((ngx_cycle_t *) ngx_cycle, path, 0)== NGX_ERROR)
+        {
             return NULL;
         }
 
@@ -1947,7 +1948,7 @@ ngx_http_core_type(ngx_conf_t *cf, ngx_command_t *dummy, void *conf)
     if (ngx_strcmp(value[0].data, "include") == 0) {
         file = value[1];
 
-        if (ngx_conf_full_name(cf->cycle, &file) == NGX_ERROR){
+        if (ngx_conf_full_name(cf->cycle, &file, 1) == NGX_ERROR){
             return NGX_CONF_ERROR;
         }
 
@@ -2290,7 +2291,7 @@ ngx_http_core_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child)
             conf->root.len = sizeof("html") - 1;
             conf->root.data = (u_char *) "html";
 
-            if (ngx_conf_full_name(cf->cycle, &conf->root) == NGX_ERROR) {
+            if (ngx_conf_full_name(cf->cycle, &conf->root, 0) == NGX_ERROR) {
                 return NGX_CONF_ERROR;
             }
         }
@@ -2739,7 +2740,7 @@ ngx_http_core_root(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
     }
 
     if (lcf->root.data[0] != '$') {
-        if (ngx_conf_full_name(cf->cycle, &lcf->root) == NGX_ERROR) {
+        if (ngx_conf_full_name(cf->cycle, &lcf->root, 0) == NGX_ERROR) {
             return NGX_CONF_ERROR;
         }
     }
index 91374607938883c5b6a27d46737de9726f3f4b23..123017d808d81dc1d0dc60002f0b6575f5070921 100644 (file)
@@ -926,7 +926,9 @@ ngx_http_variable_document_root(ngx_http_request_t *r,
             return NGX_ERROR;
         }
 
-        if (ngx_conf_full_name((ngx_cycle_t *) ngx_cycle, &path) == NGX_ERROR) {
+        if (ngx_conf_full_name((ngx_cycle_t *) ngx_cycle, &path, 0)
+            == NGX_ERROR)
+        {
             return NGX_ERROR;
         }