#useradd www //使用www用户运行
nginx
#
yum -y install openssl //使nginx 加载openssl模块
/usr/local/src/
#cd /usr/local/src/
#tar -jxvf pcre-8.32.tar.bz2 && cd pcre-8.32
#./configure
pcre-8.32 configuration summary:
Install prefix .................. : /usr/local
C preprocessor .................. : gcc -E
C compiler ...................... : gcc
C++ preprocessor ................ : g++ -E
C++ compiler .................... : g++
Linker .......................... : /usr/bin/ld
C preprocessor flags ............ :
C compiler flags ................ : -O2 -fvisibility=hidden
C++ compiler flags .............. : -O2 -fvisibility=hidden -fvisibility-inlines-hidden
Linker flags .................... :
Extra libraries ................. :
Build 8 bit pcre library ........ : yes
Build 16 bit pcre library ....... : no
Build 32 bit pcre library ....... : no
Build C++ library ............... : yes
Enable JIT compiling support .... : no
Enable UTF-8/16/32 support ...... : no
Unicode properties .............. : no
Newline char/sequence ........... : lf
\R matches only ANYCRLF ......... : no
EBCDIC coding ................... : no
EBCDIC code for NL .............. : n/a
Rebuild char tables ............. : no
Use stack recursion ............. : yes
POSIX mem threshold ............. : 10
Internal link size .............. : 2
Match limit ..................... : 10000000
Match limit recursion ........... : MATCH_LIMIT
Build shared libs ............... : yes
Build static libs ............... : yes
Use JIT in pcregrep ............. : no
Buffer size for pcregrep ........ : 20480
Link pcregrep with libz ......... : no
Link pcregrep with libbz2 ....... : no
Link pcretest with libedit ...... : no
Link pcretest with libreadline .. : no
Valgrind support ................ : no
Code coverage ................... : no
#make && make install
#tar -zxvf ngx_cache_purge-2.0.tar.gz
#tar -zxvf nginx-1.3.9.tar.gz
#cd nginx-1.3.9
#./configure --user=www --group=www --add-module=../ngx_cache_purge-2.0 --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module
Configuration summary
+ using system PCRE library
+ using system OpenSSL library
+ md5: using OpenSSL library
+ sha1: using OpenSSL library
+ using system zlib library
nginx path prefix: "/usr/local/nginx"
nginx binary file: "/usr/local/nginx/sbin/nginx"
nginx configuration prefix: "/usr/local/nginx/conf"
nginx configuration file: "/usr/local/nginx/conf/nginx.conf"
nginx pid file: "/usr/local/nginx/logs/nginx.pid"
nginx error log file: "/usr/local/nginx/logs/error.log"
nginx http access log file: "/usr/local/nginx/logs/access.log"
nginx http client request body temporary files: "client_body_temp"
nginx http proxy temporary files: "proxy_temp"
nginx http fastcgi temporary files: "fastcgi_temp"
nginx http uwsgi temporary files: "uwsgi_temp"
nginx http scgi temporary files: "scgi_temp"
user www;
worker_processes 1;
worker_rlimit_nofile 30000;
error_log logs/error.log;
pid logs/nginx.pid;
events {
use epoll;
worker_connections 35000;
}
http {
include mime.types;
default_type application/octet-stream;
charset utf-8;
sendfile on;
tcp_nopush on;
server_names_hash_bucket_size 128;
client_header_buffer_size 32k;
large_client_header_buffers 4 32k;
client_max_body_size 10m;
tcp_nodelay on;
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;
keepalive_timeout 65;
gzip on;
gzip_disable "MSIE [1-6]\.";
gzip_proxied any;
gzip_comp_level 5;
gzip_buffers 16 8k;
gzip_min_length 1k;
gzip_vary on;
gzip_types text/plain text/css image/gif image/jpeg image/png application/json application/x-javascripttext/xml application
/xml application/xml+rss text/javascript;
proxy_temp_path /usr/local/cache/img_temp;
proxy_cache_path /usr/local/cache/img_cache levels=1:2 keys_zone=pic_cache:500m inactive=1d max_size=10g;
server {
listen 80;
server_name 192.168.198.130;
access_log logs/pic.log;
location / {
proxy_cache pic_cache;
proxy_cache_valid 200 304 24h;
proxy_cache_key $host$uri$is_args$args;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_pass http://192.168.198.130:88;
expires 1d;
}
location ~ /purge(/.*) {
allow 127.0.0.1;
allow 192.168.198.0/24;
deny all;
proxy_cache_purge pic_cache $host$1$is_args$args;
}
error_page 500 502 503 504 /50x.html;
}
#假设后端
server {
listen 88;
server_name 192.168.198.130;
root /usr/local/cache/img_s;
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|ico)$ {
expires 1d;
access_log logs/88pic.log; //方便测试时查看使用
}
}
}