阿里云-云小站(无限量代金券发放中)
【腾讯云】云服务器、云数据库、COS、CDN、短信等热卖云产品特惠抢购

源码编译安装Nginx

398次阅读
没有评论

共计 6754 个字符,预计需要花费 17 分钟才能阅读完成。

编译过程是通过 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.

–group=name — sets the name of agroup whose credentials will be used by worker processes. After installation,the name can always be changed in the nginx.conf configuration fileusing the user directive.By default, a group name is set to the name of an unprivileged user.

–with-select_module
–without-select_module — enables or disables building a module thatallows the server to work with the select() method. This module isbuilt automatically if the platform does not appear to support more appropriatemethods such as kqueue, epoll, or /dev/poll.

–with-poll_module
–without-poll_module — enables or disables building a module that allowsthe server to work with the poll() method. This module is builtautomatically if the platform does not appear to support more appropriatemethods such as kqueue, epoll, or /dev/poll.

–without-http_gzip_module — disablesbuilding a module that compressesresponses of an HTTP server. The zlib library is required tobuild and run this module.

–without-http_rewrite_module —disables building a module that allows an HTTP server toredirectrequests and change URI of requests. The PCRE library is required tobuild and run this module.

–without-http_proxy_module — disablesbuilding an HTTP server proxyingmodule.

–with-http_ssl_module — enablesbuilding a module that adds the HTTPSprotocol support to an HTTP server. This module is not built bydefault. The OpenSSL library is required to build and run this module.

–with-pcre=path — sets the path tothe sources of the PCRE library. The library distribution (version 4.4 —8.32) needs to be downloaded from the PCRE siteand extracted. The rest is done by nginx’s ./configure and make.The library is required for regular expressions support in the location directiveand for the ngx_http_rewrite_module module.

–with-pcre-jit — builds the PCRElibrary with“just-in-time compilation”support (1.1.12, the pcre_jit directive).

–with-zlib=path — sets the path tothe sources of the zlib library. The library distribution (version 1.1.3 —1.2.7) needs to be downloaded from the zlib siteand extracted. The rest is done by nginx’s ./configure and make.The library is required for the ngx_http_gzip_modulemodule.

–with-cc-opt=parameters — setsadditional parameters that will be added to the CFLAGS variable. When using thesystem PCRE library under FreeBSD, –with-cc-opt=”-I/usr/local/include”should be specified. If the number of files supportedby select() needs to be increased it can also be specified here suchas this: –with-cc-opt=”-D FD_SETSIZE=2048″.

–with-ld-opt=parameters — setsadditional parameters that will be used during linking. When using the systemPCRE library under FreeBSD, –with-ld-opt=”-L /usr/local/lib” shouldbe specified.

Example of parameters usage (all of thisneeds to be typed in one line):

./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

After configuration, nginx is compiled andinstalled using make.

CentOS 6.2 实战部署 Nginx+MySQL+PHP http://www.linuxidc.com/Linux/2013-09/90020.htm

使用 Nginx 搭建 WEB 服务器 http://www.linuxidc.com/Linux/2013-09/89768.htm

搭建基于 Linux6.3+Nginx1.2+PHP5+MySQL5.5 的 Web 服务器全过程 http://www.linuxidc.com/Linux/2013-09/89692.htm

CentOS 6.3 下 Nginx 性能调优 http://www.linuxidc.com/Linux/2013-09/89656.htm

CentOS 6.3 下配置 Nginx 加载 ngx_pagespeed 模块 http://www.linuxidc.com/Linux/2013-09/89657.htm

CentOS 6.4 安装配置 Nginx+Pcre+php-fpm http://www.linuxidc.com/Linux/2013-08/88984.htm

Nginx 安装配置使用详细笔记 http://www.linuxidc.com/Linux/2014-07/104499.htm

Nginx 日志过滤 使用 ngx_log_if 不记录特定日志 http://www.linuxidc.com/Linux/2014-07/104686.htm

Nginx 的详细介绍 :请点这里
Nginx 的下载地址 :请点这里

本文永久更新链接地址 :http://www.linuxidc.com/Linux/2015-12/125792.htm

正文完
星哥玩云-微信公众号
post-qrcode
 0
星锅
版权声明:本站原创文章,由 星锅 于2022-01-21发表,共计6754字。
转载说明:除特殊说明外本站文章皆由CC-4.0协议发布,转载请注明出处。
【腾讯云】推广者专属福利,新客户无门槛领取总价值高达2860元代金券,每种代金券限量500张,先到先得。
阿里云-最新活动爆款每日限量供应
评论(没有评论)
验证码
【腾讯云】云服务器、云数据库、COS、CDN、短信等云产品特惠热卖中

星哥玩云

星哥玩云
星哥玩云
分享互联网知识
用户数
4
文章数
19351
评论数
4
阅读量
7990537
文章搜索
热门文章
星哥带你玩飞牛NAS-6:抖音视频同步工具,视频下载自动下载保存

星哥带你玩飞牛NAS-6:抖音视频同步工具,视频下载自动下载保存

星哥带你玩飞牛 NAS-6:抖音视频同步工具,视频下载自动下载保存 前言 各位玩 NAS 的朋友好,我是星哥!...
星哥带你玩飞牛NAS-3:安装飞牛NAS后的很有必要的操作

星哥带你玩飞牛NAS-3:安装飞牛NAS后的很有必要的操作

星哥带你玩飞牛 NAS-3:安装飞牛 NAS 后的很有必要的操作 前言 如果你已经有了飞牛 NAS 系统,之前...
我把用了20年的360安全卫士卸载了

我把用了20年的360安全卫士卸载了

我把用了 20 年的 360 安全卫士卸载了 是的,正如标题你看到的。 原因 偷摸安装自家的软件 莫名其妙安装...
再见zabbix!轻量级自建服务器监控神器在Linux 的完整部署指南

再见zabbix!轻量级自建服务器监控神器在Linux 的完整部署指南

再见 zabbix!轻量级自建服务器监控神器在 Linux 的完整部署指南 在日常运维中,服务器监控是绕不开的...
飞牛NAS中安装Navidrome音乐文件中文标签乱码问题解决、安装FntermX终端

飞牛NAS中安装Navidrome音乐文件中文标签乱码问题解决、安装FntermX终端

飞牛 NAS 中安装 Navidrome 音乐文件中文标签乱码问题解决、安装 FntermX 终端 问题背景 ...
阿里云CDN
阿里云CDN-提高用户访问的响应速度和成功率
随机文章
免费无广告!这款跨平台AI RSS阅读器,拯救你的信息焦虑

免费无广告!这款跨平台AI RSS阅读器,拯救你的信息焦虑

  免费无广告!这款跨平台 AI RSS 阅读器,拯救你的信息焦虑 在算法推荐主导信息流的时代,我们...
开源MoneyPrinterTurbo 利用AI大模型,一键生成高清短视频!

开源MoneyPrinterTurbo 利用AI大模型,一键生成高清短视频!

  开源 MoneyPrinterTurbo 利用 AI 大模型,一键生成高清短视频! 在短视频内容...
【1024程序员】我劝你赶紧去免费领一个AWS、华为云等的主机

【1024程序员】我劝你赶紧去免费领一个AWS、华为云等的主机

【1024 程序员】我劝你赶紧去免费领一个 AWS、华为云等的主机 每年 10 月 24 日,程序员们都会迎来...
安装Black群晖DSM7.2系统安装教程(在Vmware虚拟机中、实体机均可)!

安装Black群晖DSM7.2系统安装教程(在Vmware虚拟机中、实体机均可)!

安装 Black 群晖 DSM7.2 系统安装教程(在 Vmware 虚拟机中、实体机均可)! 前言 大家好,...
仅2MB大小!开源硬件监控工具:Win11 无缝适配,CPU、GPU、网速全维度掌控

仅2MB大小!开源硬件监控工具:Win11 无缝适配,CPU、GPU、网速全维度掌控

还在忍受动辄数百兆的“全家桶”监控软件?后台偷占资源、界面杂乱冗余,想查个 CPU 温度都要层层点选? 今天给...

免费图片视频管理工具让灵感库告别混乱

一言一句话
-「
手气不错
国产开源公众号AI知识库 Agent:突破未认证号限制,一键搞定自动回复,重构运营效率

国产开源公众号AI知识库 Agent:突破未认证号限制,一键搞定自动回复,重构运营效率

国产开源公众号 AI 知识库 Agent:突破未认证号限制,一键搞定自动回复,重构运营效率 大家好,我是星哥,...
仅2MB大小!开源硬件监控工具:Win11 无缝适配,CPU、GPU、网速全维度掌控

仅2MB大小!开源硬件监控工具:Win11 无缝适配,CPU、GPU、网速全维度掌控

还在忍受动辄数百兆的“全家桶”监控软件?后台偷占资源、界面杂乱冗余,想查个 CPU 温度都要层层点选? 今天给...
每年0.99刀,拿下你的第一个顶级域名,详细注册使用

每年0.99刀,拿下你的第一个顶级域名,详细注册使用

每年 0.99 刀,拿下你的第一个顶级域名,详细注册使用 前言 作为长期折腾云服务、域名建站的老玩家,星哥一直...
支付宝、淘宝、闲鱼又双叕崩了,Cloudflare也瘫了连监控都挂,根因藏在哪?

支付宝、淘宝、闲鱼又双叕崩了,Cloudflare也瘫了连监控都挂,根因藏在哪?

支付宝、淘宝、闲鱼又双叕崩了,Cloudflare 也瘫了连监控都挂,根因藏在哪? 最近两天的互联网堪称“故障...
浏览器自动化工具!开源 AI 浏览器助手让你效率翻倍

浏览器自动化工具!开源 AI 浏览器助手让你效率翻倍

浏览器自动化工具!开源 AI 浏览器助手让你效率翻倍 前言 在 AI 自动化快速发展的当下,浏览器早已不再只是...