zimg服务器搭建手记

zimg是由国人开源的一个高性能的图片服务器,相关介绍和代码可从github上获取: 
https://github.com/buaazp/zimg  


1.安装Openssl (这个很关键,必须先安装) 
wget http://www.openssl.org/source/openssl-1.0.1e.tar.gz 
tar zxvf  openssl-1.0.1e.tar.gz 
./config shared --prefix=/usr --openssldir=/usr/ssl 
make && make install 



2. 安装 libevent (http://libevent.org/) 
wget http://cloud.github.com/downloads/libevent/libevent/libevent-2.0.21-stable.tar.gz 
tar zxvf libevent-2.0.17-stable.tar.gz 
./configure --prefix=/usr 
make && make install 


3.安装Cmake 
wget "http://www.cmake.org/files/v2.8/cmake-2.8.10.2.tar.gz"tar xzvf cmake-2.8.10.2.tar.gz 
cd cmake-2.8.10.2 
./bootstrap --prefix=/usr 

make && make install 


4.安装Libevhtp 
wget --no-check-certificate  https://github.com/ellzey/libevhtp/archive/1.2.6.tar.gz -O libevhtp-1.2.6.tar.gz 
tar xzvf libevhtp-1.2.6.tar.gz 
cd libevhtp-1.2.6/ 
cmake -DCMAKE_PREFIX_PATH=/usr -DCMAKE_INSTALL_PREFIX=/usr  -DLIBEVENT_OPENSSL_LIBRARY=/usr/lib/openssl 

make && make install 



5.安装ImageMagick 
#安装图片库 

yum -y install libjpeg libjpeg-devel libpng libpng-devel 

wget http://www.imagemagick.org/download/ImageMagick-6.8.7-2.tar.gz 

tar xzvf ImageMagick-6.8.7-2.tar.gz 

cd ImageMagick-6.8.7-2 

./configure  --with-perl 

make && make install 



6.安装 libmemcached 
wget http://download.tangent.org/libmemcached-0.42.tar.gz 
tar zxvf libmemcached-0.42.tar.gz 
cd libmemcached-0.42 
./configure --with-jp2=yes --with-png=yes --with-jpeg=yes LDFLAGS='-L/usr/lib' 
make && make install 

7.安装zimg 
wget  https://github.com/buaazp/zimg/archive/master.zip -O zimg.zip 
unzip zimg.zip 
cd zimg-master 

#编译 
make 



#启动 
./zimg 





#支持启动参数 
-p [port] 监听端口号,默认4869 
-t [thread_num] 线程数,默认4,请调整为具体服务器的CPU核心数 
-k [max_keepalive_num] 最高保持连接数,默认1,不启用长连接,0为启用 
-l 启用log,会带来很大的性能损失,自行斟酌是否开启 
-M [memcached_ip] 启用缓存的连接IP 
-m [memcached_port] 启用缓存的连接端口 
-b [backlog_num] 每个线程的最大连接数,默认1024,酌情设置 




调用demo: 

upload.html 

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
<html> 
    <form enctype="multipart/form-data" action="http://192.168.111.189:9000/upload" method=post> 
    选择文件: 
    <input name="userfile" type="file"> 
    <input type="submit" value="上传"> 
    </form> 
</html> 

选择图片提交,返回: 

MD5:16448cd6ec7af958e948e07267798042 
上传路径: 
http://192.168.111.189:9000/upload 

访问原图: 

http://192.168.111.189:9000/16448cd6ec7af958e948e07267798042 

裁剪: 
http://192.168.111.189:9000/16448cd6ec7af958e948e07267798042?w=200&h=200 

灰化: 
http://192.168.111.189:9000/16448cd6ec7af958e948e07267798042?g=1 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值