新安装和已安装nginx如何添加未编译安装模块/补丁
新安裝和已安裝nginx如何添加未編譯安裝模塊/補丁
--http://www.apelearn.com/bbs/forum.php?mod=viewthread&tid=10485&page=1&extra=#pid105098
新安裝nginx如何添加未編譯安裝模塊/補丁
之前發過一篇nginx如何添加未編譯安裝模塊/補丁,那篇是安裝nginx之后的,nginx已經在跑了,這一篇新安裝nginx
http://www.apelearn.com/bbs/thread-10429-1-1.html
比如要安裝?? ngx_req_status模塊??? 統計流量的
yum -y install patch unzip gcc? pcre pcre-devel zlib zlib-devel openssl-devel openssl -y
mkdir /download;cd /download
wget http://nginx.org/download/nginx-1.4.6.tar.gz &&
wget https://github.com/zls0424/ngx_req_status/archive/master.zip -O ngx_req_status.zip
unzip /download/ngx_req_status.zip? -d /usr/local/
tar -zxvf nginx-1.4.6.tar.gz
cd nginx-1.4.6
patch -p1 < /usr/local/ngx_req_status-master/write_filter.patch?? # patch命令進行打補丁
./configure --prefix=/usr/local/nginx --with-pcre \
--with-http_gzip_static_module --with-http_ssl_module \
--add-module=/usr/local/ngx_req_status-master? && make -j2 && make install?? #啟用2個cpu去編譯,2個job,提高編譯速度
rm -rf? /usr/local/ngx_req_status-master
#啟動nginx
/usr/local/nginx/sbin/nginx
#修改nginx.conf
http {
req_status_zone server_name $server_name 256k;
req_status_zone server_addr $server_addr 256k;
req_status_zone server_url? $server_name$uri 256k;
req_status server_name server_addr server_url;
server {
listen 8080;
server_name test.com;
location /ttlsa-req-status {
allow 192.168.1.6;
allow 192.168.2.8;
deny all;
req_status_show on;
}
}
}
#reload一下/usr/local/nginx/sbin/nginx -s reload
#修改Windows的hosts文件
http://test.com:8080/ttlsa-req-status
#http://www.ttlsa.com/nginx/nginx-custom-header-to-return-information-module-ngx_headers_more/ 隱藏服務器的軟件版本改為tomcat 7
sed -i 's/Server: nginx/Server: tomcat/' /download/nginx-1.4.6/src/http/ngx_http_header_filter_module.c
sed -i 's/1.4.6/7.0.52/'? /download/nginx-1.4.6/src/core/nginx.h
sed -i 's/nginx\//tomcat/'? /download/nginx-1.4.6/src/core/nginx.h
cat > /etc/ld.so.conf << EOF
> include ld.so.conf.d/*.conf
> /usr/local/lib??????????? #動態裝入器將在/usr/local/lib 中查找共享庫。
> EOF
?ldconfig??? 更新ld.so.cache 文件,以讀取最新的/etc/ld.so.conf
?
?
?
?nginx如何添加未編譯安裝模塊/補丁 [復制鏈接]
--http://www.apelearn.com/bbs/forum.php?mod=viewthread&tid=10429&page=1&extra=#pid103693
有這樣一個增強的負載均衡模塊,我們知道php添加擴展模塊很容易,但是nginx呢?
下面是教程
“公平的”Nginx 負載均衡模塊,增強了Nginx 提供的round-robin 負載均衡算法,可以跟蹤后端服務器的負載來分發請求。
配置范例:
upstream mongrel {
??? fair;
??? server 127.0.0.1:5000;
??? server 127.0.0.1:5001;
??? server 127.0.0.1:5002;
}
原已經安裝好的nginx,現在需要添加一個未被編譯安裝的模塊:
nginx -V 可以查看原來編譯時都帶了哪些參數
--prefix=/usr/local/nginx --with-pcre --with-http_gzip_static_module --with-http_ssl_module --user=nginx --group=nginx --add-module=/usr/local/ngx_req_status-master
wget -O nginx-upstream-fair.zip https://github.com/gnosek/nginx-upstream-fair/archive/master.zip
步驟如下:
unzip /download/nginx-upstream-fair.zip? -d /usr/local/
tar -zxvf nginx-1.4.6.tar.gz
cd nginx-1.4.6???? #上面nginx -V? 查出來的編譯參數這里原樣加上
./configure? --prefix=/usr/local/nginx --with-pcre --with-http_gzip_static_module --with-http_ssl_module --user=nginx --group=nginx? --add-module=/usr/local/ngx_req_status-master/? --add-module=/usr/local/nginx-upstream-fair-master/
#不要make install,否則就是覆蓋安裝,生成的nginx二進制文件放在當前目錄的objs/下
make
替換nginx二進制文件:
cp /usr/local/nginx/sbin/nginx{,.bak}
/etc/init.d/nginx stop
cp /download/nginx-1.4.6/objs/nginx? /usr/local/nginx/sbin/
rm -rf /usr/local/{nginx-upstream-fair-master,ngx_req_status-master}
?
?
?
f
總結
以上是生活随笔為你收集整理的新安装和已安装nginx如何添加未编译安装模块/补丁的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 数据分析系列剧第四集:行业研究报告与生产
- 下一篇: SharePoint 2013 Desi