nginx 功能简介

1、web 服务器:http 服务、邮件服务器

1、Http代理:正向代理、反向代理

2、负载均衡

  轮询           挨个去访问

  加权轮询         根据权重值去轮询

  ip hash          对客户端请求的ip进行hash操作,然后根据hash结果将同一个客户端ip的请求分发给同一台服务器进行处理,可以解决session不共享的问题。

  拓展策略(自定义)

3、web 缓存

  Nginx可以对不同的文件做不同的缓存处理,配置灵活,并且支持FastCGI_Cache,主要用于对FastCGI的动态程序进行缓存。配合着第三方的ngx_cache_purge,对制定的URL缓存内容可以的进行增删管理。

环境准备

一、安装编译工具及库文件

yum -y install make zlib zlib-devel gcc-c++ libtool  openssl openssl-devel

二、首先要安装 PCRE

PCRE 作用是让 Nginx 支持 Rewrite 功能。

1、下载 PCRE 安装包,下载地址: http://downloads.sourceforge.net/project/pcre/pcre/8.35/pcre-8.35.tar.gz

[root@192 src]# cd /usr/local/src/
[root@192 src]# wget http://downloads.sourceforge.net/project/pcre/pcre/8.35/pcre-8.35.tar.gz

2、解压安装包:

[root@192 src]# tar zxvf pcre-8.35.tar.gz

3、进入安装包目录

[root@192 src]# cd pcre-8.35

4、编译安装 

[root@192 pcre-8.35]# ./configure
[root@192 pcre-8.35]# make && make install

5、查看pcre版本

[root@192 pcre-8.35]# pcre-config --version

安装 Nginx

1、下载 Nginx,下载地址:http://nginx.org/download/nginx-1.6.2.tar.gz

[root@192 src]# cd /usr/local/src/
[root@192 src]# wget http://nginx.org/download/nginx-1.6.2.tar.gz

安装包

[root@192 src]# tar zxvf nginx-1.6.2.tar.gz

3、进入安装包目录

[root@192 src]# cd nginx-1.6.2

4、编译安装

[root@192 nginx-1.6.2]# ./configure --prefix=/usr/local/webserver/nginx --with-http_stub_status_module --with-http_ssl_module --with-pcre=/usr/local/src/pcre-8.35
[root@192 nginx-1.6.2]# make
[root@192 nginx-1.6.2]# make install
http_stub_status_module  性能收集模块
http_ssl_module       加密模块

5、查看nginx版本

[root@192 nginx-1.6.2]# /usr/local/webserver/nginx/sbin/nginx -v

Nginx 配置

创建 Nginx 运行使用的用户 www:

[root@192 conf]# /usr/sbin/groupadd www 

[root@192 conf]# /usr/sbin/useradd -g www www

nginx 文件结构

...              #全局块

events {         #events块
   ...
}

http      #http块
{
    ...   #http全局块
    server        #server块
    { 
        ...       #server全局块
        location [PATTERN]   #location块
        {
            ...
        }
        location [PATTERN] 
        {
            ...
        }
    }
    server
    {
      ...
    }
    ...     #http全局块
}
View Code

相关文章:

  • 2019-11-25
  • 2018-08-17
  • 2021-12-03
  • 2021-06-10
  • 2021-06-11
  • 2021-11-05
  • 2022-01-06
  • 2021-12-15
猜你喜欢
  • 2020-07-30
  • 2021-11-04
  • 2021-10-30
  • 2022-01-12
  • 2021-07-18
相关资源
相似解决方案