原文地址:
http://note.youdao.com/share/web/file.html?id=60898bbb59c5aade1443402b6fe26dd9&type=note
cd
/data/ngx_openresty-1.7.10.2/
./configure --prefix=/data/openresty (./configure --prefix=/data/openresty --with-pcre=/data/pcre-8.32)
gmake
wget https://github.com/brimworks/lua-zlib/archive/master.zip
unzip master.zip
cd lua-zlib-master
cmake -DLUA_INCLUDE_DIR=/data/openresty/luajit/include/luajit-2.1/ -DUSE_LUAJIT=ON
make
cp zlib.so /data/openresty/lualib/
如果報pcre的依賴包沒有的話下載
解壓到/data目錄
gmake install
把原來的nginx配置文件拷貝到新的目錄執行下面的命令:
cp /data/nginx/conf/nginx.conf /data/openresty/nginx/conf/
修改/data/openresty/nginx/conf/nginx.conf文件
修改:error_log /data/openresty/nginx/logs/error.log crit;
gzip_types text/plain application/x-javascript text/css application/xml application/json;
添加:
lua_shared_dict healthcheck 1m;
lua_max_running_timers 1024;
init_worker_by_lua_file luaFile/initWorker.lua;
include vhosts/api.conf;
include vhosts/static.conf;
把下面這個兩個文件拷貝到/data/openresty/nginx/conf/vhosts目錄下面
去掉原來的:include vhosts/default.conf;
upServer的配置(放nginx.conf的最下面即可):
upstream upServer {
#server 172.16.200.82:8080;
#server 172.16.115.75:8080;
server 172.16.10.118:8080;
keepalive 128;
#keepalive_timeout 60s;
#session_sticky cookie=JSESSIONID domain=api2.v.meizu.com fallback=on path=/ mode=insert option=direct;
}
修改這裏server配置實際的jetty的內網IP
修改api.conf 的 set $mirrorIdcName "ns";
修改 mirrorIdcName 參數,例如南沙機房的就改爲它的鏡像機房:wx(無錫)
這裏的mirrorIdcName 就是這個機房希望對應的鏡像機房,在jetty服務不可用時會請求會被轉發到對應的鏡像機房。
修改config配置:LUAINC=-I/data/openresty/luajit/include/luajit-2.1/
make & make install
然後就是把附件解壓,luaFile文件夾放到/data/openresty/nginx/下面
require.lua、dispatch.lua放到/data/openresty/lualib/下面
然後在/data/openresty/lualib/resty目錄下面新建一個tools目錄,把tool.lua文件放到這個新建目錄下面
運行/data/openresty/nginx/sbin/nginx