安装Nginx:
centos 6.9 使用yum 安装 Nginx1.12.1
nginx1.10.2(二零一六.10.18)是流行稳固版,相符线上运维,最新开辟版为1.11.8(二零一四.12.27)
系统版本CentOS6.8
陆拾个人,全数依赖都以系统rpm包,由于epel-release的nginx包不是风靡的安澜版本所以选用源码包安装nginx通过源码编写翻译安装
--prefix= 指向安装目录
[root@jiufengjing ~]# wget http://nginx.org/download/nginx-1.14.0.tar.gz ##下载
Nginx (engine x) 是二个高品质的HTTP和反向代理服务器,也是一个IMAP/POP3/SMTP服务器。Nginx是由伊戈尔·赛Sawyer夫为俄罗丝访谈量第二的Rambler.ru站点(斯洛伐克共和国(The Slovak Republic)语:Рамблер)开采的,第二个通晓版本0.1.0公布于二〇〇二年七月4日。
1、安装编写翻译所需工具
yum groupinstall "Development Tools"
yum install wget
--sbin-path 指向(试行)程序文件(nginx)
[root@jiufengjing ~]# yum -y install pcre pcre-devel zlib zlib-devel openssl-devel openssl gcc gcc-c #安装信任包
其将源代码以类BSD许可证的花样公布,因它的安居、丰裕的成效集、示例配置文件和低系统能源的开销而老品牌。二零一二年三月1日,nginx 1.0.4揭破。
2、到官方网址下载最新的源代码(
cd /usr/local/src
wget
tar zxvf nginx-1.10.2.tar.gz
--conf-path= 指向配置文件(nginx.conf)
[root@jiufengjing ~]# useradd -M -s /sbin/nologin nginx ##创建用户
Nginx是一款轻量级的Web 服务器/反向代理服务器及电子邮件(IMAP/POP3)代理服务器,并在三个BSD-like 左券下发行。其性状是占用内部存款和储蓄器少,并发本事强,事实上nginx的产出工夫确实在同品种的网页服务器中显现较好,中华人民共和国次大陆使用nginx网址客户有:百度、京东、和讯、微博、Tencent、Tmall等。
3、安装看重包
yum install zlib-devel openssl-devel pcre-devel
zlib:
为nginx提供gzip模块,须求zlib库援助,传输数据打包,省流量(但消功耗源)
openssl: 为nginx提供ssl功能
pcre: 为帮衬地点重写rewrite成效
--error-log-path= 指向错误日志目录
[root@jiufengjing ~]# tar zxf nginx-1.14.0.tar.gz -C /usr/src/ ##解压
Nginx官网:
4、创设用来运作nginx的客商及组
groupadd -g 58 www
useradd -u 58 -g 58 -M www -s /sbin/nologin
-g参数为www客商钦点了多少个组。-M参数有限支撑其不 自动生成home目录。
--pid-path= 指向pid文件(nginx.pid)
[root@jiufengjing ~]# cd /usr/src/nginx-1.14.0/
Nginx中文手册:
5、编写翻译源代码
先使用./configure –help 查看编写翻译扶持:
笔者的线上编写翻译参数,暗许开启的不用写
./configure --with-http_ssl_module --with-http_v2_module
--with-http_realip_module --with-http_stub_status_module
--with-stream --with-stream_ssl_module --with-pcre
./configure --help
--help print this message
--prefix=PATH set installation prefix
#Nginx安装的根路线,默认为 /usr/local/nginx。
--sbin-path=PATH set nginx binary pathname
#钦赐nginx二进制文件的门路,默以为PATH/sbin/nginx。
--modules-path=PATH set modules path #Perl模块地点
--conf-path=PATH set nginx.conf pathname
#设定nginx配置文件地方,默感觉PATH/conf/nginx.conf。
--error-log-path=PATH set error log pathname
#错误文件路线,默以为 PATH/logs/error.log。
--pid-path=PATH set nginx.pid pathname #
master进度pid写入的公文地方,常常在var/run下,默感觉PATH/logs/nginx.pid。
--lock-path=PATH set nginx.lock pathname
#分享存款和储蓄器互斥锁文件路线
--user=USER set non-privileged user for worker
processes #点名程序运维时的非特权客商
--group=GROUP set non-privileged group for worker
processes #点名程序运维时的非特权客户组
--build=NAME set build name #编写翻译名称
--builddir=DIR set build directory #针对编写翻译目录
--with-select_module enable select module
允许或不允许开启SELECT形式,即使configure未有找到确切的情势,比如,kqueue(sun
os)、epoll(linux kenel 2.6 )、rtsig(实时时域信号)
--without-select_module disable select module
禁止使用select模块帮助
--with-poll_module enable poll module
启用poll模块帮助(作用与select一样,与select天性相同,为一种轮询方式,不引入在高载情形下利用)
--without-poll_module disable poll module
禁止使用poll模块支持
--with-threads enable thread pool support
--with-file-aio enable file AIO support
#为freeBSD4.3 和linux2.6.22 系统启用异步io
--with-ipv6 enable IPv6 support
#启用ipv6支持
#暗中同意禁止使用的模块
--with-http_ssl_module enable ngx_http_ssl_module
#使扶助https诉求,需已设置openssl
--with-http_v2_module enable ngx_http_v2_module
#启用HTTP V2
--with-http_realip_module enable ngx_http_realip_module
#此模块辅助显得真实来源IP地址,主要用来NGINX做前端负载均衡服务器使用
--with-http_addition_module enable
ngx_http_addition_module
#输出过滤器,使您可以预知在伸手经过多个location前或后时在该location本人增加内容
--with-http_xslt_module enable ngx_http_xslt_module
#本条模块是一个过滤器,它能够由此XSLT模板转变XML应答
--with-http_xslt_module=dynamic enable dynamic
ngx_http_xslt_module
--with-http_image_filter_module enable
ngx_http_image_filter_module
#图像过滤器,在将图像投递到客商早先开展处理(须求libgd库)
--with-http_image_filter_module=dynamic
enable dynamic
ngx_http_image_filter_module
--with-http_geoip_module enable ngx_http_geoip_module
#创办基于与马克斯Mind 吉优IP匹配的顾客端地址
--with-http_geoip_module=dynamic enable dynamic
ngx_http_geoip_module
--with-http_sub_module enable ngx_http_sub_module
#这么些模块能够能够在nginx的应对中搜寻并替换文本
--with-http_dav_module enable ngx_http_dav_module
#为文件和目录钦命权限,限制不一样类型的顾客对于页面有不相同的操作权限
--with-http_flv_module enable ngx_http_flv_module
#这一个模块协助对FLV(flash)文件的拖动播放
--with-http_mp4_module enable ngx_http_mp4_module
#支撑H.264/AAC文件为伪流媒体
--with-http_gunzip_module enable ngx_http_gunzip_module
#对此不扶植gzip编码的顾客,该模块用于为顾客解压缩预压缩内容
--with-http_gzip_static_module enable
ngx_http_gzip_static_module
#以此模块在一个预压缩文件传送到展开Gzip压缩的顾客端此前检查是还是不是已经存在以“.gz”结尾的压缩文件,那样能够幸免文件被再次压缩
--with-http_auth_request_module enable
ngx_http_auth_request_module
--with-http_random_index_module enable
ngx_http_random_index_module #从目录中选拔一个自由主页
--with-http_secure_link_module enable
ngx_http_secure_link_module
#该模块提供一种体制,它会将三个哈希值链接到三个url中,由此,独有那几个运用科学的密码能够总计链接
--with-http_degradation_module enable
ngx_http_degradation_module #同意在内部存款和储蓄器不足的情事下回到204或444码
--with-http_slice_module enable ngx_http_slice_module
--with-http_stub_status_module enable
ngx_http_stub_status_module
#猎取部分nginx的运维处境,输出的意况音讯可利用KugaOdysseyDtool或近乎的工具绘制作而成图
#私下认可启用的模块
--without-http_charset_module disable
ngx_http_charset_module #再一次编码web页面
--without-http_gzip_module disable ngx_http_gzip_module
#同-with-http_gzip_static_module功效雷同
--without-http_ssi_module disable ngx_http_ssi_module
#提供在输入端管理管理服务器包涵文件(SSI)的过滤器,方今援助SSI命令的列表是不完全的
--without-http_userid_module disable ngx_http_userid_module
#用来管理用来分明客商端后续央求的cookies
--without-http_access_module disable ngx_http_access_module
#供了几个简练的依据主机的访问调节。允许/拒绝基于ip地址
--without-http_auth_basic_module disable
ngx_http_auth_basic_module
#能够利用客商名和密码基于http基本注明方式来维护你的站点或其部分内容
--without-http_autoindex_module disable
ngx_http_autoindex_module
#自动生成目录列表,只在ngx_http_index_module模块未找到索引文件时发出央求。
--without-http_geo_module disable ngx_http_geo_module
#创制一些变量,其值正视于顾客端的IP地址
--without-http_map_module disable ngx_http_map_module
#动用任意的键/值对安装配置变量
--without-http_split_clients_module disable
ngx_http_split_clients_module
#用来基于有个别准绳划分顾客。条件如:ip地址、报头、cookies等等
--without-http_referer_module disable
ngx_http_referer_module
#用来过滤须要,拒绝报头中Referer值不科学的伏乞
--without-http_rewrite_module disable
ngx_http_rewrite_module
#允许使用正则表达式改造U福睿斯I,何况依据变量来转向以至选取安插
--without-http_proxy_module disable ngx_http_proxy_module
#至于代理服务器
--without-http_fastcgi_module disable
ngx_http_fastcgi_module #同意Nginx 与法斯特CGI
进度并行,并透过传递参数来调节法斯特CGI 过程工作。
--without-http_uwsgi_module disable ngx_http_uwsgi_module
#用来利用uwsgi公约,uWSGI服务器相关
--without-http_scgi_module disable ngx_http_scgi_module
#用来启用SCGI协议匡助,SCGI公约是CGI共商的代替。
--without-http_memcached_module disable
ngx_http_memcached_module #用来提供轻易的缓存,以加强系统成效
--without-http_limit_conn_module disable
ngx_http_limit_conn_module
#同意你对此一个地方进行连接数的界定用一个加以的session或一个特定的平地风波
--without-http_limit_req_module disable
ngx_http_limit_req_module
#同意你对于多个地方进行呼吁数量的界定用叁个加以的session或多个一定的风云
--without-http_empty_gif_module disable
ngx_http_empty_gif_module
#在内部存储器中常驻了一个1*1的透明GIF图像,能够被那么些便捷的调用
--without-http_browser_module disable
ngx_http_browser_module #用来创制依赖于诉求报头的值
--without-http_upstream_hash_module
disable
ngx_http_upstream_hash_module #用来轻巧的负荷均衡
--without-http_upstream_ip_hash_module
disable
ngx_http_upstream_ip_hash_module
--without-http_upstream_least_conn_module
disable
ngx_http_upstream_least_conn_module
--without-http_upstream_keepalive_module
disable
ngx_http_upstream_keepalive_module
--without-http_upstream_zone_module
disable
ngx_http_upstream_zone_module
--with-http_perl_module enable ngx_http_perl_module
#以此模块允许nginx使用SSI调用perl或直接实践perl(使用会稳中有降品质)
--with-http_perl_module=dynamic enable dynamic
ngx_http_perl_module
--with-perl_modules_path=PATH set Perl modules path
#设定perl模块路线
--with-perl=PATH set perl binary pathname
#设定perl库文件路线
--http-log-path=PATH set http access log pathname
#设定access log路径
--http-client-body-temp-path=PATH set path to store http client
request body temporary files #设定http客户端恳求有的时候文件路径
--http-proxy-temp-path=PATH set path to store http proxy
temporary files #设定http代理有的时候文件路线
--http-fastcgi-temp-path=PATH set path to store http fastcgi
temporary files #设定http fastcgi一时文件路线
--http-uwsgi-temp-path=PATH set path to store http uwsgi
temporary files #设定http uwsgi一时文件路线
--http-scgi-temp-path=PATH set path to store http scgi
temporary files #设定http scgi一时文件路线
--without-http disable HTTP server
#统统禁止使用http模块,如若只想辅助mall,能够应用此项设置
--without-http-cache disable HTTP cache
#在采纳upstream模块时,nginx可以配置本地缓存内容,此选项可禁止使用缓存
--with-mail enable POP3/IMAP4/SMTP proxy module
#激活POP3/IMAP4/SMTP代理模块,暗中同意未激活
--with-mail=dynamic enable dynamic POP3/IMAP4/SMTP
proxy module
--with-mail_ssl_module enable ngx_mail_ssl_module
#SMTP能够利用SSL/TLS.配置已经定义了HTTP
SSL模块,但是不接济客商端证书检验
--without-mail_pop3_module disable ngx_mail_pop3_module
#启用mail模块后,单独禁止使用pop3模块
--without-mail_imap_module disable ngx_mail_imap_module
#启用mail模块后,单独禁止使用imap模块
--without-mail_smtp_module disable ngx_mail_smtp_module
#启用mail模块后,单独禁止使用smtp模块
--with-stream enable TCP/UDP proxy module
--with-stream=dynamic enable dynamic TCP/UDP proxy
module
--with-stream_ssl_module enable ngx_stream_ssl_module
--without-stream_limit_conn_module disable
ngx_stream_limit_conn_module
--without-stream_access_module disable
ngx_stream_access_module
--without-stream_upstream_hash_module
disable
ngx_stream_upstream_hash_module
--without-stream_upstream_least_conn_module
disable
ngx_stream_upstream_least_conn_module
--without-stream_upstream_zone_module
disable
ngx_stream_upstream_zone_module
--with-google_perftools_module enable
ngx_google_perftools_module #调解用,深入分析程序品质瓶颈
--with-cpp_星彩网app下载,test_module enable ngx_cpp_test_module
--add-module=PATH enable external module
#启用外界模块协助
--add-dynamic-module=PATH enable dynamic external module
#编写翻译相关的参数
--with-cc=PATH set C compiler pathname
#若果想设置贰个不在暗中同意path下的c编译器
--with-cpp=PATH set C preprocessor pathname
#设置c预管理器的相对路线
--with-cc-opt=OPTIONS set additional C compiler options
#设置C编写翻译器参数
--with-ld-opt=OPTIONS set additional linker options
#带有连接库的门径和平运动作路径
--with-cpu-opt=CPU build for the specified CPU, valid
values:pentium, pentiumpro, pentium3, pentium4,athlon, opteron, sparc32,
sparc64, ppc64 #点名编写翻译的CPU
--without-pcre disable PCRE library usage
#禁用pcre库
--with-pcre force PCRE library usage
#启用pcre库
--with-pcre=DIR set path to PCRE library sources
#本着pcre库文件目录
--with-pcre-opt=OPTIONS set additional build options for
PCRE #在编写翻译时为pcre库设置附加参数
--with-pcre-jit build PCRE with JIT compilation
support
--with-md5=DIR set path to md5 library sources
#本着md5库文件目录
--with-md5-opt=OPTIONS set additional build options for md5
#在编写翻译时为md5库设置附加参数
--with-md5-asm use md5 assembler sources
#使用md5汇编源
--with-sha1=DIR set path to sha1 library sources
#指向sha1库目录
--with-sha1-opt=OPTIONS set additional build options for
sha1 #在编写翻译时为sha1库设置附加参数
--with-sha1-asm use sha1 assembler sources
#使用sha1汇编源
--with-zlib=DIR set path to zlib library sources
#指向zlib库目录
--with-zlib-opt=OPTIONS set additional build options for
zlib #在编写翻译时为zlib设置附加参数
--with-zlib-asm=CPU use zlib assembler sources
optimized for the specified CPU, valid values: pentium, pentiumpro
#为钦定的CPU使用zlib汇编源举办优化
--with-libatomic force libatomic_ops library usage
# 为原子内部存储器的翻新操作的兑现提供二个架构
--with-libatomic=DIR set path to libatomic_ops library
sources #指向libatomic_ops安装目录
--with-openssl=DIR set path to OpenSSL library sources
#指向openssl安装目录
--with-openssl-opt=OPTIONS set additional build options for
OpenSSL #在编写翻译时为openssl设置附加参数
--with-debug enable debug logging #启用debug日志
--lock-path= 指向lock文件(nginx.lock)(安装文件锁定,幸免安装文件被外人利用,或本人误操作。)
[root@jiufengjing nginx-1.14.0]# ./configure --prefix=/usr/local/nginx --user=nginx --group=nginx --with-http_ssl_module --with-http_stub_status_module &&make
一、安装前准备
6,编译汇总
Configuration summary
--user= 钦命程序运维时的非特权客商
&&make install ##编写翻译安装
1.安装PCRE
--group= 钦赐程序运行时的非特权顾客组
Nginx 模块必得在编译时就展开分选,近日不扶持在运行时开展模块采用。在编写翻译时,可以运用 ./configure --help查看编译援助,会提供有关的编写翻译选项。必要小心的一些正是大好多编译选项都有暗中认可值,能够钦定也得以不钦赐。别的编写翻译选项通常以 --with起初的都是默许不会编译的,你须要用到哪边效果就足以钦赐其编译选项;另外以 --without此前的选项表示这几个模块都以默许会编写翻译的,如若手动钦赐使用以 --without带头的选项表示您将会关闭此成效模块,慎用。
1)Nginx在编写翻译时,运转时期与路线相关的各个参数
--prefix=PATH #本着安装目录
--sbin-path=PATH #本着(实行)程序文件(nginx)
--conf-path=PATH #本着配置文件(nginx.conf)
--error-log-path=PATH #指向错误日志目录
--http-log-path=PATH #钦命访谈复制目录
--pid-path=PATH #指向pid文件(nginx.pid)
--lock-path=PATH #指向lock文件(nginx.lock)(安装文件锁定,幸免安装文件被外人使用,或和煦误操作。)
--builddir=PATH #针对编译目录
--http-client-body-temp-path=PATH #设定http客商端央浼有的时候文件路线
--http-proxy-temp-path=PATH #设定http代理有时文件路线
--http-fastcgi-temp-path=PATH #设定http fastcgi不时文件路线
--http-uwsgi-temp-path=PATH #设定http uwsgi有时文件路线
--http-scgi-temp-path=PATH #设定http scgi不时文件路线
2)一些权力、http、mail及信任库模块
--user=USER #钦点程序运营时的非特权客户
--group=USER #钦赐程序运营时的非特权顾客组
--with-rtsig_module #启用rtsig模块帮忙(实时复信号)
--with-file-aio #启用file aio帮助(一种APL文件传输格式)
--with-ipv6 #启用ipv6支持
--with-select_module #启用select模块支持(一种轮询方式,不推荐在高载境况下行使)禁止使用:--without-select_module
--with-poll_module #启用poll模块扶持(作用与select相同,与select天性同样,为一种轮询格局,不引入在高载境遇下使用)
--with-http_ssl_module #启用扶持https诉求,需已设置openssl
--with-http_realip_module #启用ngx_http_realip_module支持(这么些模块允许从呼吁标头退换客商端的IP地址值,默许为关)
--with-http_addition_module #启用ngx_http_addition_module扶持(作为七个输出过滤器,帮助不完全缓冲,办事处分响应要求)
--with-http_xslt_module #启用ngx_http_xslt_module扶植(过滤转变XML恳求)
--with-http_image_filter_module #启用协理传输JPEG/GIF/PNG 图片过滤,暗中同意为不启用,gd库要用到
--with-http_sub_module #启用ngx_http_sub_module扶助(允许用部分任何文件替换nginx响应中的一些文书)
--with-http_dav_module #启用ngx_http_dav_module扶持(增添PUT,DELETE,MKCOL:创设群集,COPY和MOVE方法)
--with-http_flv_module #启用ngx_http_flv_module扶助(提供寻求内部存款和储蓄器使用基于时间的偏移量文件)
--with-http_gzip_static_module #启用ngx_http_gzip_static_module扶植(在线实时压缩输出数据流)
--with-http_random_index_module #启用ngx_http_random_index_module支持(从目录中任性选择三个目录索引)
--with-http_secure_link_module #启用ngx_http_secure_link_module扶持(计算和检讨必要所需的黄山毛峰链接网站)
--with-http_degradation_module #启用ngx_http_degradation_module协理(允许在内部存款和储蓄器不足的图景下再次来到204或444码)
--with-http_stub_status_module #启用ngx_http_stub_status_module协助(获取nginx自上次起步以来的办事情景)
--with-http_perl_module #启用ngx_http_perl_module接济(该模块使nginx能够一向利用perl或透过ssi调用perl)
--with-mail #启用POP3/IMAP4/SMTP代理模块扶持
--with-mail_ssl_module #启用ngx_mail_ssl_module支持
--add-module= #启用外界模块帮衬
--with-cpu-opt= #点名编写翻译的CPU,可用的值为: pentium,opteron, amd64, sparc32, sparc64, ppc64等
--with-pcre #启用pcre库(暗中同意会自动去找rpm包安装的pcre库文件以至模块)
--with-pcre= #本着pcre库文件目录(假设是源码安装就需求内定,rpm包安装就没有需求钦命了)
--with-pcre-opt= #在编写翻译时为pcre库设置附加参数
--with-perl_modules_path= ##设定perl模块路线
--with-perl= #设定perl库文件路线
--with-debug #启用debug日志
PCRE(Perl Compatible Regular Expressions)是一个Perl库,包罗 perl 包容的正则表明式库。
7,编写翻译安装
编译
make
安装
make install
加入PATH
ln -s /usr/local/nginx/sbin/nginx /usr/sbin/nginx
核算版本音讯
123456 nginx -V
nginx version: nginx/1.10.2
built by gcc 4.4.7 20120313 (Red
Hat 4.4.7-17) (GCC)
built with OpenSSL 1.0.1e-fips 11 Feb 2013
TLS SNI support enabled
configure arguments: --with-http_ssl_module --with-http_v2_module
--with-http_realip_module --with-http_stub_status_module
--with-stream --with-stream_ssl_module --with-pcre
--builddir= 指向编写翻译目录
--without-http #该模块用于http server功用
--without-http-cache #该模块用于http cache功用
--without-http_charset_module #该模块用于重新编码web页面,但只好是一个趋势--服务器端到客商端,何况独有三个字节的编码能够被重复编码
--without-http_gzip_module #该模块同-with-http_gzip_static_module作用雷同
--without-http_ssi_module #该模块提供了三个在输入端处理管理服务器包罗文件(SSI)的过滤器,最近援助SSI命令的列表是不完全的
--without-http_userid_module #该模块用来拍卖用来分明客商端后续要求的cookies
--without-http_access_module #该模块提供了二个简易的基于主机的访谈调节。允许/拒绝基于ip地址
--without-http_auth_basic_module #该模块是足以应用客商名和密码基于http基本注明方法来有限扶植你的站点或其有些剧情
--without-http_autoindex_module #该模块用于自动生成目录列表,只在ngx_http_index_module模块未找到索引文件时发出须要
--without-http_geo_module #该模块用于创制一些变量,其值重视于客商端的IP地址
--without-http_map_module #该模块用于采纳猖狂的键/值对安装配置变量
--without-http_referer_module #该模块用来过滤诉求,拒绝报头中Referer值不科学的伸手
--without-http_rewrite_module #该模块允许使用正则表达式改动UPAJEROI
--without-http_proxy_module #该模块用于代理服务器
--without-http_fastcgi_module #该模块允许Nginx与法斯特CGI进程并行,并透过传递参数来调节法斯特CGI进程专业,法斯特CGI一个常驻型的共用网关接口
--without-http_uwsgi_module #该模块启用uwsgi左券,uWSGI服务器相关
--without-http_scgi_module #该模块用来启用SCGI公约援救,SCGI合同是CGI协商的代替,它是一种应用程序与HTTP服务接口典型
--without-http_memcached_module #该模块用来提供轻巧的缓存,以加强系统效用
--without-http_limit_zone_module #该模块能够本着条件,举办对话的面世连接数调整
--without-http_limit_req_module #该模块允许你对此二个地方举行呼吁数量的限定用二个加以的session或二个一定的风云
--without-http_empty_gif_module #该模块在内部存款和储蓄器中常驻了二个1*1的透明GIF图像,可以被百般飞速的调用)
--without-http_browser_module #该模块用来创设信任于央求报头的值
--without-http_split_clients_module #该模块用来基于有些原则划分客户。条件如:ip地址、报头、cookies等等
--without-http_upstream_ip_hash_module #该模块用于负载均衡
--without-mail_pop3_module #该模块用于pop3磋商,邮局契约
--without-mail_imap_module #该模块用于邮件的imap合同,邮件接收合同
--without-mail_smtp_module #该模块用于smtp公约,邮件发送合同
[root@jiufengjing nginx-1.14.0]# ln -s /usr/local/nginx/sbin/nginx /usr/local/sbin/ ###创立软链接,优化命令寻觅路线
[root@jiufengjing nginx-1.14.0]# ls -l /usr/local/sbin/nginx
lrwxrwxrwx 1 root root 27 Aug 15 03:09 /usr/local/sbin/nginx -> /usr/local/nginx/sbin/nginx
[root@jiufengjing nginx-1.14.0]# cd
[root@jiufengjing ~]# nginx -t ##反省布置
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
[root@jiufengjing ~]# nginx ##起头服务
[root@jiufengjing ~]# netstat -utpln |grep 80
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 13592/nginx: master
行使nginx服务运转脚本:
[root@jiufengjing ~]# vim /etc/init.d/nginx
(1)#!/bin/bash
# chkconfig: 35 99 20
# description: Nginx Server Control Script
NP="/usr/local/nginx/sbin/nginx"
NPF="/usr/local/nginx/logs/nginx.pid"
case "$1" in ##$1表示第一职位变量,$0表示脚本小编
start)
$NP;
if [ $? -eq 0 ]
then
echo "nginx is starting!! "
fi
;;
stop)
kill -s QUIT $(cat $NPF)
if [ $? -eq 0 ]
then
echo "nginx is stopping!! "
fi
;;
restart)
$0 stop
$0 start
;;
reload)
kill -s HUP $(cat $NPF)
if [ $? -eq 0 ]
then
echo "nginx config file is reload! "
fi
;;
*)
echo "Usage: $0 {start|stop|restart|reload}"
exit 1
esac
exit 0
:wq
(2)#!/bin/bash
# chkconfig: - 30 21
# description: http service.
# Source Function Library
. /etc/init.d/functions
# Nginx Settings
NGINX_SBIN="/usr/local/nginx/sbin/nginx"
NGINX_CONF="/usr/local/nginx/conf/nginx.conf"
NGINX_PID="/usr/local/nginx/logs/nginx.pid"
RETVAL=0
prog="Nginx"
start()
{
echo -n $"Starting $prog: "
mkdir -p /dev/shm/nginx_temp
daemon $NGINX_SBIN -c $NGINX_CONF
RETVAL=$?
echo
return $RETVAL
}
stop()
{
echo -n $"Stopping $prog: "
killproc -p $NGINX_PID $NGINX_SBIN -TERM
rm -rf /dev/shm/nginx_temp
RETVAL=$?
echo
return $RETVAL
}
reload()
{
echo -n $"Reloading $prog: "
killproc -p $NGINX_PID $NGINX_SBIN -HUP
RETVAL=$?
echo
return $RETVAL
}
restart()
{
stop
start
}
configtest()
{
$NGINX_SBIN -c $NGINX_CONF -t
return 0
}
case "$1" in
start)
start
;;
stop)
stop
;;
reload)
reload
;;
restart)
restart
;;
configtest)
configtest
;;
*)
echo $"Usage: $0 {start|stop|reload|restart|configtest}"
RETVAL=1
esac
[root@jiufengjing ~]# chkconfig --add nginx ##加多系统服务
[root@jiufengjing ~]# chmod x /etc/init.d/nginx ##授权
[root@jiufengjing ~]# /etc/init.d/nginx restart ##重启验证
nginx is stopping!!
nginx is starting!!
[root@jiufengjing ~]# netstat -utpln |grep nginx ##翻开nginx监听端口
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 14036/nginx: master
做客验证
[root@jiufengjing ~]# elinks --dump 192.168.100.102
-dump:将HTML文书档案以纯文本的诀窍打字与印刷到标准输出设备;
Welcome to
nginx!
If you see this page, the
nginx web server is successfully installed and
working. Further
configuration is required.
For online documentation and
support please refer to [1]nginx.org.
Commercial support is
available at [2]nginx.com.
Thank you for using nginx.
References
Visible
links
1.
2.
PCRE被广泛使用在相当多开源软件之中,最出名的实在Apache HTTP服务器和PHP脚本语言、景逸SUV脚本语言,别的,正如从其名字所能见到的,PCRE也是perl语言的缺省正则库。
8,轻便陈设
自个儿这一次珍视运用到tcp四层负载,后续大概波及到https
http2等,所以编写翻译时增多了那个参数。
nginx.conf配置如下:
user www www;
worker_processes auto;
worker_cpu_affinity auto;
error_log logs/error.log error;
pid logs/nginx.pid;
worker_rlimit_nofile 653600;
events
{
use epoll;
worker_connections 655350;
}
stream {
upstream server {
hash $remote_addr consistent;
server 172.16.1.11:8081 weight=1 max_fails=3
fail_timeout=10s;
server 172.16.1.22:8081 weight=1 max_fails=3
fail_timeout=10s;
}
server {
listen 8081;
proxy_connect_timeout 1s;
proxy_timeout 3s;
proxy_pass server;
}
}
--with-rtsig_module 启用rtsig模块帮忙(实时随机信号)
官网:
CentOS 7.2下编写翻译安装PHP7.0.10 MySQL5.7.14 Nginx1.10.1 http://www.linuxidc.com/Linux/2016-09/134804.htm
--with-select_module 启用select模块扶植(一种轮询情势,不推荐在高载情状下利用)禁止使用:–without-select_module
[root@001 ~]# yum install pcre-devel pcre -y
搭建基于Linux6.3 Nginx1.2 PHP5 MySQL5.5的Web服务器全经过 http://www.linuxidc.com/Linux/2013-09/89692.htm
--with-poll_module 启用poll模块补助(功效与select一样,与select特性一样,为一种轮询形式,不引入在高载碰着下行使)
2.安装
CentOS 6.3下Nginx质量调优 http://www.linuxidc.com/Linux/2013-09/89656.htm
--with-file-aio 启用file aio援助(一种APL文件传输格式)
OpenSSL 是贰个安然还是套接字层密码库,囊括首要的密码算法、常用的密钥和证书封装管理职能及SSL契约,并提供丰盛的应用程序供测量检验或其余指标接纳。#nginx加密入眼是信任openssl
CentOS 6.3下配置Nginx加载ngx_pagespeed模块 http://www.linuxidc.com/Linux/2013-09/89657.htm
--with-ipv6 启用ipv6支持
官网:
CentOS 6.4安装配置Nginx Pcre php-fpm http://www.linuxidc.com/Linux/2013-08/88984.htm
--with-http_ssl_module 启用ngx_http_ssl_module援助(使帮忙https央浼,需已设置openssl)
[root@001 ~]# yum install openssl openssl-devel -y
Nginx安装配备利用详细笔记 http://www.linuxidc.com/Linux/2014-07/104499.htm
--with-http_realip_module 启用ngx_http_realip_module协助(这些模块允许从呼吁标头改造顾客端的IP地址值,默认为关)
3.设置编写翻译器
Nginx日志过滤 使用ngx_log_if不记录特定日志 http://www.linuxidc.com/Linux/2014-07/104686.htm
--with-http_addition_module 启用ngx_http_addition_module援助(作为二个出口过滤器,扶助不完全缓冲,总局分响应乞请)
GCC(GNU Compiler Collection,GNU编写翻译器套件),是由 GNU 开采的编制程序语言编写翻译器。它是以GPL许可证所批发的自由软件,也是 GNU陈设的主要部分。GCC原来作为GNU操作系统的合法编写翻译器,现已被相当多类Unix操作系统(如Linux、BSD、Mac OS X等)选拔为行业内部的编写翻译器,GCC一样适用于微软的Windows。GCC是自由软件进程发展中的盛名例子,由自由软件基金会以GPL公约公布。
Nginx的500,502,504破绽相当多解决办法 http://www.linuxidc.com/Linux/2015-03/115507.htm
--with-http_xslt_module 启用ngx_http_xslt_module支持(过滤调换XML诉求)
[root@001 ~]# yum install gcc gcc-c -y
CentOS 7 编写翻译安装Nginx1.10.2 脚本运转退步化解思路 http://www.linuxidc.com/Linux/2017-01/139794.htm
--with-http_image_filter_module 启用ngx_http_image_filter_module扶持(传输JPEG/GIF/PNG 图片的三个过滤器)(默以为不启用。gd库要运用)
[root@001 ~]# yum install wget -y
Nginx
的详尽介绍:请点这里
Nginx
的下载地址:请点这里
--with-http_geoip_module 启用ngx_http_geoip_module支持(该模块创立基于与马克斯Mind 吉优IP二进制文件相配的客商端IP地址的ngx_http_geoip_module变量)
4.增加顾客
正文永远更新链接地址:http://www.linuxidc.com/Linux/2017-01/139965.htm
--with-http_sub_module 启用ngx_http_sub_module支持(允许用一些别的文件替换nginx响应中的一些文件)
[root@001 ~]# useradd nginx -s /sbin/nologin -M
--with-http_dav_module 启用ngx_http_dav_module支持(扩张PUT,DELETE,MKCOL:制造集合,COPY和MOVE方法)默许情形下为关闭,需编写翻译开启
(关闭防火墙及selinux)
--with-http_flv_module 启用ngx_http_flv_module援救(提供寻求内部存款和储蓄器使用基于时间的偏移量文件)
二、安装 Nginx
--with-http_gzip_static_module 启用ngx_http_gzip_static_module帮助(在线实时压缩输出数据流)
[root@001 ~]# wget
--with-http_random_index_module 启用ngx_http_random_index_module协助(从目录中随便选取一个目录索引)
[root@001 ~]# tar xf nginx-1.12.1.tar.gz -C /usr/local/src/
--with-http_secure_link_module 启用ngx_http_secure_link_module援救(总计和检查必要所需的安全链接网站)
[root@001 ~]# cd !$
--with-http_degradation_module 启用ngx_http_degradation_module扶植(允许在内部存款和储蓄器不足的情事下回到204或444码)
[root@001 src]# cd nginx-1.12.1
--with-http_stub_status_module 启用ngx_http_stub_status_module支持(获取nginx自上次开头以来的做事情形)
[root@001 nginx-1.12.1]# ./configure --prefix=/usr/local/nginx --user=nginx --group=nginx --with-http_ssl_module --with-http_stub_status_module
--without-http_charset_module 禁用ngx_http_charset_module支持(重新编码web页面,但不得不是二个样子–服务器端到顾客端,並且只有一个字节的编码能够被另行编码)
--配置参数表明:
--without-http_gzip_module 禁用ngx_http_gzip_module帮助(该模块同-with-http_gzip_static_module功效雷同)
--prefix=/usr/local/nginx #设置路线
--without-http_ssi_module 禁用ngx_http_ssi_module协理(该模块提供了二个在输入端管理管理服务器包涵文件(SSI)的过滤器,前段时间支撑SSI命令的列表是不完整的)
--user=nginx #进度客户
--without-http_userid_module 禁用ngx_http_userid_module帮助(该模块用来管理用来明确客商端后续需要的cookies)
--group=nginx #进程组
--without-http_access_module 禁用ngx_http_access_module扶持(该模块提供了二个大约的基于主机的访谈调整。允许/拒绝基于ip地址)
--with-http_ssl_module #激活状态新闻
--without-http_auth_basic_module禁用ngx_http_auth_basic_module(该模块是足以选取客户名和密码基于http基本注脚方法来珍视你的站点或其部分剧情)
--with-http_stub_status_module #激活ssl功能 ---越多参数详解见文章尾巴部分
--without-http_autoindex_module 禁用disable ngx_http_autoindex_module扶助(该模块用于自动生成目录列表,只在ngx_http_index_module模块未找到索引文件时发出央求。)
--查看编写翻译参数使用 -V:
--without-http_geo_module 禁用ngx_http_geo_module援助(创立一些变量,其值信任于客商端的IP地址)
[root@001 sbin]# ./nginx -V
--without-http_map_module 禁用ngx_http_map_module扶持(使用大肆的键/值对设置配置变量)
nginx version: nginx/1.12.1
--without-http_split_clients_module 禁用ngx_http_split_clients_module协理(该模块用来基于某个准绳划分客户。条件如:ip地址、报头、cookies等等)
built by gcc 4.4.7 20120313 (Red Hat 4.4.7-18) (GCC)
--without-http_referer_module 禁用disable ngx_http_referer_module扶助(该模块用来过滤诉求,拒绝报头中Referer值不科学的哀告)
built with OpenSSL 1.0.1e-fips 11 Feb 2013
--without-http_rewrite_module 禁用ngx_http_rewrite_module扶助(该模块允许利用正则表达式改变UENVISIONI,而且依据变量来转向以至选用安顿。要是在server品级设置该采纳,那么她们将要location在此之前生效。若是在location还应该有更进一竿的重写法则,location部分的平整依旧会被实施。假使这几个UCRUISERI重写是因为location部分的条条框框产生的,那么 location部分会再度被试行作为新的U奥迪Q5I。 那个循环会实行11回,然后Nginx会重回叁个500荒谬。)
TLS SNI support enabled
--without-http_proxy_module 禁用ngx_http_proxy_module辅助(有关代理服务器)
configure arguments: --prefix=/usr/local/nginx --user=nginx --group=nginx --with-http_ssl_module --with-http_stub_status_module
--without-http_fastcgi_module 禁用ngx_http_fastcgi_module扶助(该模块允许Nginx 与法斯特CGI 进程并行,并经过传递参数来决定法斯特CGI 进度专门的学问。 )法斯特CGI一个常驻型的公家网关接口。
[root@001 nginx-1.12.1]# make && make install
--without-http_uwsgi_module 禁用ngx_http_uwsgi_module帮忙(该模块用来医用uwsgi左券,uWSGI服务器相关)
[root@001 nginx-1.12.1]# cd /usr/local/nginx/sbin/
--without-http_scgi_module 禁用ngx_http_scgi_module帮忙(该模块用来启用SCGI左券支持,SCGI合同是CGI合同的代替。它是一种应用程序与HTTP服务接口标准。它稍微像FastCGI但她的宏图 更便于完毕。)
[root@001 sbin]# ./nginx #启动
--without-http_memcached_module 禁用ngx_http_memcached_module援助(该模块用来提供轻易的缓存,以增加系统作用)
#无报错则编写翻译安装成功
--without-http_limit_zone_module 禁用ngx_http_limit_zone_module支持(该模块能够本着条件,举办对话的面世连接数调整)
--without-http_limit_req_module 禁用ngx_http_limit_req_module扶持(该模块允许你对此多个地方进行呼吁数量的限制用一个加以的session或多个一定的平地风波)
--without-http_empty_gif_module 禁用ngx_http_empty_gif_module扶持(该模块在内部存储器中常驻了贰个1*1的晶莹GIF图像,能够被那么些急迅的调用)
三、将nginx参与到系统境况变量及service形式处理服务
--without-http_browser_module 禁用ngx_http_browser_module帮忙(该模块用来创立重视于央求报头的值。假如浏览器为modern ,则$modern_browser等于modern_browser_value指令分配的值;假设浏览器为old,则$ancient_browser等于 ancient_browser_value指令分配的值;如若浏览器为 MSIE中的放肆版本,则 $msie等于1)
1.将nginx加入到系统情状变量
--without-http_upstream_ip_hash_module 禁用ngx_http_upstream_ip_hash_module扶助(该模块用于轻便的载重均衡)
[root@001 sbin]# vim /etc/profile #在/etc/profile 中参与如下内容
--with-http_perl_module 启用ngx_http_perl_module援救(该模块使nginx能够直接使用perl或透过ssi调用perl)
export NGINX_HOME=/usr/local/nginx
export PATH=$PATH:$NGINX_HOME/sbin
--with-perl_modules_path= 设定perl模块路线
[root@001 sbin]# source /etc/profile #实践source /etc/profile ,使配置文件生效。
--with-perl= 设定perl库文件路线
[root@001 sbin]# nginx -s stop #终止服务
--http-log-path= 设定access log路径
[root@001 sbin]# nginx #运行服务
--http-client-body-temp-path= 设定http顾客端央浼偶然文件路线
2.成立脚本把Nginx加为系统服务使其Nelly用(service nginx start/stop/restart)
--http-proxy-temp-path= 设定http代理有的时候文件路线
[root@001 sbin]# vim /etc/init.d/nginx
--http-fastcgi-temp-path= 设定http fastcgi一时文件路线
#!/bin/bash
# nginx Startup script for the Nginx HTTP Server
# it is v.0.0.2 version.
# chkconfig: - 85 15
# description: Nginx is a high-performance web and proxy server.
# It has a lot of features, but it's not for everyone.
# processname: nginx
# pidfile: /var/run/nginx.pid
# config: /usr/local/nginx/conf/nginx.conf
nginxd=/usr/local/nginx/sbin/nginx #/注意你安装nginx是否这个路径
nginx_config=/usr/local/nginx/conf/nginx.conf #/注意你安装nginx是否这个路径
nginx_pid=/log/nginx/nginx.pid #/注意你安装nginx是否这个路径
RETVAL=0
prog="nginx"
# Source function library.
. /etc/rc.d/init.d/functions
# Source networking configuration.
. /etc/sysconfig/network
# Check that networking is up.
[ ${NETWORKING} = "no" ] && exit 0
[ -x $nginxd ] || exit 0
# Start nginx daemons functions.
start() {
if [ -e $nginx_pid ];then
echo "nginx already running...."
exit 1
fi
echo -n $"Starting $prog: "
daemon $nginxd -c ${nginx_config}
RETVAL=$?
echo
[ $RETVAL = 0 ] && touch /var/lock/subsys/nginx
return $RETVAL
}
# Stop nginx daemons functions.
stop() {
echo -n $"Stopping $prog: "
killproc $nginxd
RETVAL=$?
echo
[ $RETVAL = 0 ] && rm -f /var/lock/subsys/nginx /var/run/nginx.pid
}
# reload nginx service functions.
reload() {
echo -n $"Reloading $prog: "
#kill -HUP `cat ${nginx_pid}`
killproc $nginxd -HUP
RETVAL=$?
echo
}
# See how we were called.
case "$1" in
start)
start
;;
stop)
stop
;;
reload)
reload
;;
restart)
stop
start
;;
status)
status $prog
RETVAL=$?
;;
*)
echo $"Usage: $prog {start|stop|restart|reload|status|help}"
exit 1
esac
exit $RETVAL
--http-uwsgi-temp-path= 设定http uwsgi一时文件路线
[root@001 sbin]# chmod -R 755 /etc/init.d/nginx #现行反革命就能够利用service来关闭或展开服务
--http-scgi-temp-path= 设定http scgi不时文件路线
--without-http 禁用http server功能
=========================到那Nginx安装达成 =========================
--without-http-cache 禁用http cache功能
四、布置基于域名、ip、端口测量试验站点
--with-mail 启用POP3/IMAP4/SMTP代理模块扶持
Nginx目录下的目录表明:
--with-mail_ssl_module 启用ngx_mail_ssl_module支持
--without-mail_pop3_module 禁止使用pop3合计(POP3即邮局合同的第1个本子,它是明确个人Computer怎样连接到互联英特网的邮件服务器举行收发邮件的钻探。是因特网电子邮件的率先个离线左券标准,POP3协商允许客商从服务器上把邮件存款和储蓄到地面主机上,同时依赖顾客端的操作删除或保存在邮件服务器上的邮件。POP3议和是TCP/IP左券族中的一员,主要用以 帮衬选择顾客端远程管理在服务器上的电子邮件)
1.创造四个站点目录
--without-mail_imap_module 禁止使用imap公约(一种邮件获取左券。它的第十分之一效是邮件客商端能够经过这种左券从邮件服务器上获得邮件的新闻,下载邮件等。IMAP公约运营在TCP/IP合同之上, 使用的端口是143。它与POP3合计的重大不一样是客户能够毫不把具有的邮件全部下载,能够透过顾客端间接对服务器上的邮件举行操作。)
[root@001 ~]# mkdir /usr/local/nginx/html/www
--without-mail_smtp_module 禁止使用smtp左券(SMTP即轻松邮件传输公约,它是一组用于由源地址到指标地址传送邮件的平整,由它来决定信件的转折方式。SMTP左券属于TCP/IP合同族,它扶持每台计算机在发送或转变信件时找到下一个目标地。)
[root@001 ~]# mkdir /usr/local/nginx/html/bbs
--with-google_perftools_module 启用ngx_google_perftools_module支持(调节和测量试验用,剖判程序质量瓶颈)
2.编纂Nginx 配置文件
--with-cpp_test_module 启用ngx_cpp_test_module支持
[root@001 ~]# egrep -v "#|^$" /usr/local/nginx/conf/nginx.conf.default > /usr/local/nginx/conf/nginx.conf #破除配置文件注释与空行
--add-module= 启用外界模块帮衬
3.基于域名站点目录
--with-cc= 指向C编写翻译器路线
[root@001 conf]# vim /usr/local/nginx/conf/nginx.conf
--with-cpp= 指向C预管理门路
修改如下内容:
--with-cc-opt= 设置C编写翻译器参数(PCRE库,须求钦命–with-cc-opt=”-I /usr/local/include”,假使利用select()函数则供给相同的时候增Gavin件呈报符数量,能够透过–with-cc- opt=”-D FD_SETSIZE=2048”指定。)
worker_processes 1;
--with-ld-opt= 设置连接文件参数。(PCRE库,需求钦赐–with-ld-opt=”-L /usr/local/lib”。)
events {
--with-cpu-opt= 钦命编写翻译的CPU,可用的值为: pentium, pentiumpro, pentium3, pentium4, athlon, opteron, amd64, sparc32, sparc64, ppc64
worker_connections 1024;
--without-pcre 禁用pcre库
}
--with-pcre 启用pcre库
http {
--with-pcre= 指向pcre库文件目录
include mime.types;
--with-pcre-opt= 在编译时为pcre库设置附加参数
default_type application/octet-stream;
--with-md5= 指向md5库文件目录(新闻摘要算法第五版,用以提供音信的完整性尊敬)
sendfile on;
--with-md5-opt= 在编写翻译时为md5库设置附加参数 –with-md5-asm 使用md5汇编源
keepalive_timeout 65;
--with-sha1= 指向sha1库目录(数字具名算法,主要用以数字具名)
server {
--with-sha1-opt= 在编写翻译时为sha1库设置附加参数
listen 80;
--with-sha1-asm 使用sha1汇编源
server_name www.test.com; #站点域名
--with-zlib= 指向zlib库目录
location / {
--with-zlib-opt= 在编写翻译时为zlib设置附加参数
root html/www; #站点目录
--with-zlib-asm= 为钦点的CPU使用zlib汇编源举行优化,CPU类型为pentium, pentiumpro
index index.html index.htm;
--with-libatomic 为原子内部存款和储蓄器的立异操作的得以实现提供多少个框架结构
}
--with-libatomic= 指向libatomic_ops安装目录
}
--with-openssl= 指向openssl安装目录
添加:
--with-openssl-opt 在编写翻译时为openssl设置附加参数
server {
--with-debug 启用debug日志
listen 80;
server_name bbs.test.com; #站点域名
location / {
root html/bbs; #站点目录
index index.html index.htm;
}
}
}
[root@001 html]# /usr/local/nginx/sbin/nginx -t #反省陈设文件是还是不是有错
[root@001 html]# /usr/local/nginx/sbin/nginx -s reload #重复加载配置文件
Nginx 配置文件详解:
[root@001 html]# echo "www.test.com">> www/index.html #增长测验页面
[root@001 html]# echo "bbs.test.com">> bbs/index.html #加上测量检验页面
[root@001 html]# vim /etc/hosts #修改hosts配置文件
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.1.222 www.test.com #添加
192.168.1.222 bbs.test.com #添加
[root@001 sbin]# curl www.test.com
www.test.com #测验页面寻常
[root@001 sbin]# curl bbs.test.com
bbs.test.com #测验页面经常
3.基于IP或端口的设想测量检验站点
[root@001 conf]# ip addr help
Usage: ip addr {add|change|replace} IFADDR dev STRING [ LIFETIME ]
[ CONFFLAG-LIST]
ip addr del IFADDR dev STRING
ip addr {show|flush} [ dev STRING ] [ scope SCOPE-ID ]
[ to PREFIX ] [ FLAG-LIST ] [ label PATTERN ]
IFADDR := PREFIX | ADDR peer PREFIX
[ broadcast ADDR ] [ anycast ADDR ]
[ label STRING ] [ scope SCOPE-ID ]
SCOPE-ID := [ host | link | global | NUMBER ]
FLAG-LIST := [ FLAG-LIST ] FLAG
FLAG := [ permanent | dynamic | secondary | primary |
tentative | deprecated | CONFFLAG-LIST ]
CONFFLAG-LIST := [ CONFFLAG-LIST ] CONFFLAG
CONFFLAG := [ home | nodad ]
LIFETIME := [ valid_lft LFT ] [ preferred_lft LFT ]
LFT := forever | SECONDS
[root@001 conf]# ip addr add 192.168.1.234 dev eth0 #给网卡增添IP
[root@001 conf]# ip addr del 192.168.1.234 dev eth0 #查出ip命令
编排配置文件注:基于ip的设想主机只需给网卡增加ip并修改listen就能够
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
server {
listen 192.168.1.222:800; #基于ip或端口
server_name www.test.com; #站点域名
location / {
root html/www; #站点目录
index index.html index.htm;
}
}
server {
listen 192.168.1.234:808; #基于ip或端口
server_name bbs.test.com; #站点域名
location / {
root html/bbs; #站点目录
index index.html index.htm; #基于IP或端口
}
}
}
附:Nginx编写翻译参数详解:
--prefix= 指向安装目录
--sbin-path 指向(推行)程序文件(nginx)
--conf-path= 指向配置文件(nginx.conf)
--error-log-path= 指向错误日志目录
--pid-path= 指向pid文件(nginx.pid)
--lock-path= 指向lock文件(nginx.lock)(安装文件锁定,防止安装文件被外人使用,或自个儿误操作。)
--user= 钦点程序运转时的非特权客户
--group= 钦点程序运转时的非特权顾客组
--builddir= 指向编写翻译目录
--with-rtsig_module 启用rtsig模块帮助(实时非确定性信号)
--with-select_module 启用select模块扶持(一种轮询格局,不引入在高载遇到下使用)禁止使用:--without-select_module
--with-poll_module 启用poll模块帮助(作用与select同样,与select脾性同样,为一种轮询方式,不引进在高载情况下行使)
--with-file-aio 启用file aio支持(一种APL文件传输格式)
--with-ipv6 启用ipv6支持
--with-http_ssl_module 启用ngx_http_ssl_module帮助(使资助https央浼,需已安装openssl)
--with-http_realip_module 启用ngx_http_realip_module辅助(那一个模块允许从呼吁标头退换客商端的IP地址值,默认为关)
--with-http_addition_module 启用ngx_http_addition_module支持(作为一个出口过滤器,帮助不完全缓冲,根据地分响应要求)
--with-http_xslt_module 启用ngx_http_xslt_module帮忙(过滤转变XML乞求)
--with-http_image_filter_module 启用ngx_http_image_filter_module扶助(传输JPEG/GIF/PNG 图片的几个过滤器)(默感觉不启用。gd库要动用)
--with-http_geoip_module 启用ngx_http_geoip_module辅助(该模块成立基于与马克斯Mind 吉优IP二进制文件相称的客商端IP地址的ngx_http_geoip_module变量)
--with-http_sub_module 启用ngx_http_sub_module扶植(允许用一些其余文件替换nginx响应中的一些文件)
--with-http_dav_module 启用ngx_http_dav_module扶持(扩展PUT,DELETE,MKCOL:成立集结,COPY和MOVE方法)暗中同意情形下为关闭,需编写翻译开启
--with-http_flv_module 启用ngx_http_flv_module扶助(提供寻求内存使用基于时间的偏移量文件)
--with-http_gzip_static_module 启用ngx_http_gzip_static_module辅助(在线实时压缩输出数据流)
--with-http_random_index_module 启用ngx_http_random_index_module帮衬(从目录中专擅行选购取叁个目录索引)
--with-http_secure_link_module 启用ngx_http_secure_link_module援助(总计和自己评论要求所需的资阳链接网站)
--with-http_degradation_module 启用ngx_http_degradation_module帮衬(允许在内部存款和储蓄器不足的气象下回到204或444码)
--with-http_stub_status_module 启用ngx_http_stub_status_module扶助(获取nginx自上次起动以来的工作状态)
--without-http_charset_module 禁用ngx_http_charset_module协助(重新编码web页面,但只好是四个样子--服务器端到顾客端,並且独有三个字节的编码可以被重复编码)
--without-http_gzip_module 禁用ngx_http_gzip_module支持(该模块同-with-http_gzip_static_module功能雷同)
--without-http_ssi_module 禁用ngx_http_ssi_module协助(该模块提供了多个在输入端管理管理服务器包罗文件(SSI)的过滤器,近些日子支撑SSI命令的列表是不完全的)
--without-http_userid_module 禁用ngx_http_userid_module帮忙(该模块用来管理用来显著顾客端后续央求的cookies)
--without-http_access_module 禁用ngx_http_access_module补助(该模块提供了三个简便的基于主机的访谈调节。允许/拒绝基于ip地址)
--without-http_auth_basic_module禁用ngx_http_auth_basic_module(该模块是足以应用客户名和密码基于http基本注解方法来保险你的站点或其有个别剧情)
--without-http_autoindex_module 禁用disable ngx_http_autoindex_module支持(该模块用于自动生成目录列表,只在ngx_http_index_module模块未找到索引文件时发出诉求。)
--without-http_geo_module 禁用ngx_http_geo_module援助(创立一些变量,其值信任于客商端的IP地址)
--without-http_map_module 禁用ngx_http_map_module协理(使用任性的键/值对安装配置变量)
--without-http_split_clients_module 禁用ngx_http_split_clients_module支持(该模块用来基于有个别条件划分客商。条件如:ip地址、报头、cookies等等)
--without-http_referer_module 禁用disable ngx_http_referer_module支持(该模块用来过滤诉求,拒绝报头中Referer值不得法的乞请)
--without-http_rewrite_module 禁用ngx_http_rewrite_module协助(该模块允许利用正则表达式退换UPAJEROI,并且根据变量来转向以至选择安顿。假如在server等级设置该选择,那么她们就要 location以前生效。倘诺在location还恐怕有更上一层楼的重写准则,location部分的条条框框照旧会被执行。借使那个UEvoqueI重写是因为location部分的平整形成的,那么 location部分会再一次被实施作为新的U大切诺基I。那一个循环会实践十四遍,然后Nginx会再次来到三个500谬误。)
--without-http_proxy_module 禁用ngx_http_proxy_module扶持(有关代理服务器)
--without-http_fastcgi_module 禁用ngx_http_fastcgi_module扶持(该模块允许Nginx 与法斯特CGI 进度并行,并经过传递参数来调控法斯特CGI 进度专门的学问。)法斯特CGI八个常驻型的公共网关接口。
--without-http_uwsgi_module 禁用ngx_http_uwsgi_module援救(该模块用来医用uwsgi左券,uWSGI服务器相关)
--without-http_scgi_module 禁用ngx_http_scgi_module扶助(该模块用来启用SCGI协议匡助,SCGI契约是CGI左券的代替。它是一种应用程序与HTTP服务接口标准。它稍微像法斯特CGI但他的安插性更便于达成。)
--without-http_memcached_module 禁用ngx_http_memcached_module援救(该模块用来提供简单的缓存,以拉长系统功用)
-without-http_limit_zone_module 禁用ngx_http_limit_zone_module支持(该模块能够本着条件,举行对话的产出连接数调节)
--without-http_limit_req_module 禁用ngx_http_limit_req_module扶植(该模块允许你对此三个地点进行呼吁数量的范围用贰个加以的session或二个一定的风云)
--without-http_empty_gif_module 禁用ngx_http_empty_gif_module协助(该模块在内部存款和储蓄器中常驻了多个1*1的透明GIF图像,能够被百般连忙的调用)
--without-http_browser_module 禁用ngx_http_browser_module帮忙(该模块用来创制信任于供给报头的值。假使浏览器为modern ,则$modern_browser等于modern_browser_value指令分配的值;若是浏览器为old,则$ancient_browser等于 ancient_browser_value指令分配的值;尽管浏览器为 MSIE中的任性版本,则 $msie等于1)
--without-http_upstream_ip_hash_module 禁用ngx_http_upstream_ip_hash_module帮忙(该模块用于轻便的载重均衡)
--with-http_perl_module 启用ngx_http_perl_module协理(该模块使nginx能够直接使用perl或通过ssi调用perl)
--with-perl_modules_path= 设定perl模块路径
--with-perl= 设定perl库文件路线
--http-log-path= 设定access log路径
--http-client-body-temp-path= 设定http顾客端诉求有的时候文件路线
--http-proxy-temp-path= 设定http代理不经常文件路径
--http-fastcgi-temp-path= 设定http fastcgi偶然文件路线
--http-uwsgi-temp-path= 设定http uwsgi有的时候文件路线
--http-scgi-temp-path= 设定http scgi有的时候文件路线
-without-http 禁用http server功能
--without-http-cache 禁用http cache功能
--with-mail 启用POP3/IMAP4/SMTP代理模块辅助
--with-mail_ssl_module 启用ngx_mail_ssl_module支持
--without-mail_pop3_module 禁止使用pop3磋商(POP3即邮局协议的首个本子,它是鲜明个人Computer怎么样连接到网络上的邮件服务器进行收发邮件的情商。是因特网电子邮件的首先个离线协议正式,POP3左券允许客户从服务器上把邮件存款和储蓄到本地主机上,同时依靠顾客端的操作删除或保存在邮件服务器上的邮件。POP3合计是TCP/IP合同族中的一员,首要用来辅助采纳客商端远程管理在服务器上的电子邮件)
--without-mail_imap_module 禁止使用imap左券(一种邮件获取协议。它的最重要意义是邮件客商端能够因而这种合同从邮件服务器上收获邮件的新闻,下载邮件等。IMAP协议运转在TCP/IP公约之上,使用的端口是143。它与POP3商业事务的首要差距是顾客可以毫不把具备的邮件全体下载,能够由此客商端直接对服务器上的邮件进行操作。)
--without-mail_smtp_module 禁止使用smtp公约(SMTP即轻便邮件传输公约,它是一组用于由源地址到指标地址传送邮件的法则,由它来支配信件的转会格局。SMTP公约属于TCP/IP合同族,它帮助每台微型Computer在出殡和下葬或转向信件时找到下贰个指标地。)
--with-google_perftools_module 启用ngx_google_perftools_module扶助(调节和测验用,分析程序品质瓶颈)
--with-cpp_test_module 启用ngx_cpp_test_module支持
--add-module= 启用外界模块扶植
--with-cc= 指向C编写翻译器路线
--with-cpp= 指向C预管理渠道
--with-cc-opt= 设置C编写翻译器参数(PCRE库,需求钦定–with-cc-opt="-I /usr/local/include",若是采用select()函数则要求同一时间增Gavin件汇报符数量,可以透过–with-cc- opt="-D FD_SETSIZE=2048"指定。)
--with-ld-opt= 设置连接文件参数。(PCRE库,必要钦赐–with-ld-opt="-L /usr/local/lib"。)
--with-cpu-opt= 钦命编写翻译的CPU,可用的值为: pentium, pentiumpro, pentium3, pentium4, athlon, opteron, amd64, sparc32, sparc64, ppc64
--without-pcre 禁用pcre库
--with-pcre 启用pcre库
--with-pcre= 指向pcre库文件目录
--with-pcre-opt= 在编写翻译时为pcre库设置附加参数
--with-md5= 指向md5库文件目录(音讯摘要算法第五版,用以提供音讯的完整性爱慕)
--with-md5-opt= 在编写翻译时为md5库设置附加参数
--with-md5-asm 使用md5汇编源
--with-sha1= 指向sha1库目录(数字签字算法,首要用于数字具名)
--with-sha1-opt= 在编写翻译时为sha1库设置附加参数
--with-sha1-asm 使用sha1汇编源
--with-zlib= 指向zlib库目录
--with-zlib-opt= 在编写翻译时为zlib设置附加参数
--with-zlib-asm= 为钦定的CPU使用zlib汇编源进行优化,CPU类型为pentium, pentiumpro
--with-libatomic 为原子内存的翻新操作的得以达成提供二个架构
--with-libatomic= 指向libatomic_ops安装目录
--with-openssl= 指向openssl安装目录
--with-openssl-opt 在编写翻译时为openssl设置附加参数
--with-debug 启用debug日志
编写翻译参数详解:
Nginx 配置文件详解:
本文由星彩网app下载发布于星彩网app下载,转载请注明出处:编写翻译安装,Nginx源码安装