一、安装nginx时必须先安装相应的编译工具
yum -y install gcc gcc-c++ autoconf automake
yum -y install zlib zlib-devel openssl openssl-devel pcre-devel
zlib:nginx提供gzip模块,需要zlib库支持
openssl:nginx提供ssl功能
pcre:支持地址重写rewrite功能
二、执行解压命令解压 tar -zxvf nginx-1.6.2.tar.gz
三、编译和安装
cd nginx-1.6.2
------编译安装配置
# ./configure --prefix=/usr/local/nginx-1.6.2 --with-http_image_filter_module
------编译和安装
# make && make install
四、修改配置
在/usr/local/nginx-1.6.2/conf目录下的nginx.conf文件中的设置为文件服务器的server节点,增加如下内容:
location ~* ^/img/w_(\d+)/h_(\d+)/(.*)$ {
proxy_pass http://127.0.0.1/img/$3?width=$1&height=$2;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
#proxy_cache cache_one;
proxy_cache_valid 200 304 12h;
proxy_cache_key $host$uri$is_args$args;
add_header X-Cache "ImageCache Status: $upstream_cache_status";
}
location /img/{
alias /usr/local/nginx-1.6.2/html/img/;
image_filter resize $arg_width $arg_height;
image_filter_buffer 50M;
}
注:
/usr/local/nginx-1.6.2/html/img/ 为图片在linux上存放的位置
mage_filter_buffer 50M; 为最大图片缓冲大小
------启动
执行命令进行启动 /usr/local/nginx-1.6.2/sbin/nginx
访问:
原图
http://hostname/img/image4.jpg
压缩图:
http://hostname/img/resize/w_120/h_129/image4.jpg
相关推荐
Dockerfile 编译安装nginx FROM hub.c.163.com/netease_comb/centos:7 RUN yum install -y gcc gcc-c++ make openssl-devel pcre-devel #http://nginx.org/download/nginx-1.12.2.tar.gz ADD nginx-1.12.2....
Centos_6.3_编译安装Nginx+php+Mysql,基础文档
本篇内容详细讲解了编译安装nginx的过程和如何操作
一键编译安装nginx-1.12.2.txt
Windows下编译Nginx并添加模块,在项目中使用过的
添加nginx-http-flv-module模块并重新编译后的nginx(windows版)
centos7编译安装nginx
nginx源码编译安装;本人亲测,可以使用。nginx-1.10.2
离线编译nginx需要的包资源 1.安装pcre 2.安装zlib 3.安装openssl 解压tar -zxvf nginx-1.16.0.tar.gz cd nginx-1.16.0 ./configure make && make install 可能报错后需要的包都在里面
CentOS 6.2编译安装Nginx1.2.0+MySQL5.5.25+PHP5.3.13+Zend Guard Loader+WordPress-3.3.2中文版.pdf
nginx-1.6.0.tar.gz openssl-1.0.1h.tar.gz pcre-8.35.tar.gz zlib-1.2.8.tar.gz
centos 6.0最简化编译安装Nginx+Mysql+PHP+Zend
文章目录6 软件管理6.3 源码编译安装nginx,要求能直接运行nginx命令,启动web服务,并能访问网页 6 软件管理 6.3 源码编译安装nginx,要求能直接运行nginx命令,启动web服务,并能访问网页 (/usr/local/nginx) (rm ...
FreeBSD7.0编译安装nginx+php+mysql[定义].pdf
NULL 博文链接:https://kevin1.iteye.com/blog/902769
国产化环境麒麟v10系统arm64下安装nginx所有依赖
FreeBSD7.0编译安装nginx+php+mysql.pdf