一.Nginx的介绍
1.概念
nginx(发音”engine x”)是俄罗斯软件工程师Igor Sysoev开发的免费开源web服务器软件。nginx于2004年发布,聚焦于高性能,高并发和低内存消耗问题。并且具有多种web服务器功能特性:负载均衡,缓存,访问控制,带宽控制,以及高效整合各种应用的能力,这些特性使nginx很适合于现代网站架构。目前,nginx已经是互联网上第二流行的开源web服务器软件。
2.架构图
二.Nginx的安装(源码方式)
1.下载源码包,并解压
注意,在下载安装包的过程中,一定要看和当前的linux操作系统是否匹配,省的做一些无用功
[root@hx ~]# tar zxf nginx-1.12.0.tar.gz
[root@hx ~]# cd nginx-1.12.0
[root@hx nginx-1.12.0]# ls
auto CHANGES.ru configure html man src
CHANGES conf contrib LICENSE README
[root@hx nginx-1.12.0]# cd src/
[root@hx src]# ls
core event http mail misc os stream
[root@hx src]# cd core/
[root@hx core]# ls
nginx.c ngx_inet.h ngx_radix_tree.h
nginx.h ngx_list.c ngx_rbtree.c
......
2.隐藏nginx的版本号,在这里主要是为了安全起见
vim /root/nginx-1.12.0/src/core/nginx.h
3.关闭gcc的debug调试模式,节省空间
[root@hx nginx-1.12.0]# ls
auto CHANGES.ru configure html man src
CHANGES conf contrib LICENSE README
[root@hx nginx-1.12.0]# cd auto/
[root@hx auto]# ls
cc feature headers install module options stubs types
define have include lib modules os summary unix
endianness have_headers init make nohave sources threads
[root@hx auto]# cd cc
[root@hx cc]# ls
acc bcc ccc clang conf gcc icc msvc name owc sunc
[root@hx cc]# vim gcc
4.设置nginx的目录及各种模块比如openssl加密等
因为linux内核是c语言写的,所以一定要保证gcc环境
#yum install gcc -y
[root@hx nginx-1.12.0]# ./configure --prefix=/usr/local/nginx --with-http_ssl_module --with-file-aio --with-threads --with-http_stub_status_module
./configure: error: the HTTP rewrite module requires the PCRE library.
You can either disable the module by using --without-http_rewrite_module
option, or install the PCRE library into the system, or