circle_gif的作用:
The circle_gif module generates simple circle images with the colors and size
specified in the URL. The images are served quickly, much faster than if they
had been read from disk. The module was made to help web designers change the
colors of their "round corners" without having to fire up PhotoShop.
1. get nginx
wget http://nginx.org/download/nginx-0.8.54.tar.gz
note: 针对circle_gif这个module还是下载较新的nginx吧,以前为了看代码,下载的0.5.x版本的nginx, 编译不通过.
2. 安装ImageMagick
circle_gif依赖于ImageMagick
2.1 fetch最新的代码,开发机上的版本太低.
wget ftp://ftp.imagemagick.org/pub/ImageMagick/ImageMagick.tar.gz
2.1编译安装
make --prefix=/opt/imagemagick
make -j 8
sudo make install
3.编译nginx
3.0 fetch circle_gif module的源代码:
git clone git://github.com/evanmiller/nginx_circle_gif.git
3.1 现在我安装的imagemagick不在标准位置,这得修改一下circle_gif目录下的config文件:
ngx_feature="MagickWand"
ngx_feature_name=
ngx_feature_run=no
ngx_feature_incs="#include
ngx_feature_path="/opt/imagemagick/include/ImageMagick"
ngx_feature_libs=-lMagickWand
ngx_feature_test="MagickWandGenesis()"
NGX_TEST_LD_OPT="-L /opt/imagemagick/lib $NGX_TEST_LD_OPT"
. auto/feature
if [ $ngx_found = yes ]; then
ngx_addon_name=ngx_http_circle_gif_module
HTTP_MODULES="$HTTP_MODULES ngx_http_circle_gif_module"
NGX_ADDON_SRCS="$NGX_ADDON_SRCS $ngx_addon_dir/ngx_http_circle_gif_module.c"
CORE_LIBS="$CORE_LIBS -L /opt/imagemagick/lib -lMagickWand"
CFLAGS="$CFLAGS `MagickWand-config --cflags`"
else
cat << END
$0: error: the Circle GIF addon requires the ImageMagick library.
END
exit 1
fi
3.2 编译,安装
cd nginx-0.8.54
./configure --add-module=/home/tangyi/program/cc/nginx_circle_gif --prefix=/home/tangyi/circle
4. 启服务
修改conf/nginx.conf文件
添加
location /circles {
circle_gif;
}
修改监听端口为3000
启服务:
cd ~/circle
./sbin/nginx
5. 访问
wget http://localhost:3000/circles/ffffff/000000/20.gif
最后得到的图片:
nginx的平滑重启:
kill -HUP <nginx masterPID>

没有评论:
发表评论