您好,登錄后才能下訂單哦!
There are several dependences of zimg you should build and install before using zimg. And the version of cmake should >= 2.8, libevent should >= 2.0, libmemcached should >= 1.0.18.
yum install openssl-devel cmake libevent-devel libjpeg-devel giflib-devel libpng-devel libwebp-devel ImageMagick-devel libmemcached-devel
安裝需要的軟件,但是libwebp-devel yum上沒有
libwebp-devel、libevent和libmemcached需要重新編譯,因為yum 上的版本過低
1、安裝libevent
wget http://cloud.github.com/downloads/libevent/libevent/libevent-2.0.21-stable.tar.gz
tarzxvf libevent-2.0.17-stable.tar.gz
cd libevent-2.0.17-stable
./configure --prefix=/usr/local
make&& make install
2、安裝libmemcached
wget https://launchpad.net/libmemcached/1.0/1.0.18/+download/libmemcached-1.0.18.tar.gz
tarzxvf libmemcached-1.0.18.tar.gz
cd libmemcached-1.0.18
./configure -prefix=/usr/local
make && make install
3、安裝libwebp-devel
wget http://downloads.webmproject.org/releases/webp/libwebp-0.4.1.tar.gz(此文件暫時下載不下來 )
tarzxvf libwebp-0.4.1.tar.gz
cd libwebp-0.4.1
./configure
make
sudo make install
Now you can build zimg itself. If you want to gdbzimg, you can use make debug option.
git clone https://github.com/buaazp/zimg -b master --depth=1
cdzimg
make
If you want to enable cache to improve performance, or you want to store the images to a distributed storage backend, the softwares below is optional.
wget http://www.memcached.org/files/memcached-1.4.19.tar.gz
tarzxvf memcached-1.4.19.tar.gz
cd memcached-1.4.19
./configure --prefix=/usr/local
make
make install
git clone https://github.com/douban/beansdb
cdbeansdb
./configure --prefix=/usr/local
make
git clone git@github.com:douban/beanseye.git
cdbeanseye
make
wget --no-check-certificate https://github.com/ideawu/ssdb/archive/master.zip
unzip master
cdssdb-master
make
git clone git@github.com:twitter/twemproxy.git
cdtwemproxy
autoreconf -fvi
./configure --enable-debug=log
make
src/nutcracker -h
在運行zimg之前,你需要按照《Install文檔》的說明進行安裝,zimg安裝成功之后,即可簡單修改配置文件后啟動。zimg本身的所有選項都在配置文件中進行配置,你可以根據自己的需要修改配置文件:
--zimg server config
--server config
--是否后臺運行
is_daemon = 1
--綁定IP
ip = '0.0.0.0'
--端口
port = 4869
--運行線程數,默認值為服務器CPU數
--thread_num=4
backlog_num = 1024
max_keepalives = 1
retry = 3
system = io.popen('uname -sn'):read('*l')
pwd = io.popen('pwd'):read('*l')
--header config
--返回時所帶的HTTP header
headers = 'Cache-Control:max-age=7776000'
--是否啟用etag緩存
etag = 1
--access config
--support mask rules like 'allow 10.1.121.138/24'
--NOTE: remove rule can improve performance
--上傳接口的IP控制權限,將權限規則注釋掉可以提升服務器處理能力,下同
--upload_rule = 'allow all'
--下載接口的IP控制權限
--download_rule = 'allow all'
--管理接口的IP控制權限
admin_rule = 'allow 127.0.0.1'
--cache config
--是否啟用memcached緩存
cache = 1
--緩存服務器IP
mc_ip = '127.0.0.1'
--緩存服務器端口
mc_port = 11211
--log config
--log_level output specified level of log to logfile
--[[
LOG_FATAL 0 System is unusable
LOG_ALERT 1 Action must be taken immediately
LOG_CRIT 2 Critical conditions
LOG_ERROR 3 Error conditions
LOG_WARNING 4 Warning conditions
LOG_NOTICE 5 Normal, but significant
LOG_INFO 6 Information
LOG_DEBUG 7 DEBUG message
]]
--輸出log級別
log_level = 6
--輸出log路徑
log_name = pwd .. '/log/zimg.log'
--htdocconfig
--默認主頁html文件路徑
root_path = pwd .. '/www/index.html'
--admin頁面html文件路徑
admin_path = pwd .. '/www/admin.html'
--image process config
--禁用URL圖片處理
disable_args = 0
--禁用lua腳本圖片處理
disable_type = 0
--lua process script
--lua腳本文件路徑
script_name = pwd .. '/script/process.lua'
--format value: 'none' for original or other format names
--默認保存新圖的格式,字符串'none'表示以原有格式保存,或者是期望使用的格式名
format = 'jpeg'
--quality value: 1~100(default: 75)
--默認保存新圖的質量
quality = 75
--storage config
--zimg support 3 ways for storage images
--存儲后端類型,1為本地存儲,2為memcached協議后端如beansdb,3為redis協議后端如SSDB
mode = 1
--save_new value: 0.don't save any 1.save all 2.only save types in lua script
--新文件是否存儲,0為不存儲,1為全都存儲,2為只存儲lua腳本產生的新圖
save_new = 1
--上傳圖片大小限制,默認100MB
max_size = 100*1024*1024
--允許上傳圖片類型列表
allowed_type = {'jpeg', 'jpg', 'png', 'gif', 'webp'}
--mode[1]: local disk mode
--本地存儲時的存儲路徑
img_path = pwd .. '/img'
--mode[2]: beansdb mode
--beansdb服務器IP
beansdb_ip = '127.0.0.1'
--beansdb服務器端口
beansdb_port = 7900
--mode[3]: ssdb mode
--SSDB服務器IP
ssdb_ip = '127.0.0.1'
--SSDB服務器端口
ssdb_port = 8888
然后啟動zimg:
cd bin
./zimgconf/zimg.lua
zimg啟動之后就可以開始上傳和下載圖片了,上傳方式有兩種:
第一種是通過瀏覽器上傳,啟動zimg后的默認地址就是一個簡單的圖片上傳頁:
http://127.0.0.1:4869/
大約是這個樣子的:
上傳成功之后會以HTML的格式返回該圖片的MD5:
使用到的命令
http://zimg.buaa.us/documents/guidebookcn/免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。