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:
Aaron Bannert 2002-04-18 22:10:57 +00:00
parent ab54cc1e1b
commit 3aa8a9b62b
3 changed files with 43 additions and 3 deletions

View File

@ -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}
};

View File

@ -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;

View File

@ -42,6 +42,9 @@
#include "http_core.h"
#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);