美文网首页架构
[Nginx]的安装与配置

[Nginx]的安装与配置

作者: 陈大集 | 来源:发表于2016-01-16 21:12 被阅读135次

系统 CentOS 6.5

首先打开Nginx的官方网站下载Nginx,此处笔者下载的是

nginx-1.9.7.tar.gz

将其放置在/opt/目录下

tar -zxvf nginx-1.9.7.tar.gz
cd nginx-1.9.7
./configure
make
make install

常见问题

缺少PCRE库
./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 build the PCRE library
statically from the source with nginx by using --with-pcre=<path> option.

解决方式

yum -y install pcre pcre-devel
缺少gzip
./configure: error: the HTTP gzip module requires the zlib library.
You can either disable the module by using --without-http_gzip_module
option, or install the zlib library into the system, or build the zlib library
statically from the source with nginx by using --with-zlib=<path> option.

解决方式

yum -y install zlib zlib-devel
缺少 gcc

解决方式

yum install gcc gcc-c++

Nginx进程

Nginx启动后,在Unix系统中以Daemon的方式在后台运行,后台进程包含一个master进程和多个work进程,默认以多进程的方式。

master管理work,外界的信号都是发给master,再由master分配给work进程

master进程
  1. 管理work进程;
  2. 外界的信号都是发给master,再由它分配给work进程;
  3. 监控work的运行状态,如发生异常,重新启动新的进程;
work进程
  1. work之间是对等的
  2. 基本的网络请求都是在work中进行
  3. 一个请求只能在一个work进程中进行
  4. 一个work进程也不能处理其他进程的请求
  5. work进程的个数是可设置的,一般跟CPU核数相同;

Nginx进程模型如下:

Nginx进程模型

ps:控制nginx,只需和master通信即可(work被master管理)

相关文章

网友评论

本文标题:[Nginx]的安装与配置

本文链接:https://www.haomeiwen.com/subject/gzohkttx.html