编译过程是通过configure命令配置的。这定义了有关系统的各个方面,包括nginx允许的处理连接数。最后会创建一个Makefile文件。configure命令支持下面的参数。
--prefix=path 定义保存服务器文件的目录。这个目录页被用于通过configure设置的和nginx.conf设置的相对路径。默认被设置为/usr/local/nginx目录。
--sbin-path=path 设置nginx可执行文件的名称。这个名字在安装的时候才会被使用。默认文件名字为prefix/sbin/nginx
--conf-path=path 设置nginx.conf配置文件的名称。如果需要的话,nginx可以使用-c file来指定一个不同的配置文件。默认文件名为prefix/conf/nginx.conf
--pid-path=path 设置nginx.pid文件的名字,存储着主进程的ID号。安装之后,文件名可以在nginx.conf文件里设置。默认文件名为prefix/logs/nginx.pid
--error-log-path=path 设置错误,警告和诊断的文件。在安装后,文件名可以在nginx.conf 文件里通过error_log指令改变。默认文件名字为prefix/logs/error.log
--http-log-path=path 设置HTTP服务器请求的日志文件名称。在安装之后,名字可以在nginx.conf文件里面使用access_log指令改变。默认文件名为prefix/logs/access.log
--user=name 设置worker进程的非特权用户。在安装之后,可以在nginx.conf文件里面使用user指令改变。默认用户名为nobody
--group=name 设置worker进程的组。安装之后可以在nginx。conf里面通过user指令改变。默认组名被设置为非特权用户的名字。
--with-select_module
--without-select_module 允许或禁止编译服务器使用select()方法工作。如果平台上没有合适的方法找到,例如kqueue,epoll,或者/dev/poll,那么这个模块会自动编译。
--with-poll_module
--without-poll_module 允许或禁止服务器工作在poll()方式。如果平台上没有合适的方法像kqueue,epoll或者/dev/poll,那么这个模块会自动编译。
--without-http_gzip_module 禁止编译压缩HTTP服务器回复的模块。要想编译和运行这么模块,那么需要zlib库的支持。
--without-http_rewrite_module 禁止编译HTTP重定向请求的模块。为了编译这个模块,PCRE库需要事先准备好。
--without-httpd_proxy_module 禁止编译HTTP服务器代理模块
--with-http_ssl_module 允许编译支持HTTPS协议的模块。默认没编译。为了编译和运行这个模块,OpenSSL库是需要的。
--with-pcre=path 设置PCRE源码的路径,这个库发需要从PCRE网站下载。这个库需要被正则表达式localtion指令支持。和ngx_http_rewrite_module。
--with-zlib=path 设置zlib库的源位置,这个库需要从官网下载这个库依靠http_gzip模块。
-with-ld-opt=parameters 设置在链接时候的额外的参数
案例:
./configure
--sbin-path=/usr/local/nginx/nginx \
--conf-path=/usr/local/nginx/nginx.conf \
--pid-path=/usr/local/nginx/nginx.pid \
--with-http_ssl_module \
--with-pcre=../pcre-4.4 \
--with-zlib=../zlib-1.1.3
配置之后,nginx可以使用make编译和安装。
The build is configured using the configure command.It defines various aspects of the system, including the methods nginx isallowed to use for connection processing. At the end it creates aMakefile. The configure commandsupports the following parameters:
--prefix=path — defines a directorythat will keep server files. This same directory will also be used for allrelative paths set by configure (except for paths to librariessources) and in the nginx.conf configuration file. It is set to the /usr/local/nginx directoryby default.
--sbin-path=path — sets the name of annginx executable file. This name is used only during installation. By defaultthe file is named prefix/sbin/nginx.
--conf-path=path — sets the name of an nginx.conf configurationfile. If needs be, nginx can always be started with a different configurationfile, by specifying it in the command-line parameter -c file. Bydefault the file is named prefix/conf/nginx.conf.
--pid-path=path — sets the name of annginx.pid file that will store the process ID of the main process. Afterinstallation, the file name can always be changed in the nginx.confconfigurationfile using the pid directive.By default the file is named prefix/logs/nginx.pid.
--error-log-path=path — sets the nameof the primary error, warnings, and diagnostic file. After installation, thefile name can always be changed in the nginx.conf configuration fileusing the error_log directive.By default the file is named prefix/logs/error.log.
--http-log-path=path — sets the nameof the primary request log file of the HTTP server. After installation, thefile name can always be changed in the nginx.conf configuration fileusing the access_log directive.By default the file is named prefix/logs/access.log.
--user=name — sets the name of anunprivileged user whose credentials will be used by worker processes. Afterinstallation, the name can always be changed in the nginx.conf configurationfile using the user directive.The default user name is nobody.