图片服务器zimg的搭建案例

2020/03 作者:ihunter 0 0

zimg是图像存储和处理服务器。您可以使用URL参数从zimg获取压缩和缩放的图像。

zimg的并发I / O,分布式存储和时间处理能力非常出色。

您不再需要在图像服务器中使用nginx。在基准测试中,zimg可以在高并发级别上处理每秒3000+图像下载任务和每秒90000+ HTTP回应请求,性能高于PHP或其他图像处理服务器。


1. 安装依赖库:

sudo yum install -y wget openssl-devel cmake libevent-devel libjpeg-devel giflib-devel libpng-devel libwebp-devel ImageMagick-devel libmemcached-devel 

sudo yum install -y glibc-headers gcc-c++
sudo yum install -y build-essential nasm


2. 安装openssl

mkdir /usr/local/
cd /usr/local/
wget http://www.openssl.org/source/openssl-1.0.1i.tar.gz
tar zxvf openssl-1.0.1i.tar.gz
cd openssl-1.0.1i
./config shared --prefix=/usr/local --openssldir=/usr/ssl
make && make install


3. 安装cmake

mkdir -p /usr/local/
cd /usr/local/
wget http://www.cmake.org/files/v3.0/cmake-3.0.1.tar.gz
tar xzvf cmake-3.0.1.tar.gz
cd cmake-3.0.1
./bootstrap --prefix=/usr/local
make && make install


4. 安装libevent

mkdir -p /usr/local/
cd /usr/local/
wget http://cloud.github.com/downloads/libevent/libevent/libevent-2.0.21-stable.tar.gz
tar zxvf libevent-2.0.21-stable.tar.gz
cd libevent-2.0.21-stable
./configure --prefix=/usr/local
make && make install

5. 安装libjpeg-turbo

mkdir -p /usr/local/
cd /usr/local/
wget https://downloads.sourceforge.net/project/libjpeg-turbo/1.3.1/libjpeg-turbo-1.3.1.tar.gz
tar zxvf libjpeg-turbo-1.3.1.tar.gz
cd libjpeg-turbo-1.3.1
./configure --prefix=/usr/local --with-jpeg8
make && make install


下面这几个,如果采取源代码构建,不需要安装


1. 安装webp

mkdir /usr/local/
cd /usr/local/
wget http://downloads.webmproject.org/releases/webp/libwebp-0.4.1.tar.gz
tar zxvf libwebp-0.4.1.tar.gz
cd libwebp-0.4.1
./configure
make
sudo make install

完成


2. 安装jpegsrc

mkdir /usr/local/
cd /usr/local/zimg/
wget http://www.ijg.org/files/jpegsrc.v8b.tar.gz
tar -xf jpegsrc.v8b.tar.gz
cd jpeg-8b
./configure --prefix=/usr/local --enable-shared --enable-static
make && make install

安装完成


3. 安装imageMagic

mkdir /usr/local/
cd /usr/local/
wget http://www.imagemagick.org/download/ImageMagick.tar.gz
tar zxvf ImageMagick.tar.gz
cd ImageMagick-6.9.1-10
./configure --prefix=/usr/local
make && make install


4. 安装libmemcached

wget https://launchpad.net/libmemcached/1.0/1.0.18/+download/libmemcached-1.0.18.tar.gz
tar zxvf libmemcached-1.0.18.tar.gz
cd libmemcached-1.0.18
./configure -prefix=/usr/local
make && make install


5. 构建zimg

cd /usr/local

##此处不要根据下面链接去下载,自己去zimg github地址库区下载release 版;

#git clone https://github.com/buaazp/zimg -b master --depth=1
如果项目名称是zimg-master, 那么重命名为 zimg
mv zimg-master zimg
cd zimg
make

再make之前,先进入到解压目录zimg/deps, 把/zimg/deps中的libjpeg-turboxxx和libwebpxxx删除, 把前面安装使用的对应的的libjpeg-turbo.tar.gz和libwebpXXX.tar.gz包复制后来, 注意是tar包, 即.tar.gz, 之后我们再make ,否则会报错

如果Make之后报错,处理方法如下:

yum install -y wget libhdf5-serial-dev hdf5-tools


11可选的插件


11.1 Memcached

wget http://www.memcached.org/files/memcached-1.4.19.tar.gz

tar zxvf memcached-1.4.19.tar.gz

cd memcached-1.4.19

./configure --prefix=/usr/local

make

make install


11.2 beansdb

git clone https://github.com/douban/beansdb

cd beansdb

./configure --prefix=/usr/local

make


11.3 SSDB

wget --no-check-certificate https://github.com/ideawu/ssdb/archive/master.zip

unzip master

cd ssdb-master

make


11.4 twemproxy

git clone git@github.com:twitter/twemproxy.git

cd twemproxy

autoreconf -fvi

./configure --enable-debug=log

make

src/nutcracker -h


12安装成功后启动

cd /usr/local/zimg/bin

./zimg conf/zimg.lua

ctrl+z 退出

crul http://localhost/4869

如果出现html代码 则说明安装启动成功。


赞(1) 更多分享

上篇: JupyterLab,极其强大的下一代notebook!
下篇: 今日头条这么牛逼,用了什么技术?