安装echo模块

下载模块

# pwd
/root
# git clone https://github.com/openresty/echo-nginx-module

重新编译

先查看版本,然后根据需要看是否需要升级nginx版本,这里是按原先的版本来添加echo模块。

# /opt/nginx/sbin/nginx -V
nginx version: nginx/1.6.3
built by gcc 4.4.7 20120313 (Red Hat 4.4.7-18) (GCC)
TLS SNI support enabled
configure arguments: --prefix=/opt/nginx --with-http_ssl_module --with-http_mp4_module --with-http_spdy_module --with-http_flv_module --with-http_stub_status_module --with-pcre
# wget http://nginx.org/download/nginx-1.6.3.tar.gz
# tar -xf nginx-1.6.3.tar.gz
# cd nginx-1.6.3
# ./configure --prefix=/opt/nginx --with-http_ssl_module --with-http_mp4_module --with-http_spdy_module --with-http_flv_module --with-http_stub_status_module --with-pcre --add-module=/root/echo-nginx-module/
# make

注意不要进行install 操作,为了避免覆盖正在使用的nginx程序。

# mv /opt/nginx/sbin/nginx /opt/nginx/sbin/nginx.old
# cp objs/nginx /opt/nginx/sbin/
# cd /opt/nginx/sbin/
# ./nginx -V
nginx version: nginx/1.6.3
built by gcc 4.4.7 20120313 (Red Hat 4.4.7-18) (GCC)
TLS SNI support enabled
configure arguments: --prefix=/opt/nginx --with-http_ssl_module --with-http_mp4_module --with-http_spdy_module --with-http_flv_module --with-http_stub_status_module --with-pcre --add-module=/root/echo-nginx-module/
# kill -USR2 `cat /opt/nginx/logs/nginx.pid`
# kill -QUIT `cat /opt/nginx/logs/nginx.pid.oldbin`

location 配置

nginx 配置文件

server {
server_name www.example.com;
listen 80;
access_log /data/log/nginx/www.example.com.log;
root /opt/web/www.example.com;
location / {
echo "/";
}
location = /{
echo "=/";
}
location = /nginx {
echo "=/nginx";
}
location /nginx/ {
echo "/nginx/";
} location ~ \.(gif|jpg|png|js|css)$ {
echo "small-gif/jpg/png";
}
location ~* \.png$ {
echo "all-png";
}
location ^~ /static/ {
echo "static";
}
}

下面需要做好本地hosts的域名解析,这里不做演示。

测试如下

# tree /opt/web/www.example.com/
/opt/web/www.example.com/
└── index.html 0 directories, 1 file
# curl http://www.example.com
=/
# curl http://www.example.com/nginx
=/nginx
# curl http://www.example.com/nginx/index.html
/nginx
# curl http://www.example.com/yyf/pangtouyu.png
small-gif/jpg/png
# curl http://www.example.com/yyf/pangtouyu.PNG
all-png
# curl http://www.example.com/static/pangtouyu.png
static
# curl http://www.example.com/static/pangtouyu.PNG
static
# curl http://www.example.com/nginx/a.txt
/

最新文章

  1. 非技术1-学期总结&ending 2016
  2. eclipse SE增加Web开发插件
  3. PHP图片加文字水印和图片水印方法(鉴于李老师博客因没加水印被盗,特搜集的办法。希望能有用!)
  4. Zookeeper学习之:paxos算法
  5. IIS错误处理集合
  6. ebs双节点webservice部署问题
  7. mysql 存储过程 死循环,如何关闭
  8. linux笔记:shell基础-bash变量
  9. [原]quick2.25让描边闪起来
  10. Unicode : RLO
  11. IOS开发经验分享
  12. 咏南DATASNAP中间件提供免费使用了
  13. .net求两个数的最大公约数和最小公倍数
  14. [转载]Unity3D 游戏引擎之使用C#语言建立本地数据库(SQLITE)
  15. 使用 APPLY
  16. JS采用ActiveXObject实现用户在提交表单时屏蔽敏感词的功能
  17. [Codeforces 873B]Balanced Substring
  18. MySQL 大表优化方案
  19. Spring DAO模块
  20. [Android] 基于 Linux 命令行构建 Android 应用(一):关于 Android 项目

热门文章

  1. 用python写web一定要去破解的异步请求问题.经历web.py和tornado,完破!
  2. C# WinForm 关于窗体最大化时的是否全屏效果与是否遮盖任务栏
  3. 关于UltraWinGrid选中行只读设置
  4. Linux常用基本命令(more)
  5. HDU4162(最小循环表示)
  6. ThinkPHP5+Layui实现图片上传加预览
  7. JavaSE——序列化和反序列化
  8. 解决ubuntu 16.04+ Qt 5.7.1无法输入中文的问题
  9. C#版Aliyun DNS API
  10. 如何使用Ubuntu中的avdManager命令行为“System-Image;Androd-27;GoogleAPI;x86”创建一个AVD?