系統(tǒng) CentOS 6.5
首先打開Nginx的官方網(wǎng)站下載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系統(tǒng)中以Daemon的方式在后臺運行,后臺進程包含一個master進程和多個work進程,默認以多進程的方式梆惯。
master管理work密似,外界的信號都是發(fā)給master辞居,再由master分配給work進程
master進程
- 管理work進程;
- 外界的信號都是發(fā)給master蛋勺,再由它分配給work進程瓦灶;
- 監(jiān)控work的運行狀態(tài),如發(fā)生異常抱完,重新啟動新的進程贼陶;
work進程
- work之間是對等的
- 基本的網(wǎng)絡請求都是在work中進行
- 一個請求只能在一個work進程中進行
- 一個work進程也不能處理其他進程的請求
- work進程的個數(shù)是可設置的,一般跟CPU核數(shù)相同巧娱;
Nginx進程模型如下:
Nginx進程模型
ps:控制nginx碉怔,只需和master通信即可(work被master管理)