Nginx 1.4.7图片缓存服务器

  1. 软件包版本:

Nginx 1.4.7

Ngx_cache_purge-2.0

Openssl-1.0.1

Pcre-8.32

二、安装编译:

a)         下载pcre-8.32.tar.gz      
tar zvxf pcre-8.32.tar.gz
cd pcre-8.32 && ./configure && make && make install

b)         下载openssl-1.0.1.tar.gz
cd openssl && ./configure && make && make install

c)         下载ngx_cache_purge-2.0.zip
unzip ngx_cache_purge-2.0.zip

d)         下载nginx-1.4.7.tar.gz
cd nginx-1.4.7
./configure --prefix=/opt/nginx --add-module=../ngx_cache_purge-2.0 --with-http_stub_status_module --with-http_realip_module --with-http_ssl_module --with-pcre=../pcre-8.32 --with-openssl=/opt/soft/openssl-1.0.1

Make && make install

三、nginx配置:

a)         Vi /opt/nginx/conf/nginx.conf

user  www www;

worker_processes 8;

error_log  /opt/nginx/logs/nginx_error.log  crit;

pid        /opt/nginx/logs/nginx.pid;

#Specifies the value for maximum file descriptors that can be opened by this process.

worker_rlimit_nofile 51200;

events

{

use epoll;

worker_connections 65535;

}

http

{

include       mime.types;

default_type  application/octet-stream;

server_names_hash_bucket_size 128;

client_header_buffer_size 32k;

large_client_header_buffers 4 32k;

client_max_body_size 300m;

sendfile on;

tcp_nopush     on;

keepalive_timeout 60;

tcp_nodelay on;

fastcgi_connect_timeout 300;

fastcgi_send_timeout 300;

fastcgi_read_timeout 300;

fastcgi_buffer_size 64k;

fastcgi_buffers 4 64k;

fastcgi_busy_buffers_size 128k;

fastcgi_temp_file_write_size 256k;

client_body_buffer_size 512k;

proxy_connect_timeout 5;

proxy_read_timeout 60;

proxy_send_timeout 5;

proxy_buffer_size 16k;

proxy_buffers 4 64k;

proxy_busy_buffers_size 128k;

proxy_temp_file_write_size 128k;

proxy_temp_path /opt/nginx/html/images/images_temp;

proxy_cache_path /opt/nginx/html/images/images_cache levels=1:2 keys_zone=content:200m inactive=1d max_size=30g;

gzip on;

gzip_min_length  1k;

gzip_buffers     4 16k;

gzip_http_version 1.0;

gzip_comp_level 2;

gzip_types       text/plain application/x-javascript text/css application/xml;

gzip_vary on;

gzip_proxied        expired no-cache no-store private auth;

gzip_disable        "MSIE [1-6]\.";

#limit_zone  crawler  $binary_remote_addr  10m;

server_tokens off;

#log format

log_format  access  '$remote_addr - $remote_user [$time_local] "$request" '

'$status $body_bytes_sent "$http_referer" '

'"$http_user_agent" $http_x_forwarded_for';

include vhost/cqnt.conf;

}

  1. 编译vhost/cqnt.conf

server

{

listen       80;

server_name images.lencee.com 192.168.0.107;

index index.html index.htm index.php default.html default.htm default.php;

root  /opt/app/img;

access_log /opt/nginx/logs/80pic.log access;

location ~ /purge(/.*){

allow 192.168.1.0/24;

deny       all;

proxy_cache_purge content $host$1$is_args$args;

}

location ~ .*\.(php|php5)?$

{

try_files $uri =404;

fastcgi_pass  unix:/tmp/php-cgi.sock;

fastcgi_index index.php;

#                      include fcgi.conf;

}

#        location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$

location ~ .*\.(cgi|php|jsp|swf)?$

{

expires      30d;

proxy_cache content;

proxy_cache_valid 200 304 301 302 10d;

proxy_cache_valid any 1d;

proxy_set_header Host $host;

proxy_set_header X-Forwarded-For $remote_addr;

proxy_cache_key $host$uri$is_args$args;

proxy_pass http://192.168.0.107:8080;

}

location ~ .*\.(js|css)?$

{

expires      12h;

}

}

server

{

listen 8080;

server_name 192.168.0.107;

root /opt/nginx/img/;

location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$

{

expires      30d;

access_log  /opt/nginx/logs/8080pic.log access;

}

access_log on;

}

四、检查配置信息是否正确

Nginx 1.4.7图片缓存服务器

五、启动Nginx服务

/etc/init.d/nginxd start

Ps –aux |grep nginx

Nginx 1.4.7图片缓存服务器

六、手动清除图片缓存

Nginx 1.4.7图片缓存服务器

上一篇:window.location.href无法跳转的解决办法


下一篇:Mybatis 代码自动生成[myeclipse版]