linux系統為Centos 64位
第一步:從http://nginx.org/download/上下載相應的版本(或者wget http://nginx.org/download/nginx-1.5.9.tar.gz直接在Linux上用命令下載)
第二步:解壓 tar -zxvf nginx-1.5.9.tar.gz
第三步:設置一下配置信息 ./configure --prefix=/usr/local/nginx ,或者不執行此步,直接默認配置
第四步:
make 編譯 (make的過程是把各種語言寫的源碼文件,變成可執行文件和各種庫文件)
make install 安裝 (make install是把這些編譯出來的可執行文件和庫文件復制到合適的地方)
在配置信息的時候,也就是在第三步,出現了一下錯誤:

錯誤為:./configure: error: the HTTP rewrite module requires the PCRE library.
安裝pcre-devel解決問題
yum -y install pcre-devel
還有可能出現:
錯誤提示:./configure: error: the HTTP cache module requires md5 functions
from OpenSSL library. You can either disable the module by using
--without-http-cache option, or install the OpenSSL library into the system,
or build the OpenSSL library statically from the source with nginx by using
--with-http_ssl_module --with-openssl=<path> options.
解決辦法:
yum -y install openssl openssl-devel
安裝后在linux下啟動和關閉nginx:
啟動操作
/usr/nginx/sbin/nginx (/usr/nginx/sbin/nginx -t 查看配置信息是否正確)
停止操作是通過向nginx進程發送信號(什么是信號請參閱linux文 章)來進行的
步驟1:查詢nginx主進程號
ps -ef | grep nginx
在進程列表里 面找master進程,它的編號就是主進程號了。
步驟2:發送信號
從容停止Nginx:
kill -QUIT 主進程號
快速停止Nginx:
kill -TERM 主進程號
強制停止Nginx:
pkill -9 nginx
另外, 若在nginx.conf配置了pid文件存放路徑則該文件存放的就是Nginx主進程號,如果沒指定則放在nginx的logs目錄下。有了pid文 件,我們就不用先查詢Nginx的主進程號,而直接向Nginx發送信號了,命令如下:
kill -信號類型 '/usr/nginx/logs/nginx.pid'
平滑重啟
如果更改了配置就要重啟Nginx,要先關閉Nginx再打開?不是的,可以向Nginx 發送信號,平滑重啟。
平滑重啟命令:
kill -HUP 住進稱號或進程號文件路徑
或者使用
/usr/nginx/sbin/nginx -s reload
nginx -t -c /usr/nginx/conf/nginx.conf
或者
