PHP: added setting of php.ini configuration file path.
This commit is contained in:
@@ -46,9 +46,10 @@ typedef struct {
|
|||||||
|
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
char *root;
|
char *root;
|
||||||
nxt_str_t script;
|
nxt_str_t script;
|
||||||
nxt_str_t index;
|
nxt_str_t index;
|
||||||
|
nxt_conf_value_t *options;
|
||||||
} nxt_php_app_conf_t;
|
} nxt_php_app_conf_t;
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -201,6 +201,16 @@ static nxt_conf_vldt_object_t nxt_conf_vldt_python_members[] = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
static nxt_conf_vldt_object_t nxt_conf_vldt_php_options_members[] = {
|
||||||
|
{ nxt_string("file"),
|
||||||
|
NXT_CONF_VLDT_STRING,
|
||||||
|
NULL,
|
||||||
|
NULL },
|
||||||
|
|
||||||
|
NXT_CONF_VLDT_END
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
static nxt_conf_vldt_object_t nxt_conf_vldt_php_members[] = {
|
static nxt_conf_vldt_object_t nxt_conf_vldt_php_members[] = {
|
||||||
{ nxt_string("root"),
|
{ nxt_string("root"),
|
||||||
NXT_CONF_VLDT_STRING,
|
NXT_CONF_VLDT_STRING,
|
||||||
@@ -217,6 +227,11 @@ static nxt_conf_vldt_object_t nxt_conf_vldt_php_members[] = {
|
|||||||
NULL,
|
NULL,
|
||||||
NULL },
|
NULL },
|
||||||
|
|
||||||
|
{ nxt_string("options"),
|
||||||
|
NXT_CONF_VLDT_OBJECT,
|
||||||
|
&nxt_conf_vldt_object,
|
||||||
|
(void *) &nxt_conf_vldt_php_options_members },
|
||||||
|
|
||||||
NXT_CONF_VLDT_NEXT(&nxt_conf_vldt_common_members)
|
NXT_CONF_VLDT_NEXT(&nxt_conf_vldt_common_members)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -169,6 +169,12 @@ static nxt_conf_map_t nxt_php_app_conf[] = {
|
|||||||
NXT_CONF_MAP_STR,
|
NXT_CONF_MAP_STR,
|
||||||
offsetof(nxt_common_app_conf_t, u.php.index),
|
offsetof(nxt_common_app_conf_t, u.php.index),
|
||||||
},
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
nxt_string("options"),
|
||||||
|
NXT_CONF_MAP_PTR,
|
||||||
|
offsetof(nxt_common_app_conf_t, u.php.options),
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -97,7 +97,7 @@ static sapi_module_struct nxt_php_sapi_module =
|
|||||||
|
|
||||||
0, /* php_ini_ignore */
|
0, /* php_ini_ignore */
|
||||||
#ifdef NXT_HAVE_PHP_IGNORE_CWD
|
#ifdef NXT_HAVE_PHP_IGNORE_CWD
|
||||||
0, /* php_ini_ignore_cwd */
|
1, /* php_ini_ignore_cwd */
|
||||||
#endif
|
#endif
|
||||||
NULL, /* get_fd */
|
NULL, /* get_fd */
|
||||||
|
|
||||||
@@ -184,10 +184,13 @@ static nxt_int_t
|
|||||||
nxt_php_init(nxt_task_t *task, nxt_common_app_conf_t *conf)
|
nxt_php_init(nxt_task_t *task, nxt_common_app_conf_t *conf)
|
||||||
{
|
{
|
||||||
u_char *p;
|
u_char *p;
|
||||||
nxt_str_t rpath;
|
nxt_str_t rpath, ini_path;
|
||||||
nxt_str_t *root, *path, *script, *index;
|
nxt_str_t *root, *path, *script, *index;
|
||||||
|
nxt_conf_value_t *value;
|
||||||
nxt_php_app_conf_t *c;
|
nxt_php_app_conf_t *c;
|
||||||
|
|
||||||
|
static nxt_str_t file_str = nxt_string("file");
|
||||||
|
|
||||||
c = &conf->u.php;
|
c = &conf->u.php;
|
||||||
|
|
||||||
if (c->root == NULL) {
|
if (c->root == NULL) {
|
||||||
@@ -271,6 +274,25 @@ nxt_php_init(nxt_task_t *task, nxt_common_app_conf_t *conf)
|
|||||||
}
|
}
|
||||||
|
|
||||||
sapi_startup(&nxt_php_sapi_module);
|
sapi_startup(&nxt_php_sapi_module);
|
||||||
|
|
||||||
|
if (c->options != NULL) {
|
||||||
|
value = nxt_conf_get_object_member(c->options, &file_str, NULL);
|
||||||
|
|
||||||
|
if (value != NULL) {
|
||||||
|
nxt_conf_get_string(value, &ini_path);
|
||||||
|
|
||||||
|
p = nxt_malloc(ini_path.length + 1);
|
||||||
|
if (nxt_slow_path(p == NULL)) {
|
||||||
|
return NXT_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
nxt_php_sapi_module.php_ini_path_override = (char *) p;
|
||||||
|
|
||||||
|
p = nxt_cpymem(p, ini_path.start, ini_path.length);
|
||||||
|
*p = '\0';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
nxt_php_startup(&nxt_php_sapi_module);
|
nxt_php_startup(&nxt_php_sapi_module);
|
||||||
|
|
||||||
return NXT_OK;
|
return NXT_OK;
|
||||||
|
|||||||
Reference in New Issue
Block a user