nginx+lua环境搭建笔记
2015-05-08 17:28
225 查看
1、下载安装包: http://luajit.org/download/LuaJIT-2.0.3.tar.gz? https://codeload.github.com/simpl/ngx_devel_kit/tar.gz/v0.2.19 https://codeload.github.com/openresty/lua-nginx-module/tar.gz/v0.9.15 http://nginx.org/download/nginx-1.9.0.tar.gz https://codeload.github.com/diegonehab/luasocket/tar.gz/v3.0-rc1 2、安装依赖
yum install -y readline-devel ncurses-devel
yum install libreadline-dev libncurses5-dev libpcre3-dev perl
yum install -y make gcc
yum install readline-devel pcre-devel openssl-devel
3、先安装luajit
前提:修改Makefile中的export PREFIX ,改变安装路径――不一定需要操作。
make
make install
①配置环境变量
export LUA_PATH=/usr/local/luajit/share/lua/?.lua\;?.lua;
export LUA_CPATH=/usr/local/luajit/lib/lua/?.so\;?.so;
export PATH=$PATH:/usr/local/luajit/bin
export LUAJIT_LIB=/usr/local/luajit/lib
export LUAJIT_INC=/usr/local/luajit/include/luajit-2.0
②ln -s /usr/local/luajit/lib/libluajit-5.1.so.2 /lib64/libluajit-5.1.so.2
4、安装nginx
./configure --prefix=/usr/local/nginx --add-module=../lua-nginx-module-0.9.15 --add-module=../ngx_devel_kit-0.2.19
make
出现的错误1:
../lua-nginx-module-0.9.15/src/ngx_http_lua_initworkerby.c: In function ‘ngx_http_lua_init_worker’:
../lua-nginx-module-0.9.15/src/ngx_http_lua_initworkerby.c:230: error: implicit declaration of function ‘ngx_http_set_connection_log’
解决办法:
把
#if defined(nginx_version) && nginx_version >= 1003014
ngx_http_set_connection_log(r->connection, clcf->error_log);
#else
c->log->file = clcf->error_log->file;
if (!(c->log->log_level & NGX_LOG_DEBUG_CONNECTION)) {
c->log->log_level = clcf->error_log->log_level;
}
#endif
替换为:
#if defined(nginx_version) && nginx_version >= 100900
ngx_set_connection_log(r->connection, clcf->error_log);
#elif defined(nginx_version) && nginx_version < 100900 && nginx_version >= 1003014
ngx_http_set_connection_log(r->connection, clcf->error_log);
#else
c->log->file = clcf->error_log->file;
if (!(c->log->log_level & NGX_LOG_DEBUG_CONNECTION)) {
c->log->log_level = clcf->error_log->log_level;
}
#endif
出现的错误2:
../lua-nginx-module-0.9.15/src/ngx_http_lua_timer.c: In function ‘ngx_http_lua_timer_handler’:
../lua-nginx-module-0.9.15/src/ngx_http_lua_timer.c:353: error: implicit declaration of function ‘ngx_http_set_connection_log’
解决办法同上,替换代码即可
出现的错误3:
undefined reference to 'pcre_free_study'
解决办法:
去pcre.org下载pcre包,在nginx的configure参数中添加 --with-pcre=../pcre-xx.xx --with-pcre-jit
make install
5、安装luasocket
①修改luasocket/src/makefile,对应luajit指定路径
# LUAINC_linux:
# /usr/include/lua$(LUAV)
# /usr/local/include
# /usr/local/include/lua$(LUAV)
# where lua headers are found for linux builds
LUAINC_linux_base?=/usr/local
LUAINC_linux?=$(LUAINC_linux_base)/luajit/include/luajit-2.0
LUAPREFIX_linux?=/usr/local/luajit
CDIR_linux?=lib/lua
LDIR_linux?=share/lua
②安装
make PLAT=linux LUAV=jit
make install
yum install -y readline-devel ncurses-devel
yum install libreadline-dev libncurses5-dev libpcre3-dev perl
yum install -y make gcc
yum install readline-devel pcre-devel openssl-devel
3、先安装luajit
前提:修改Makefile中的export PREFIX ,改变安装路径――不一定需要操作。
make
make install
①配置环境变量
export LUA_PATH=/usr/local/luajit/share/lua/?.lua\;?.lua;
export LUA_CPATH=/usr/local/luajit/lib/lua/?.so\;?.so;
export PATH=$PATH:/usr/local/luajit/bin
export LUAJIT_LIB=/usr/local/luajit/lib
export LUAJIT_INC=/usr/local/luajit/include/luajit-2.0
②ln -s /usr/local/luajit/lib/libluajit-5.1.so.2 /lib64/libluajit-5.1.so.2
4、安装nginx
./configure --prefix=/usr/local/nginx --add-module=../lua-nginx-module-0.9.15 --add-module=../ngx_devel_kit-0.2.19
make
出现的错误1:
../lua-nginx-module-0.9.15/src/ngx_http_lua_initworkerby.c: In function ‘ngx_http_lua_init_worker’:
../lua-nginx-module-0.9.15/src/ngx_http_lua_initworkerby.c:230: error: implicit declaration of function ‘ngx_http_set_connection_log’
解决办法:
把
#if defined(nginx_version) && nginx_version >= 1003014
ngx_http_set_connection_log(r->connection, clcf->error_log);
#else
c->log->file = clcf->error_log->file;
if (!(c->log->log_level & NGX_LOG_DEBUG_CONNECTION)) {
c->log->log_level = clcf->error_log->log_level;
}
#endif
替换为:
#if defined(nginx_version) && nginx_version >= 100900
ngx_set_connection_log(r->connection, clcf->error_log);
#elif defined(nginx_version) && nginx_version < 100900 && nginx_version >= 1003014
ngx_http_set_connection_log(r->connection, clcf->error_log);
#else
c->log->file = clcf->error_log->file;
if (!(c->log->log_level & NGX_LOG_DEBUG_CONNECTION)) {
c->log->log_level = clcf->error_log->log_level;
}
#endif
出现的错误2:
../lua-nginx-module-0.9.15/src/ngx_http_lua_timer.c: In function ‘ngx_http_lua_timer_handler’:
../lua-nginx-module-0.9.15/src/ngx_http_lua_timer.c:353: error: implicit declaration of function ‘ngx_http_set_connection_log’
解决办法同上,替换代码即可
出现的错误3:
undefined reference to 'pcre_free_study'
解决办法:
去pcre.org下载pcre包,在nginx的configure参数中添加 --with-pcre=../pcre-xx.xx --with-pcre-jit
make install
5、安装luasocket
①修改luasocket/src/makefile,对应luajit指定路径
# LUAINC_linux:
# /usr/include/lua$(LUAV)
# /usr/local/include
# /usr/local/include/lua$(LUAV)
# where lua headers are found for linux builds
LUAINC_linux_base?=/usr/local
LUAINC_linux?=$(LUAINC_linux_base)/luajit/include/luajit-2.0
LUAPREFIX_linux?=/usr/local/luajit
CDIR_linux?=lib/lua
LDIR_linux?=share/lua
②安装
make PLAT=linux LUAV=jit
make install
相关文章推荐
- Lua学习笔记1:开发环境搭建(windows和linux)
- OpenWrt 自学笔记(5)------lua 环境搭建
- cocos2d-x lua 学习笔记(1) -- 环境搭建
- cocos2d-x笔记(七)Lua开发飞机大战-1-搭建开发环境
- 【Cocos2d-x Lua笔记一】环境搭建
- Quick cocos2dx-Lua(V3.3R1)学习笔记(十)-----搭建安卓打包环境,用官方示例anysdk生成apk运行
- lua学习笔记1---VC下lua环境的搭建
- 【nginx+lua高性能web应用开发(一):环境搭建】
- 脚本语言lua笔记(1)环境搭建
- Lua学习笔记(一):搭建开发环境
- mac下lua环境搭建笔记
- Lua学习笔记1:Windows7下使用VS2008搭建Lua开发环境(一)
- 【nginx+lua高性能web应用开发(一):环境搭建】
- 配置nginx+lua开发环境笔记(2)
- (转)Lua学习笔记1:Windows7下使用VS2015搭建Lua开发环境
- Nginx+Lua学习笔记-环境搭建
- Quick cocos2dx-Lua(V3.3R1)学习笔记(9)-----搭建安卓打包环境,用官方示例anysdk生成apk运行
- Nginx+lua环境搭建
- Lua学习笔记1:Windows7下使用VS2015搭建Lua开发环境(一)
- lua学习笔记(1)——lua简介和环境搭建