0
点赞
收藏
分享

微信扫一扫

nginx动态图片不同格式提供模块

有点d伤 2021-09-29 阅读 80
日记本

nginx下载:

wget http://nginx.org/download/nginx-1.8.0.tar.gz

解压: tar -zxvf  nginx-1.8.0.tar.gz

cd nginx-1.8.0

源码编译安装:

./configure --prefix=/usr/local/nginx --pid-path=/var/run/nginx/nginx.pid --lock-path=/var/lock/nginx.lock --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --with-http_gzip_static_module --with-http_stub_status_module --with-http_image_filter_module --http-client-body-temp-path=/var/temp/nginx/client --http-proxy-temp-path=/var/temp/nginx/proxy --http-fastcgi-temp-path=/var/temp/nginx/fastcgi --http-uwsgi-temp-path=/var/temp/nginx/uwsgi --http-scgi-temp-path=/var/temp/nginx/scgi

nginx make:

make

nginx 安装: [安装在  --prefix=/usr/local/nginx  目录下面]

make install  


配置 动态图片提供配置:


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 ~* /(.+)\.(jpg|git|png|ioc|jpeg)_(\d+)_(\d+)$ {

set $w $3;

set $h $4;

rewrite /(.+)\.(jpg|git|png|ioc|jpeg)_(\d+)_(\d+)$ /$1.$2 break;

image_filter resize $w $h;

image_filter_buffer 10M;

root  html;

}


#error_page  404              /404.html;

# redirect server error pages to the static page /50x.html

#

error_page  500 502 503 504  /50x.html;

location = /50x.html {

root  html;

}

# proxy the PHP scripts to Apache listening on 127.0.0.1:80

#

#location ~ \.php$ {

#    proxy_pass  http://127.0.0.1;

#}

# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000

#

#location ~ \.php$ {

#    root          html;

#    fastcgi_pass  127.0.0.1:9000;

#    fastcgi_index  index.php;

#    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;

#    include        fastcgi_params;

#}

# deny access to .htaccess files, if Apache's document root

# concurs with nginx's one

#

#location ~ /\.ht {

#    deny  all;

#}

}




访问图片:

http://192.168.18.128/girl.jpg_500_100


http://192.168.18.128/girl.jpg_500_500


对比效果

举报

相关推荐

0 条评论