Giter Club home page Giter Club logo

nginxlua's Introduction

Nginx Lua 代理 Redis 哨兵节点

环境准备

1. 下载各个模块源码

2. 源代码编译

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

# 编译 luaJIT
cd LuaJit
make install PREFIX=/usr/local/LuaJIT
export LUAJIT_LIB=/usr/local/LuaJIT/lib
export LUAJIT_INC=/usr/local/LuaJIT/include/luajit-2.1



# 创建 nginx 用户和用户组
groupadd nginx
useradd -g nginx nginx -s /sbin/nologin

# 创建 nginx 目录
mkdir -p /var/cache/nginx

# 编译 nginx
tar -xzvf nginx-1.20.2.tar.gz
cd nginx-1.20.2

./configure --prefix=/etc/nginx --sbin-path=/usr/sbin/nginx --modules-path=/usr/lib64/nginx/modules --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx.pid --lock-path=/var/run/nginx.lock --http-client-body-temp-path=/var/cache/nginx/client_temp --http-proxy-temp-path=/var/cache/nginx/proxy_temp --http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp --http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp --http-scgi-temp-path=/var/cache/nginx/scgi_temp --user=nginx --group=nginx --with-compat --with-file-aio --with-threads --with-http_addition_module --with-http_auth_request_module --with-http_dav_module --with-http_flv_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_mp4_module --with-http_random_index_module --with-http_realip_module --with-http_secure_link_module --with-http_slice_module --with-http_ssl_module --with-http_stub_status_module --with-http_sub_module --with-http_v2_module --with-mail --with-mail_ssl_module --with-stream --with-stream_realip_module --with-stream_ssl_module --with-stream_ssl_preread_module --with-cc-opt='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -fPIC' --with-ld-opt='-Wl,-rpath,/usr/local/LuaJIT/lib' --add-module=/root/nginxlua/ngx_devel_kit --add-module=/root/nginxlua/lua-nginx-module --add-module=/root/nginxlua/stream-lua-nginx-module-0.0.11

make -j2
make install 

# 编译核心模块
cd lua-resty-core
make install PREFIX=/etc/nginx
cd lua-resty-lrucache
make install PREFIX=/etc/nginx
cd lua-resty-redis
make install PREFIX=/etc/nginx

3. 修改 nginx 配置文件

vim /etc/nginx/nginx.conf

添加到 http 上下文括号中 lua_package_path "/etc/nginx/lib/lua/?.lua;;";

在 stream 上下文中使用也需要添加

4. 清理环境

rm -rf nginxlua

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.