Nginx第三方扩展
最近试用了几个@agentzh写的第三方Nginx模块,甚为愉悦,没想到在Nginx可以玩很多技巧和扩展,分享一下。
本文尝试的几个模块大概分为:
- echo
- memcached
- nginx
- lua
详细模块地址分别为:
- ngx_devel_kit https://github.com/simpl/ngx_devel_kit
- set-misc-nginx-module https://github.com/agentzh/set-misc-nginx-module
- memc-nginx-module https://github.com/agentzh/memc-nginx-module
- echo-nginx-module https://github.com/agentzh/echo-nginx-module
- lua-nginx-module https://github.com/chaoslawful/lua-nginx-module
- srcache-nginx-module https://github.com/agentzh/srcache-nginx-module
- drizzle-nginx-module https://github.com/chaoslawful/drizzle-nginx-module
- rds-json-nginx-module https://github.com/agentzh/rds-json-nginx-module
为了省事这里一股脑把上面的module全部下载好,一起编译。PS:可以尝试下openresty项目,它帮你打包好Nginx和一堆扩展模块,得感谢@agentzh。
这里编译和drizzle和lua模块,在编译Nginx之前需要设置一下这两个库的LIB和INCLUDE文件地址:
首先安装这两个包:
wget http://luajit.org/download/LuaJIT-2.0.0-beta9.tar.gz
tar zxvf LuaJIT-2.0.0-beta9.tar.gz
cd LuaJIT-2.0.0-beta9.tar.gz
make
make install PREFIX=/usr/local/luajit
ln -sf luajit-2.0.0-beta9 /usr/local/bin/luajit
wget https://launchpad.net/ubuntu/maverick/+source/libdrizzle/0.8-1/+files/libdrizzle_0.8.orig.tar.gz
tar zxvf libdrizzle_0.8.orig.tar.gz
cd libdrizzle_0.8.orig
./configure
make && make isntall
然后加入环境变量
-- drizzle --
export LIBDRIZZLE_INC=/usr/local/include/libdrizzle
export LIBDRIZZLE_LIB=/usr/local/lib
-- lua --
# tell nginx's build system where to find lua:
export LUA_LIB=/path/to/lua/lib
export LUA_INC=/path/to/lua/include
# or tell where to find LuaJIT when if using JIT instead
export LUAJIT_LIB=/usr/local/luajit/lib
export LUAJIT_INC=/usr/local/luajit/include/luajit-2.0
Nginx编译选项如下,先将以上包解压后修改名称,请注意先后顺序:
./configure --prefix=/usr/local/nginx --user=www --group=www --with-http_stub_status_module --with-http_ssl_module --add-module=../simpl-ngx_devel_kit --add-module=../set-misc-nginx-module --add-module=../memc-nginx-module --add-module=../echo-nginx-module --add-module=../lua-nginx-module --add-module=../srcache-nginx-module --add-module=../drizzle-nginx-module --add-module=../rds-json-nginx-module
重新编译Nginx二进制,Nginx需要quit再启动。而普通配置更新则reload即可:
kill -HUP `cat /path/nginx/logs/nginx.pid`
/usr/local/nginx/sbin/nginx -s reload
详细的模块编译可以参考各自模块的文档说明,http://wiki.nginx.org/3rdPartyModules
posted on 2012-02-10 11:11 kudosharry 阅读(865) 评论(0) 编辑 收藏 举报