Nginx——特性介绍及安装
2017-05-06 17:15
435 查看
Nginx——特性介绍及安装
Nginx是一款免费、开源、性能强大且非常流行的服务器,主要有三个功能:Web Server , Reverse Proxy Server , IMAP or POP3 Proxy Server 。Nginx是为了解决互联网业内著名的 “C10K” 问题而生,且因其具有丰富的特性、极其强大的性能、配置简单、工作稳定及资源占用低等特点而闻名于世。Nginx的主要功能有:作为Web服务器可与httpd服务一样提供静态的Web资源,结合FastCGI/uwSGI/SCGI等协议反代动态资源请求,http/https协议的反向代理,imap4/pop3协议的反向代理,tcp/udp协议的请求转发(四层转发)。
Nginx在功能丰富的同时,其配置文件种类非常多。但相对于httpd的配置文件来说,Nginx配置文件逻辑严谨,条理清晰,配置方法相对简单。我们将在下一篇博客中着重详细介绍。
【注】本文全部示例以CentOS7.3作为运行环境。
Nginx特性
Nginx 的Master/Worker 程序架构
一个master进程:负责加载和分析配置文件、管理worker进程、平滑升级
一个或多个worker进程
处理并响应用户请求
缓存相关的进程:
cache loader:载入缓存对象
cache manager:管理缓存对象
Nginx特性
支持异步读写(AIO)和非阻塞(unblock)支持事件驱动(Singal Driven)
模块动态装卸载(DSO)
Nginx模块
Nginx是高度模块化,从1.9版本以后支持(部分)模块动态装卸载,模块分为以下几类- 核心模块 core module
- 标准模块 standart module
1. Http modules :用于提供web服务或web的反向代理服务
http模块分为:
标准模块 Standard HTTP modules 可选模块 Optional HTTP modules
Mail modules :用于提供邮件相关功能
Stream modules :用于提供四层转发功能
第三方模块 3rd Party modele
程序安装 Nginx installation
安装方式
Nginx程序依赖环境:两个标准包组:
“Development Tools” 和 “Server Platform Development”
依赖程序包:
pcre-devel,openssl-devel,zlib-devel
从EPEL官方yum源或者从Nginx官网获取Nginx程序包,使用yum方法安装【推荐】
从Nginx官网获取源码后编译安装
yum安装
此方法适用于大多数情况,如果有特殊需求可以使用编译安装,可在配置号yum源后安装编译安装
准备软件环境,安装上述依赖包组和程序包]# tar -xvf nginx-1.10.2.tar.gz ]# cd ngingx-1.10.2
创建组和用户
]# groupadd -r nginx ]# useradd -r -g nginx nginx
编译安装,此处的配置选项参考EPEL源中yum安装nginx的选项,较为实用
]# ./configure --prefix=/usr/share/nginx --sbin-path=/usr/sbin/nginx --modules-path=/usr/lib64/nginx/modules --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --http-client-body-temp-path=/var/lib/nginx/tmp/client_body --http-proxy-temp-path=/var/lib/nginx/tmp/proxy --http-fastcgi-temp-path=/var/lib/nginx/tmp/fastcgi --http-uwsgi-temp-path=/var/lib/nginx/tmp/uwsgi --http-scgi-temp-path=/var/lib/nginx/tmp/scgi --pid-path=/run/nginx.pid --lock-path=/run/lock/subsys/nginx --user=nginx --group=nginx --with-file-aio --with-ipv6 --< 4000 span class="hljs-comment">with-http_ssl_module --with-http_v2_module --with-http_realip_module --with-http_addition_module --with-http_xslt_module=dynamic --with-http_image_filter_module=dynamic --with-http_geoip_module=dynamic --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_mp4_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_random_index_module --with-http_secure_link_module --with-http_degradation_module --with-http_slice_module --with-http_stub_status_module --with-http_perl_module=dynamic --with-mail=dynamic --with-mail_ssl_module --with-pcre --with-pcre-jit --with-stream=dynamic --with-stream_ssl_module --with-google_perftools_module --with-debug --with-cc-opt='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -m64 -mtune=generic' --with-ld-opt='-Wl,-z,relro -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -Wl,-E' ]# make -j 4 && make install
创建对应目录
]# mkdir -pv /var/lib/nginx/tmp/{client_body,proxy,fastcgi,uwsgi,scgi}
启动服务,Nginx默认监听80端口
]# systemctl start nginx ]# ss -tnl
相关文章推荐
- nginx介绍以及编译安装
- Oracle10g安装升级以及新特性介绍
- 在centos6.5上编译安装httpd-2.4和2.4版本特性介绍
- mongodb 3.0下载安装、配置及mongodb最新特性、基本命令教程详细介绍
- 一、nginx介绍及安装
- WCF RIA Service SP1安装及新特性介绍
- nginx介绍及安装
- nginx架构特性及编译安装
- nginx特性及I/O模型&nginx安装
- centos LNMP第一部分环境搭建 LAMP LNMP安装先后顺序 php安装 安装nginx 编写nginx启动脚本 懒汉模式 mv /usr/php/{p.conf.default,p.conf} php运行方式SAPI介绍 第二十三节课
- nginx服务器的安装和配置的方法介绍
- 2012版辅助开发工具包(ADT)新功能特性介绍及安装使用
- Linux(6.4)+Nginx(1.4.1)+Mysql(5.6.12)+Php(5.5.0)源码编译安装 环境介绍
- nginx的自我介绍以及如何编译安装
- 简单介绍如何在 CentOS 下安装 Nginx
- ubunut11.0安装nginx基本目录结构介绍和配置使用方法
- 2012版辅助开发工具包(ADT)新功能特性介绍及安装使用
- nginx架构特性及编译安装,实战Nginx与PHP(FastCGI)的安装、配置与优化
- SSDB 安装 和 特性介绍
- Windows系统下Nginx服务器的基本安装和配置方法介绍