cvs: php4 /sapi/apache2filter apache_config.c php_apache.h sapi_apache2.c

From: Date: Thu, 18 Apr 2002 22:10:58 +0000
Subject: cvs: php4 /sapi/apache2filter apache_config.c php_apache.h sapi_apache2.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-11203@lists.php.net to get a copy of this message
aaron Thu Apr 18 18:10:58 2002 EDT Modified files: /php4/sapi/apache2filter sapi_apache2.c php_apache.h apache_config.c Log: 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 Index: php4/sapi/apache2filter/sapi_apache2.c diff -u php4/sapi/apache2filter/sapi_apache2.c:1.72 php4/sapi/apache2filter/sapi_apache2.c:1.73 --- php4/sapi/apache2filter/sapi_apache2.c:1.72 Thu Apr 18 12:34:06 2002 +++ php4/sapi/apache2filter/sapi_apache2.c Thu Apr 18 18:10:57 2002 @@ -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 @@ 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 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 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); Index: php4/sapi/apache2filter/php_apache.h diff -u php4/sapi/apache2filter/php_apache.h:1.13 php4/sapi/apache2filter/php_apache.h:1.14 --- php4/sapi/apache2filter/php_apache.h:1.13 Thu Apr 11 16:34:56 2002 +++ php4/sapi/apache2filter/php_apache.h Thu Apr 18 18:10:57 2002 @@ -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; Index: php4/sapi/apache2filter/apache_config.c diff -u php4/sapi/apache2filter/apache_config.c:1.17 php4/sapi/apache2filter/apache_config.c:1.18 --- php4/sapi/apache2filter/apache_config.c:1.17 Thu Feb 28 03:27:19 2002 +++ php4/sapi/apache2filter/apache_config.c Thu Apr 18 18:10:57 2002 @@ -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 @@ 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 @@ "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} };

« previous php.cvs (#11203) next »