新安装和已安装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如何添加未编译安装模块/补丁的更多相关文章

  1. 安装成功的nginx如何添加未编译安装模块

    原已经安装好的nginx,现在需要添加一个未被编译安装的模块举例说明:安装第三方的ngx_cache_purge模块(用于清除指定URL的缓存)nginx的模块是需要重新编译nginx,而不是像apa ...

  2. 转:安装成功的nginx如何添加未编译安装模块

    原已经安装好的nginx,现在需要添加一个未被编译安装的模块 举例说明:安装第三方的ngx_cache_purge模块(用于清除指定URL的缓存) nginx的模块是需要重新编译nginx,而不是像a ...

  3. 生产线上的Nginx如何添加未编译安装模块

    正在生产线上跑着web前端是nginx+tomcat,现在有这样一个需求,需要对网站的单品页面和列表页设置缓存,不同的页面设置不同的缓存,但是由于开始没有安装ngx_cache_purge这个模块,现 ...

  4. 安装成功的nginx,如何添加未编译安装模块(非覆盖安装http_image_filter_module)

    背景:1.做了图片上传小项目.2.图片上传,需要多图管理.3.图片上传,需要存储到Fastdfs.4.Fastdfs上的图片,和Nginx结合.5.Nginx从Fastdfs获得的图片,需要使用缩略图 ...

  5. 安装成功的nginx如何添加未编译模块?

    在重启nginx后发生了错误,错误如下: nginx: [emerg] the "ssl" parameter requires ngx_http_ssl_module in /u ...

  6. nginx添加未编译安装模块

    链接:http://taokey.blog.51cto.com/4633273/1318719

  7. 23、nginx动态添加nginx_upstream_check_module健康检查模块

    nginx_upstream_check_module模块地址:https://github.com/yaoweibin/nginx_upstream_check_module 23.1.说明: 1. ...

  8. Nginx之解压编译安装-yellowcong

    安装前准备 对于nginx编译安装需要先安装编译 的工具,然后再安装nginx依赖 yum -y install gcc gcc-c++ autoconf automake make yum -y i ...

  9. centos 7 下 nginx 1.10.3 编译安装的方法

    安装所需环境 Nginx 是 C语言 开发,建议在 Linux 上运行,当然,也可以安装 Windows 版本,本篇则使用 CentOS 7 作为安装环境. 一. gcc 安装安装 nginx 需要先 ...

随机推荐

  1. iftop、ifstat详解

    ifstat 介绍 ifstat工具是个网络接口监测工具,比较简单看网络流量 实例 默认使用 #ifstat eth0 eth1 KB/s in KB/s out KB/s in KB/s out 0 ...

  2. mybatise 动态sql

    1. <if><choose> 动态sql 相当 <if> Java if  满足多个条件  <choose> <when>    java ...

  3. [mysql] Install/Remove of the Service Denied

    在windos 的cmd下安装mysql 在mysql的bin目录下面执行: mysqld --install 报错: 信息如下: Install/Remove of the Service Deni ...

  4. opencv-从图像旋转学习Mat数据訪问

    先看一个简单的样例 代码: // ConsoleApplication3_6_23.cpp : Defines the entry point for the console application. ...

  5. Maven------使用maven新建web项目出现问题 项目名称出现红色交叉

    转载: http://wenda.so.com/q/1365963640069173?src=140 解决方法: problems窗口查看到下面错误java compiler level does n ...

  6. Javascript 字符串替换

    <!DOCTYPE html><html><head> <meta http-equiv="Content-Type" content=& ...

  7. Linux下Redis集群环境的搭建

    一.安装redis(使用redis3.0版本) 1.需要gcc环境,如果没有执行命令安装gcc yum install gcc-c++ 2.下载redis3.0的源码包并上传至服务器 3.解压源码包 ...

  8. AndroidWear开发之开发环境[前奏]

    上篇教程教的是如何下载最新的SDK http://www.cnblogs.com/bvin/p/3811751.html 一.Eclipse下的尝试 之前以为在Eclipse下把SDK,ADT更新一下 ...

  9. springjdbc的批量操作

    这里主要是看的官方文档,如何翻译: NamedParameterJdbcTemplate The NamedParameterJdbcTemplate class adds support for p ...

  10. CSS-项目中遇到IE兼容问题,处理随笔

    总是忘记给ie做特殊样式处理,以前打游击,不做也就算了,以后可不行,得对自己的“孩子”负责.. 一.先说IE老大的兼容 知道了一些常用的css属性兼容方法确实可以解决问题, 但我不知道我自己的ieTe ...