diff -uNpar apache2handler/sapi_apache2.c apache2handler.alt-sapi/sapi_apache2.c --- apache2handler/sapi_apache2.c 2007-01-01 12:36:12 +0300 +++ apache2handler.alt-sapi/sapi_apache2.c 2007-03-07 13:53:52 +0300 @@ -51,6 +51,7 @@ #include "http_core.h" #include "ap_mpm.h" +#include #include "php_apache.h" /* UnixWare and Netware define shutdown to _shutdown, which causes problems later @@ -82,6 +83,29 @@ php_apache_sapi_ub_write(const char *str return str_length; /* we always consume all the data passed to us. */ } +/* default php.ini path */ +static int php_ini_path_override(char **val) +{ + char *buf = NULL; + + if (getenv("PHPRC")) { + *val = buf; + return 0; + } + + if ((buf = (char *) malloc(MAXPATHLEN)) == NULL) { + errno = ENOMEM; + return -1; + } + + snprintf(buf, MAXPATHLEN, "/etc/php/%d.%d.%d/apache2-mod_php", + PHP_MAJOR_VERSION, + PHP_MINOR_VERSION, + PHP_RELEASE_VERSION); + *val = buf; + return 0; +} + static int php_apache_sapi_header_handler(sapi_header_struct *sapi_header,sapi_headers_struct *sapi_headers TSRMLS_DC) { @@ -407,6 +431,11 @@ php_apache_server_startup(apr_pool_t *pc /* Set up our overridden path. */ if (apache2_php_ini_path_override) { apache2_sapi_module.php_ini_path_override = apache2_php_ini_path_override; + } else { + if ( php_ini_path_override(&apache2_sapi_module.php_ini_path_override) == -1) { + perror("Can't override php.ini path"); + return NULL; + } } #ifdef ZTS tsrm_startup(1, 1, 0, NULL);