码迷,mamicode.com
首页 > 其他好文 > 详细

nginx部署lua环境

时间:2016-01-28 19:34:46      阅读:287      评论:0      收藏:0      [点我收藏+]

标签:lua环境   nginx   

系统环境

# uname -r

3.10.0-229.el7.x86_64

# cat /etc/redhat-release

CentOS Linux release 7.1.1503(Core)

所需模块

pcre       ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/

luajit         http://luajit.org/download.html

ngx_devel_kit  https://github.com/simpl/ngx_devel_kit/tags

lua_nginx_module   https://github.com/openresty/lua-nginx-module/tags 

安装步骤

1、安装luajit

1.1安装

# cd /tools/

# wget http://luajit.org/download/LuaJIT-2.0.4.tar.gz

# tar xf LuaJIT-2.0.4.tar.gz

# cd LuaJIT-2.0.4

# make

# make install  PREFIX=/application/luagit

# cd

1.2配置luagit

# export  LUAJIT_LIB=/application/luagit/lib/

# export  LUAJIT_INC=/application/luagit/include/luajit-2.0/

2、安装ngx_devel_kit

# cd /tools/

# wget https://github.com/simpl/ngx_devel_kit/archive/v0.2.19.tar.gz

# tar xf ngx_devel_kit-0.2.19.tar.gz

# mv ngx_devel_kit-0.2.19  /application/ngx_devel_kit

# cd

3、安装lua_nginx_module

# cd /tools/

# wget https://github.com/openresty/lua-nginx-module/archive/v0.10.0.tar.gz

# tar xf lua-nginx-module-0.10.0.tar.gz

# mv lua-nginx-module-0.10.0  /application/lua-nginx-module

# cd

4、安装nginx

安装基础环境

# yum install -y pcre pcre-developenssl openssl-devel

创建用户和组

# groupadd nginx

# useradd nginx -g nginx -M -s /sbin/nologin

下载解压nginx

# cd /tools/

# wget http://nginx.org/download/nginx-1.9.4.tar.gz

# tar xf nginx-1.9.4.tar.gz

# cd nginx-1.9.4

## ./configure --user=nginx --group=nginx --prefix=/application/nginx-1.9.4 --with-http_ssl_module --with-http_stub_status_module --with-pcre --add-module=/application/ngx_devel_kit  --add-module=/application/lua-nginx-module

# make -j2

# make install

# ln -s /application/nginx-1.9.4/  /application/nginx

# cd

检查

# /application/nginx/sbin/nginx -v

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

解决办法

# ln -s/application/luagit/lib/libluajit-5.1.so.2  /lib64/

# /application/nginx/sbin/nginx -v

nginx version: nginx/1.9.4

5、配置nginx.conf

在server模块添加如下几行

        location /kevin {

                 default_type ‘text/plain‘;

                 content_by_lua ‘ngx.say("Hello,kevin!Iam lua.")‘;

        }

6、检查并启动nginx

# ../sbin/nginx -t

nginx: the configuration file/application/nginx-1.9.4/conf/nginx.conf syntax is ok

nginx: configuration file/application/nginx-1.9.4/conf/nginx.conf test is successful

# ../sbin/nginx

7、检测lua环境

在浏览器中输入http://<serverip>/kevin,出现如下图即表明成功

技术分享

本文出自 “长街听风人” 博客,请务必保留此出处http://kevinhao.blog.51cto.com/5204735/1739503

nginx部署lua环境

标签:lua环境   nginx   

原文地址:http://kevinhao.blog.51cto.com/5204735/1739503

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!