Nginx

本文详细介绍了Nginx的介绍、安装过程、多核绑定、证书加密、虚拟主机配置、负载均衡策略以及访问其他发布目录等内容。通过实例演示了Nginx的配置和优化,包括设置worker_processes以适应多核CPU,配置证书实现HTTPS访问,以及利用round-robin负载均衡策略。
摘要由CSDN通过智能技术生成

一.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 
  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值