mirror of
https://github.com/php/php-src.git
synced 2024-09-22 10:27:25 +00:00
This patch implements a new Apache2 directive called PHPINIDir that
allows the specification of the php.ini directory from within the Apache configuration. If left unset, the default is to defer to the hard-coded php paths. When set, the supplied path is made relative to Apache's internal ServerRoot setting. Example: PHPINIDir "conf" # PHP will now look in the ServerRoot/conf directory for the php.ini file
This commit is contained in:
parent
ab54cc1e1b
commit
3aa8a9b62b
@ -18,6 +18,7 @@
|
||||
|
||||
#include "php.h"
|
||||
#include "php_ini.h"
|
||||
#include "php_apache.h"
|
||||
|
||||
#include "apr_strings.h"
|
||||
#include "ap_config.h"
|
||||
@ -82,6 +83,16 @@ static const char *php_apache_admin_value_handler(cmd_parms *cmd, void *dummy, c
|
||||
return real_value_hnd(cmd, dummy, name, value, PHP_INI_SYSTEM);
|
||||
}
|
||||
|
||||
static const char *php_apache_phpini_set(cmd_parms *cmd, void *mconfig, const char *arg)
|
||||
{
|
||||
if (apache2_php_ini_path_override) {
|
||||
return "PHPINIPath is not yet supported in vhost configurations";
|
||||
}
|
||||
apache2_php_ini_path_override = ap_server_root_relative(cmd->pool, arg);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
void *merge_php_config(apr_pool_t *p, void *base_conf, void *new_conf)
|
||||
{
|
||||
php_conf_rec *d = base_conf, *e = new_conf;
|
||||
@ -130,6 +141,8 @@ const command_rec php_dir_cmds[] =
|
||||
"PHP Value Modifier"),
|
||||
AP_INIT_TAKE2("php_admin_value", php_apache_admin_value_handler, NULL, OR_NONE,
|
||||
"PHP Value Modifier"),
|
||||
AP_INIT_TAKE1("PHPINIDir", php_apache_phpini_set, NULL, RSRC_CONF,
|
||||
"Directory containing the php.ini file"),
|
||||
{NULL}
|
||||
};
|
||||
|
||||
|
@ -19,6 +19,17 @@
|
||||
#ifndef PHP_APACHE_H
|
||||
#define PHP_APACHE_H
|
||||
|
||||
#include "httpd.h"
|
||||
#include "http_config.h"
|
||||
#include "http_core.h"
|
||||
|
||||
/* Declare this so we can get to it from outside the sapi_apache2.c file */
|
||||
extern module AP_MODULE_DECLARE_DATA php4_module;
|
||||
|
||||
/* A way to specify the location of the php.ini dir in an apache directive */
|
||||
extern char *apache2_php_ini_path_override;
|
||||
|
||||
/* The server_context used by PHP */
|
||||
typedef struct php_struct {
|
||||
int state;
|
||||
request_rec *r;
|
||||
|
@ -43,6 +43,9 @@
|
||||
|
||||
#include "php_apache.h"
|
||||
|
||||
/* A way to specify the location of the php.ini dir in an apache directive */
|
||||
char *apache2_php_ini_path_override = NULL;
|
||||
|
||||
static int
|
||||
php_apache_sapi_ub_write(const char *str, uint str_length TSRMLS_DC)
|
||||
{
|
||||
@ -248,15 +251,14 @@ static sapi_module_struct apache2_sapi_module = {
|
||||
php_apache_sapi_register_variables,
|
||||
php_apache_sapi_log_message, /* Log message */
|
||||
|
||||
NULL, /* php_ini_path_override */
|
||||
|
||||
NULL, /* Block interruptions */
|
||||
NULL, /* Unblock interruptions */
|
||||
|
||||
STANDARD_SAPI_MODULE_PROPERTIES
|
||||
};
|
||||
|
||||
|
||||
AP_MODULE_DECLARE_DATA module php4_module;
|
||||
|
||||
static int php_input_filter(ap_filter_t *f, apr_bucket_brigade *bb,
|
||||
ap_input_mode_t mode, apr_read_type_e block, apr_off_t readbytes)
|
||||
{
|
||||
@ -433,10 +435,23 @@ static void php_apache_add_version(apr_pool_t *p)
|
||||
}
|
||||
}
|
||||
|
||||
static int php_pre_config(apr_pool_t *pconf, apr_pool_t *plog, apr_pool_t *ptemp)
|
||||
{
|
||||
/* When this is NULL, apache won't override the hard-coded default
|
||||
* php.ini path setting. */
|
||||
apache2_php_ini_path_override = NULL;
|
||||
return OK;
|
||||
}
|
||||
|
||||
static int
|
||||
php_apache_server_startup(apr_pool_t *pconf, apr_pool_t *plog,
|
||||
apr_pool_t *ptemp, server_rec *s)
|
||||
{
|
||||
/* Set up our overridden path. */
|
||||
if (apache2_php_ini_path_override) {
|
||||
apache2_sapi_module.php_ini_path_override = apache2_php_ini_path_override;
|
||||
}
|
||||
|
||||
tsrm_startup(1, 1, 0, NULL);
|
||||
sapi_startup(&apache2_sapi_module);
|
||||
apache2_sapi_module.startup(&apache2_sapi_module);
|
||||
@ -510,6 +525,7 @@ static int php_post_read_request(request_rec *r)
|
||||
|
||||
static void php_register_hook(apr_pool_t *p)
|
||||
{
|
||||
ap_hook_pre_config(php_pre_config, NULL, NULL, APR_HOOK_MIDDLE);
|
||||
ap_hook_post_config(php_apache_server_startup, NULL, NULL, APR_HOOK_MIDDLE);
|
||||
ap_hook_insert_filter(php_insert_filter, NULL, NULL, APR_HOOK_MIDDLE);
|
||||
ap_hook_post_read_request(php_post_read_request, NULL, NULL, APR_HOOK_MIDDLE);
|
||||
|
Loading…
Reference in New Issue
Block a user