nginx介绍及编译安装

centos平台 nginx 的安装:

 1. 安装make: 

yum -y install gcc automake autoconf libtool make

 2. 安装g++:

  yum install gcc gcc-c++

 3. nginx依赖于pcre库,要先安装pcre

yum install pcre pcre-devel
4. 选定安装目录:
  cd /usr/local/src
  wget http://nginx.org/download/nginx-1.15.0.tar.gz
  tar zxvf nginx-1.15.0.tar.gz
  

  cd nginx-1.15.0

  ./configure

  如果出现./configure: error: the HTTP gzip module requires the zlib library.需要安装zlib

  wget http://zlib.net/zlib-1.2.11.tar.gz
 如果出现

  

  需要安装

  openssl-devel
  yum -y install openssl openssl-devel
  最后执行成功后

  make && make install

cd /ulsr/local/nginx, 看到如下4个目录

./

 ....conf 配置文件 

 ... html 网页文件

 ...logs  日志文件

 ...sbin  主要二进制程序

centos平台 nginx 的启动:

  1. ./sbin/nginx 

  2. nginx -c 指定配置文件启动

如果出现端口占用使用netstat -antp检查。

启动后:

  

主进程: 管理子work

 ......

信号量控制nginx

  Kill -信号选项 nginx的主进程号 

TERM, INT

Quick shutdown

QUIT

Graceful shutdown  优雅的关闭进程,即等请求结束后再关闭

HUP

Configuration reload ,Start the new worker processes with

 a new configuration Gracefully shutdown the old worker processes

改变配置文件,平滑的重读配置文件

USR1

Reopen the log files 重读日志,在日志按月/日分割时有用

USR2

Upgrade Executable on the fly 平滑的升级

WINCH

Gracefully shutdown the worker processes 优雅关闭旧的进程(配合USR2来进行升级)













 
原文地址:https://www.cnblogs.com/gcm688/p/11163782.html