1. 程式人生 > >linux源碼編譯安裝nginx

linux源碼編譯安裝nginx

是否 load 查看 nginx bin fig 列表 compile 9.1

1.從nginx的官方網站下載nginx的安裝源碼包,要下載.gz格式的包才是linux安裝包 網址http://nginx.org/download/

wget http://nginx.org/download/nginx-1.5.9.tar.gz

2.解壓

tar -zxvf nginx-1.5.9.tar.gz
yum -y install pcre-devel gcc gcc-c++ autoconf automake make zlib-devel openssl openssl-devel

3.打開解壓後的目錄 配置安裝環境-執行命令:

cd?nginx-1.6.0
./configure --prefix=/usr/local/nginx --pid-path=/var/run/nginx/nginx.pid --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --with-http_stub_status_module --with-http_ssl_module --with-http_realip_module --with-pcre --with-http_v2_module

--with-http_stub_status_module:支持nginx狀態查詢
--with-http_ssl_module:支持https
--with-http_spdy_module:支持google的spdy,想了解請百度spdy,這個必須有ssl的支持
--with-pcre:為了支持rewrite重寫功能,必須制定pcre

為了支持rewrite功能,我們需要安裝pcre
yum install pcre*
需要ssl的支持
yum install openssl*

4.在解壓目錄執行編譯命令:
make && make install

5.創建軟鏈:執行命令:
ln -s /usr/local/nginx/sbin/nginx /usr/local/bin/nginx


6.【啟動nginx服務】:執行命令:
/usr/local/servers/nginx/sbin/nginx
7.【查看nginx服務是否啟動成功】:執行命令:ps -ef|grep nginx,如果成功應該會出來兩條數據
8.停止
9.1先查詢nginx主進程號 ps -ef|grep nginx
在進程列表裏面找master進程,他的編號就是主進程號了
9.2發送信號
1從容停止nginx
kill -QUIT 主進程號
2快速停止nginx
kill -TERM 主進程號
3強制停止nginx
kill -9 nginx

  • 出現錯誤
    1  ./congigure: error: the HTTP rewrite module requires the PCRE library  
            安裝pcre-devel 解決問題
            yum -y install pcre-devel
    2   ./configure: error: C compiler cc is not found  
            yum install gcc
            yum install gcc-c++
            yum install autoconf
            yum install automake
    yum install make
    3  ./configure: error: the HTTP gzip module requires the zlib library
            yum install zlib-devel
    4 ./configure: error: the …from OpenSSL library. with-openssl=<path>options
            yum -y install openssl openssl-devel

linux源碼編譯安裝nginx