nginx+lua环境搭建笔记

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

时间: 2024-12-13 10:40:56

nginx+lua环境搭建笔记的相关文章

mac下lua环境搭建笔记

下载lua源码包,进入到根目录下 1.执行make macosx 2.然后再sudo make install即可 mac下lua环境搭建笔记,布布扣,bubuko.com

Nginx+lua环境搭建

其实有点类似WampServer一站式安装包 wget http://openresty.org/download/ngx_openresty-1.7.10.1.tar.gz tar -zxvf ngx_openresty-1.7.10.1.tar.gz cd ngx_openresty-1.7.10.1 ./configure make && make install configure之前需要安装的相关组件 yum -y install pcre-devel yum -y instal

【Lua学习笔记之:Lua环境搭建 Windows 不用 visual studio】

Lua 环境搭建 Windows 不用 visual studio 系统环境:Win7 64bit 联系方式:[email protected] 前言: 最近需要学习Unity3d游戏中的热更新技术,选择ULua方案,因此准备学习一些Lua的基础知识.之前在Ubuntu上曾经写过Lua版本的"HelloWorld", 但那时的环境搭建只需要下载源码,然后 make & make install 就可以了,但一到Windows下就完全不会做了.经过网络查找对比,得到目前自认为较好

《Node.js入门》Windows 7下Node.js Web开发环境搭建笔记

近期想尝试一下在IBM Bluemix上使用Node.js创建Web应用程序.所以须要在本地搭建Node.js Web的开发測试环境. 这里讲的是Windows下的搭建方法,使用CentOS 的小伙伴请參考:<Node.js入门>CentOS 6.5下Node.js Web开发环境搭建笔记 Node.js是什么? 我们看看百科里怎么说的? JavaScript是一种执行在浏览器的脚本,它简单,轻巧.易于编辑,这样的脚本通经常使用于浏览器的前端编程.可是一位开发人员Ryan有一天发现这样的前端式

qt编译及qwt开发环境搭建笔记

qt的编译安装参见http://qt-project.org/doc/qt-4.8/install-x11.html 应注意以下要点,需要安装以下套件吗,否则编译后跟ubuntu的界面不兼容 Error while building on Ubuntu 12.* Before building it on Ubuntu 12.* be sure you have these packages: libfontconfig1-dev libfreetype6-dev libx11-dev libx

windows下 nginx php 环境搭建

windows下配置nginx+php环境 刚看到nginx这个词,我很好奇它的读法(engine x),我的直译是“引擎x”,一般引“擎代”表了性能,而“x”大多出现是表示“xtras(额外的效果)”,那么整个词的意思就是类似“极致效果”,“额外性能”.当然这里不是要来唠嗑,以上是题外话. nginx相较于我们熟悉的apache.IIS的优势,就我浅入浅出的了解,在于“反向代理”和“负载均衡”.因此考虑到能够为Web服务器节省资源,它可以代替apache来提供Web服务.那么上正题了,ngin

《Python入门》Linux 下 Python Web开发环境搭建笔记

之前写过 Windows 7下Python Web开发环境搭建笔记,今天写一下在Linux系统下搭建Python Web的开发测试环境. 我使用的系统是:ubuntu 14.04 server,根据个人经验,CentOS 6.5 下也适用. 关于Python的版本 进入Python的网站,鼠标移到导航条上的下载,我们会发现提供两下主版本的下载链接! 这两个之间存在什么差别呢? 个人理解,2.7.x的版本为更加稳定的版本,而3.x的版本则是比较前卫的版本,包含了很多新功能新特性之类的: 但如果想要

lua环境搭建 + 常见错误解决 windows + linux双版

lua在linux和windows系统下的安装/配置方法 linux系统: 1)去Lua的官网(http://www.lua.org/ftp/)下载最新发布包,比如lua-5.2.3.tar.gz 2)使用命令tar -xzvf  lua-5.2.3.tar.gz  解压 3)使用命令cd lua-5.2.3 进入lua目录 4)使用命令make linux 此时如出现问题,解决方法如下: 问题:error: <readline/history.h>: No such file or dire

GY的实验室 - Phalcon+Nginx+PHP-FPM环境搭建(转)

Phalcon简介 由于半路出家的缘故,没用过几个PHP框架,第一个了解的框架是公司自己的,然后又试着用了Yii,CI.在读了CSDN在某度的高排名翻译文章(PHP开发框架流行度排名:Laravel居首)后,看了Laravel的皮毛.不得不说Laravel的文档真是漂亮,但是作为一个后台程序开发者,总觉得也不是自己想要的. 框架的作用:前后端代码解耦:数据库操作封装:内置通用程序模块(比如路由.认证.加密等): 虽然整个网站中,框架性能并非主要因素,但是还是想把它发挥到极致,只能说是程序员的理想