使用Tengine+Lua+GM 实现图片自动裁剪缩放

#首先安装依赖
yum -y gcc

yum -y install openssl openssl-devel

yum -y install zlib zlib-devel pcre pcre-devel

yum -y unzip

#将所有的需要安装的东西上传打 /data/application/soft
cd /data/application/soft

#解压安装包
tar -zxvf lua-5.3.1.tar.gz
tar -zxvf LuaJIT-2.0.4.tar.gz
tar -zxvf GraphicsMagick-1.3.18.tar.gz
unzip tengine-master.zip


#安装lua 
cd /data/application/soft/lua-5.3.1

make

make install

#测试lua是否安装好 
lua -v 
# 显示 Lua 5.3.1  Copyright (C) 1994-2015 Lua.org, PUC-Rio



#安装 tengine-master
cd /data/application/soft/tengine-master

#给configure赋权
chomd 777 configure

#执行configure配置
./configure --prefix=/usr/local/Tengine --dso-path=/usr/local/Tengine/modules --with-http_realip_module --with-http_gzip_static_module --with-http_stub_status_module --with-http_concat_module --with-http_lua_module  --http-proxy-temp-path=/var/tmp/Tengine/proxy_temp --http-fastcgi-temp-path=/var/tmp/Tengine/fastcgi_temp --http-uwsgi-temp-path=/var/tmp/Tengine/uwsgi_temp --http-scgi-temp-path=/var/tmp/Tengine/cgi_temp --http-client-body-temp-path=/var/tmp/Tengine/client_body_temp --http-log-path=/var/log/Tengine/access.log --error-log-path=/var/log/Tengine/error.log

#安装
make 

make install

#执行防止报错 

ln -s /usr/local/lib/libluajit-5.1.so.2 /lib64/libluajit-5.1.so.2

mkdir -p /var/tmp/Tengine/client_body_temp

#启动 
/usr/local/Tengine/sbin/nginx

#访问网页开是否启动成功 80端口要开放 http://192.168.225.132/

#安装 GraphicsMagick-1.3.18

#安装依赖

yum -y install libjpeg libjpeg-devel libpng libpng-devel giflib giflib-devel freetype freetype-devel
 
cd /data/application/soft/GraphicsMagick-1.3.18

./configure --prefix=/usr/local/GraphicsMagick --enable-shared

make  

make install 

#查看是否安装成功 
/usr/local/GraphicsMagick/bin/gm version


#配置 lua脚本和 nginx文件
#创建 /usr/local/Tengine/lua
mkdir -p /usr/local/Tengine/lua

cd /usr/local/Tengine/lua
#将lua脚本上传
ImageResizer.lua 
#赋权 
chomd 777 ImageResizer.lua

#修改nginx.config,安装给的文件配置 



#配置好后 重启nginx
/usr/local/Tengine/sbin/nginx -t

/usr/local/Tengine/sbin/nginx -s reload

#上传文件到data/img

#浏览器访问
http://192.168.225.132/1.jpg_100x100.jpg

#服务器生成 
1.jpg_100x100.jpg

 

你可能感兴趣的:(使用Tengine+Lua+GM 实现图片自动裁剪缩放)