Nginx 1.4.7 Image Cache Server

Source: Internet
Author: User

    1. Package version:

Nginx 1.4.7

ngx_cache_purge-2.0

Openssl-1.0.1

Pcre-8.32

Second, installation and compilation:

a) Download pcre-8.32.tar.gz
Tar zvxf pcre-8.32.tar.gz
CD pcre-8.32 &&./configure && make && make install

b) Download openssl-1.0.1.tar.gz
CD OpenSSL &&./configure && make && make install

c) Download Ngx_cache_purge-2.0.zip
Unzip Ngx_cache_purge-2.0.zip

d) Download 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

Three, nginx configuration:

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 the can is 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. Compiling 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 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;

}

Iv. Check that the configuration information is correct

Five, start the Nginx service

/etc/init.d/nginxd start

Ps–aux |grep Nginx

Vi. manual removal of the picture cache

Nginx 1.4.7 Image Cache Server

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.