码迷,mamicode.com
首页 > 其他好文 > 详细

nginx反向代理及缓存清理

时间:2018-01-13 20:54:32      阅读:201      评论:0      收藏:0      [点我收藏+]

标签:dir   download   for   water   conf   txt   cti   error_log   nginx反向代理   

#下载安装包
wget http://nginx.org/download/nginx-1.13.7.tar.gz
wget http://labs.frickle.com/files/ngx_cache_purge-2.3.tar.gz
wget https://nchc.dl.sourceforge.net/project/pcre/pcre/8.40/pcre-8.41.tar.bz2

#--------------- 在未安装nginx的情况下安装ngx_cache_purge ---------------#
cd nginx-1.13.7
./configure --prefix=/usr/local/nginx \
--with-pcre=/opt/pcre-8.41 \
--user=www \
--group=www \
--with-http_stub_status_module \
--with-http_ssl_module \
--with-http_flv_module \
--with-http_gzip_static_module
--add-module=/opt/ngx_cache_purge-2.3

make
make install

#--------------- 在已安装nginx情况下安装ngx_cache_purge ---------------#
cd nginx-1.13.7
./configure --prefix=/usr/local/nginx \
--with-pcre=/opt/pcre-8.41 \
--user=www \
--group=www \
--with-http_stub_status_module \
--with-http_ssl_module \
--with-http_flv_module \
--with-http_gzip_static_module
--add-module=/opt/ngx_cache_purge-2.3

make //千万不要make install,不然就真的覆盖了

/etc/init.d/nginx stop
mv /usr/local/nginx/sbin/nginx /usr/local/nginx/sbin/nginx.bak
cp objs/nginx /usr/local/nginx/sbin/nginx

#nginx反向代理及缓存清理

#user nobody;
worker_processes 8;

#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;

#pid logs/nginx.pid;

events {
worker_connections 65535;
}

http {
include mime.types;
default_type application/octet-stream;

技术分享图片

技术分享图片

技术分享图片

}

#---------------- nginx缓存清理脚本 ------------------------#
cat atuo_nginx_cache_clean.sh

#!/bin/bash
mfile="$*"
cache_dir=/data/cache1
echo $mfile
if [ "$#" -eq 0 ]
then
echo "please input scripts, if not, it will exit"
sleep 2 && exit
fi
echo "what you put $mfile will delete, please wait..."
for i in echo $mfile | sed ‘s/ /\n/g‘
do
grep -ira $i $cache_dir | awk -F ‘:‘ ‘{print $1}‘ > /tmp/cache_list.txt
for j in cat /tmp/cache_list.txt
do
rm -rf $j
echo "$i $j is delete Success!"
done
done

#脚本用法
./atuo_nginx_cache_clean.sh aa.jpg bb.js cc.html

技术分享图片

nginx反向代理及缓存清理

标签:dir   download   for   water   conf   txt   cti   error_log   nginx反向代理   

原文地址:http://blog.51cto.com/chenxiaoming/2060639

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!