APache的PHP模块启动
首先,了解一下每个Apache模块都会输出一个模块数据结构,其定义结构如下(以PHP模块为例):
int php_module_startup(sapi_module_struct *sf, zend_module_entry *additional_modules, uint num_additional_modules){ zend_utility_functions zuf; zend_utility_values zuv; int module_number=0; /* for REGISTER_INI_ENTRIES() */ char *php_os;#ifdef ZTS zend_executor_globals *executor_globals; void ***tsrm_ls; php_core_globals *core_globals;#endif#if defined(PHP_WIN32) || (defined(NETWARE) && defined(USE_WINSOCK)) WORD wVersionRequested = MAKEWORD(2, 0); WSADATA wsaData;#endif.................... php_ini_register_extensions(TSRMLS_C); zend_startup_modules(TSRMLS_C); /* disable certain classes and functions as requested by php.ini */ php_disable_functions(TSRMLS_C); php_disable_classes(TSRMLS_C); /* start Zend extensions */ zend_startup_extensions();#ifdef ZTS zend_post_startup(TSRMLS_C);#endif module_initialized = 1; sapi_deactivate(TSRMLS_C); module_startup = 0; shutdown_memory_manager(1, 0 TSRMLS_CC); /* we're done */ return SUCCESS;}这时会对PHP做一些环境初始化,如:php_init_config会读取php.ini文件,根据这个文件的配置,初始化PHP的环境及控制变量。
这就完成从apache启动之后,至PHP的初始化和环境准备了。