首页 » WEB技术 » Nginx » nginx+proxy_cache 配置高速缓存

nginx+proxy_cache 配置高速缓存

 
文章目录

Nginx+lua+proxy_cache 搭建高速缓冲

环境:
CentOS release 6.5 192.168.10.158
安装前准备好如下软件包
nginx  地址:http://www.nginx.org
luajit 地址:http://luajit.org/download.html

Ngx_cache_purge地址: http://labs.frickle.com/files/

 

一、在服务器上部署nginx

1、下载

 

wget http://nginx.org/download/nginx-1.9.7.tar.gz
wget http://labs.frickle.com/files/ngx_cache_purge-2.3.tar.gz
wget http://luajit.org/download/LuaJIT-2.0.4.tar.gz
ll

ll.png

2、安装

yum -y install zlib-devel pcre-devel openssl-devel gcc  # 安装依赖

 

  下载安装LuaJIT-2.0.4模块

tar -zxvf LuaJIT-2.0.4.tar.gz
cd LuaJIT-2.0.4
make
###出现如下提示说明编译成功##
OK        Successfully built LuaJIT

make[1]: Leaving directory `/root/LuaJIT-2.0.4/src'

==== Successfully built LuaJIT 2.0.4 ====

make install
###出现如下提示说明安装成功##
==== Successfully installed LuaJIT 2.0.4 to /usr/local ====

下载安装nginx lua模块

 

# cd /usr/local/src
# wget https://github.com/openresty/lua-nginx-module/archive/master.zip
# unzip master.zip
# cd lua-nginx-module-master

下载安装ngx_cache_purge 模块

cd /usr/loacal/src
wget http://labs.frickle.com/files/ngx_cache_purge-2.3.tar.gz
tar -zxvf  ngx_cache_purge-2.3.tar.gz

安装nginx模块

cd /usr/local/src/
# wget 
# tar -xzvf nginx-1.9.7.tar.gz
# cd nginx-1.9.7
# export LUAJIT_LIB=/usr/local/lib
# export LUAJIT_INC=/usr/local/include/luajit-2.0
# ./configure --prefix=/usr/local/nginx --user=www  --group=www --add-module=../ngx_cache_purge-2.3 --add-module=../lua-nginx-module-master --with-http_stub_status_module --with-http_ssl_module --with-http_flv_module --with-http_gzip_static_module
# make -j2
# make install

 

配置Nginx并启动测试lua 模块

vi /usr/local/nginx/conf/nginx.conf
server {        
      listen       80;        
      server_name  localhost;
      #charset koi8-r;
      #access_log  logs/host.access.log  main;
      location / {            
          #root   html;            
          #index  index.html index.htm;            
          default_type 'text/plain';            
          content_by_lua 'ngx.say("hello, nginx lua")';        
          }

 启动nginx

/usr/local/nginx/sbin/nginx

出现如下错误

/usr/local/nginx/sbin/nginx: error while loading shared libraries: libluajit-5.1.so.2: cannot open shared object file: No such file or directory

 解决方法:

#

 ln -s /usr/local/lib/libluajit-5.1.so.2 /lib64/libluajit-5.1.so.2

测试:

[root@zabbix_db conf]# curl 
http://localhost/
hello, nginx lua

如上显示说明lua模块测试成功。

访问测试 :

lua.png

原文链接:nginx+proxy_cache 配置高速缓存,转载请注明来源!

0