详细配置步骤:
lua+nginx+GraphicsMagick
环境: CentOSsh5.4_x64.iso
虚拟机: Vmware9.0
yum install readline-devel pcre-devel openssl-devel
cd /opt/Source
wget http://agentzh.org/misc/nginx/ngx_openresty-1.0.15.10.tar.gz
useradd -r www
tar vxzf ngx_openresty-1.0.15.10.tar.gz
cd ngx_openresty-1.0.15.10
./configure --user=www --group=www --prefix=/usr/local/openresty \
--with-luajit \
--without-http_redis2_module \
--with-http_iconv_module
make -j4 # -j后面的cpu核心数,如果是多核可以写相应的个数
make install
安装jpg环境:
tar xf libjpeg-6b.tar.gz
./configure
make && make install
tar xf libpng-1.4.7.tar.gz
./configure
make && make install
注意: 64位系统需要拷贝
cp /usr/local/lib/libpng14.so.14 /lib64/ 或者做软连接,不然执行gm命令的时候会报错!
cd /opt/Source
wget http://downloads.sourceforge.net/project/graphicsmagick/graphicsmagick/1.3.16/GraphicsMagick-1.3.16.tar.gz
tar vxzf GraphicsMagick-1.3.16.tar.gz
cd GraphicsMagick-1.3.16
./configure
make&& make install
配置nginx nginx.conf
#user nobody;
worker_processes 1;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
#log_format main '$remote_addr - $remote_user [$time_local] "$request" '
# '$status $body_bytes_sent "$http_referer" '
# '"$http_user_agent" "$http_x_forwarded_for"';
#access_log logs/access.log main;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
#gzip on;
server {
listen 80;
server_name localhost;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
root html;
index index.html index.htm;
}
location /lua1 {
default_type 'text/plain';
rewrite_by_lua 'ngx.say("hello, lua")';
}
location /upload/ {
set $image_root /usr/local/openresty/nginx/html;
set $file "$image_root$uri";
if (!-f $file) {
rewrite_by_lua '
local index = string.find(ngx.var.uri, "([0-9]+)x([0-9]+)");
if (index == nil) then
相关文章
- 40M左右的大图片如何在页面上展示啊?还要实现以鼠标为中心缩放功能
- nginx+lua+GraphicsMagick实现图片自动缩放功能(强烈推荐)
- 使用nginx+lua+GraphicsMagick实现图片自动 裁剪
- PHP实现图片的等比缩放和Logo水印功能示例
- Android图片滚动,加入自动播放功能,使用自定义属性实现,霸气十足!
- Android实现自动播放图片功能
- PHP实现将上传图片自动缩放到指定分辨率,并保持清晰度封装类示例
- nginx+lua+GraphicsMagick实现图片自动缩放功能(强烈推荐)
- 使用nginx+Lua+GraphicsMagick实现图片自动裁剪
- Swift缩放并填充图片功能的实现