现状
由于业务要求,我们需要图片服务
替换repo为国内aliyun
wget http://mirrors.aliyun.com/repo/Centos-7.repo -O /etc/yum.repos.d/CentOS-Base.repo
rpm -ivh http://rpms.famillecollet.com/enterprise/remi-release-7.rpm
安装脚本
#!/bin/bash
#james.liu
#图片服务器搭建
#
srcDir="/opt/Zimg/"
if [ ! -d $srcDir ];then
echo "目录不存在!!!"
mkdir $srcDir
fi
envSet(){
systemctl stop firewalld
systemctl disable firewalld
sed -i 's/^SELINUX=.*/SELINUX=disabled/p' /etc/sysconfig/selinux
}
cd $srcDir
echo 所在目录:`pwd`
depsInstall(){
yum -y install wget openssl-devel cmake libevent-devel libjpeg-devel giflib-devel libpng-devel \
libwebp-devel ImageMagick-devel libmemcached-devel make gcc gcc-c++ nasm \
autoconf automake libtool git
}
respaceYum(){
wget http://mirrors.aliyun.com/repo/Centos-7.repo -O /etc/yum.repos.d/CentOS-Base.repo
}
installOpenssl(){
cd $srcDir
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
}
installCmake(){
cd $srcDir
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
}
installLibevent(){
cd $srcDir
wget https://github.com/libevent/libevent/releases/download/release-2.1.8-stable/libevent-2.1.8-stable.tar.gz
tar zxvf libevent-2.1.8-stable.tar.gz
cd libevent-2.1.8-stable.tar.gz
./configure --prefix=/usr/local
make && make install
}
installLibjpeg-turbo(){
cd $srcDir
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
}
installWebp(){
cd $srcDir
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
}
installImageMagick(){
cd $srcDir
wget http://www.imagemagick.org/download/ImageMagick.tar.gz
tar zxvf ImageMagick.tar.gz
cd ImageMagick-*
./configure --prefix=/usr/local
make && make install
}
installLibmemcached(){
cd $srcDir
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
}
installZimg(){
cd $srcDir
git clone https://github.com/buaazp/zimg -b master --depth=1
cd zimg
make
}
installmemcached(){
cd $srcDir
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
}
##启动
startZimg(){
cd $srcDir/zimg/bin
./zimg -d conf/zimg.lua
}
envSet
depsInstall
respaceYum
installOpenssl
installCmake
installLibevent
installLibjpeg-turbo
installWebp
installImageMagick
installLibmemcached
installZimg
installmemcached
startZimg
测试
图片服务器图片服务器
网友评论