NGINX----源码阅读---config配置脚本
config文件为nginx的配置入口文件。
1.
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
1 #!/bin/sh 2 3 # Copyright (C) Igor Sysoev 4 # Copyright (C) Nginx, Inc. 5 6 7 LC_ALL=C 8 export LC_ALL
2.nginx各种环境变量的初始化脚本
. auto/options
3.nginx各种文件目录,路径变量的初始化。
. auto/init
4.初始化nginx基本源码路径环境变量
. auto/sources
5.第一步,创建nginx目录。
test -d $NGX_OBJS || mkdir -p $NGX_OBJS
6.创建ngx_auto_headers.h和autoconf.err(变量在init中赋值的)
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
1 echo > $NGX_AUTO_HEADERS_H 2 echo > $NGX_AUTOCONF_ERR
7.在ngx_auto_headers.h文件中定义宏NGX_CONFIGURE
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
1 echo "#define NGX_CONFIGURE \"$NGX_CONFIGURE\"" > $NGX_AUTO_CONFIG_H
8.如果是debug模式,在ngx_auto_config.h文件中定义NGX_DEBUG宏
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
1 if [ $NGX_DEBUG = YES ]; then 2 have=NGX_DEBUG . auto/have 3 fi
9.
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
1 if test -z "$NGX_PLATFORM"; then 2 echo "checking for OS" 3 4 NGX_SYSTEM=`uname -s 2>/dev/null` 5 NGX_RELEASE=`uname -r 2>/dev/null` 6 NGX_MACHINE=`uname -m 2>/dev/null` 7 8 echo " + $NGX_SYSTEM $NGX_RELEASE $NGX_MACHINE" 9 10 NGX_PLATFORM="$NGX_SYSTEM:$NGX_RELEASE:$NGX_MACHINE"; 11 12 case "$NGX_SYSTEM" in 13 MINGW32_*) 14 NGX_PLATFORM=win32 15 ;; 16 esac 17 18 else 19 echo "building for $NGX_PLATFORM" 20 NGX_SYSTEM=$NGX_PLATFORM 21 fi
10.
. auto/cc/conf
11.
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
1 if [ "$NGX_PLATFORM" != win32 ]; then 2 . auto/headers 3 fi 4 5 . auto/os/conf 6 7 if [ "$NGX_PLATFORM" != win32 ]; then 8 . auto/unix 9 fi
12.
. auto/threads
13.将nginx对应的所有模块编码到ngx_modules.c文件中。
. auto/modules
14.
. auto/lib/conf