# [PATCH] PHPIniDir for 1.3?

- Thread: https://externals.io/message/16739
- Original archive: https://news-web.php.net/php.internals/16739
- Started by William A. Rowe on 2005-06-16T16:16:49+00:00
- Messages: 1
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #16739 — William A. Rowe — 2005-06-16T16:16:49+00:00

URL: https://externals.io/message/16739#16739

Several of my administrators have grown to love PHPIniDir
in the sapi/apache2handler/, so I've thrown together this
patch for Apache 1.3 mod_php to provide the feature.  I'm
guessing alot of users would be grateful for it if they
want to keep php.ini in the conf/ tree, or wherever makes
the most sense for their system config.

Can be applied to mod_php4.c or mod_php5.c below;

--- sapi/apache/mod_php4.c
+++ sapi/apache/mod_php4.c
@@ -814,6 +814,18 @@
 }
 /* }}} */
 
+/* {{{ php_apache_phpini_set
+ */
+static const char *php_apache_phpini_set(cmd_parms *cmd, void *mconfig, const char *arg)
+{
+	if (apache_sapi_module.php_ini_path_override) {
+		return "Only first PHPINIDir directive honored per configuration tree - subsequent ones ignored";
+	}
+	apache_sapi_module.php_ini_path_override = ap_server_root_relative(cmd->pool, arg);
+	return NULL;
+}
+/* }}} */
+
 /* {{{ int php_xbithack_handler(request_rec * r)
  */
 static int php_xbithack_handler(request_rec * r)
@@ -918,6 +930,7 @@
 	{"php_flag",		php_apache_flag_handler, NULL, OR_OPTIONS, TAKE2, "PHP Flag Modifier"},
 	{"php_admin_value",	php_apache_admin_value_handler, NULL, ACCESS_CONF|RSRC_CONF, TAKE2, "PHP Value Modifier (Admin)"},
 	{"php_admin_flag",	php_apache_admin_flag_handler, NULL, ACCESS_CONF|RSRC_CONF, TAKE2, "PHP Flag Modifier (Admin)"},
+	{"PHPINIDir",           php_apache_phpini_set, NULL, RSRC_CONF, TAKE1, "Directory containing the php.ini file (Admin)"},
 	{NULL}
 };
 /* }}} */
--- sapi/apache/mod_php5.c
+++ sapi/apache/mod_php5.c
@@ -814,6 +814,18 @@
 }
 /* }}} */
 
+/* {{{ php_apache_phpini_set
+ */
+static const char *php_apache_phpini_set(cmd_parms *cmd, void *mconfig, const char *arg)
+{
+	if (apache_sapi_module.php_ini_path_override) {
+		return "Only first PHPINIDir directive honored per configuration tree - subsequent ones ignored";
+	}
+	apache_sapi_module.php_ini_path_override = ap_server_root_relative(cmd->pool, arg);
+	return NULL;
+}
+/* }}} */
+
 /* {{{ int php_xbithack_handler(request_rec * r)
  */
 static int php_xbithack_handler(request_rec * r)
@@ -918,6 +930,7 @@
 	{"php_flag",		php_apache_flag_handler, NULL, OR_OPTIONS, TAKE2, "PHP Flag Modifier"},
 	{"php_admin_value",	php_apache_admin_value_handler, NULL, ACCESS_CONF|RSRC_CONF, TAKE2, "PHP Value Modifier (Admin)"},
 	{"php_admin_flag",	php_apache_admin_flag_handler, NULL, ACCESS_CONF|RSRC_CONF, TAKE2, "PHP Flag Modifier (Admin)"},
+	{"PHPINIDir",           php_apache_phpini_set, NULL, RSRC_CONF, TAKE1, "Directory containing the php.ini file (Admin)"},
 	{NULL}
 };
 /* }}} */
