nginx + ngx_lua安装测试
来源:互联网 发布:java 就业培训机构 编辑:程序博客网 时间:2024/05/22 06:05
在进行shell编程时,以#开头的句子表示注释,直到这一行的结束。我们真诚地建议您在程序中使用注释。如果您使用了注释,那么即使相当长的时间内没有使用该脚本,您也能在很短的时间内明白该脚本的作用及工作原理。
变量
在其他编程语言中您必须使用变量。在shell编程中,所有的变量都由字符串组成,并且您不需要对变量进行声明。要赋值给一个变量,您可以这样写:
变量名=值
nginx lua模块淘宝开发的nginx第三方模块,它能将lua语言嵌入到nginx配置中,从而使用lua就极大增强了nginx的能力.nginx以高并发而知名,lua脚本轻便,两者的搭配堪称完美.接下来请看如何安装nginx + ngx_lua模块.以及最后来个简单的测试.
如果你是ubuntu系统,请看nginx+lua+redis构建高并发应用
系统环境:centos/redhat
安装前准备好如下软件包
· nginx 地址:http://www.nginx.org
· luajit 地址:http://luajit.org/download.html
· HttpLuaModule 地址:http://wiki.nginx.org/HttpLuaModule
1. 下载安装LuaJIT
cd /usr/local/src
wget http://luajit.org/download/LuaJIT-2.0.2.tar.gz
tar -xzvf LuaJIT-2.0.2.tar.gz
cd LuaJIT-2.0.2
make
出现如下内容表示编译成功
OK Successfully built LuaJIT
make[1]: Leaving directory `/usr/local/src/LuaJIT-2.0.2/src’
==== Successfully built LuaJIT 2.0.2 ====
make install
出现如下内容,表示安装成功
==== Successfully installed LuaJIT 2.0.2 to /usr/local ====
2. 下载准备nginx lua模块
cd /usr/local/src
wget https://github.com/chaoslawful/lua-nginx-module/archive/v0.8.6.tar.gz
tar -xzvf v0.8.6.tar.gz
- 安装nginx
3.1 安装
cd /usr/local/src/
wget http://nginx.org/download/nginx-1.4.2.tar.gz
tar -xzvf nginx-1.4.2.tar.gz
cd nginx-1.4.2
//先导入环境变量,告诉nginx去哪里找luajit
export LUAJIT_LIB=/usr/local/lib
export LUAJIT_INC=/usr/local/include/luajit-2.0
./configure –prefix=/usr/local/nginx-1.4.2 –add-module=../lua-nginx-module-0.8.6
出现错误
./configure: error: the HTTP gzip module requires the zlib library.
You can either disable the module by using –without-http_gzip_module
option, or install the zlib library into the system, or build the zlib
library
statically from the source with nginx by using –with-zlib= option.
则需要安装“zlib-devel”即可。SSH执行以下命令:
yum install -y zlib-devel
make -j2
make install
3.1 常见错误
/usr/local/nginx-1.4.2/sbin/nginx -v
./objs/nginx: error while loading shared libraries: libluajit-5.1.so.2: cannot open shared object file: No such file or directory
解决方法:
ln -s /usr/local/lib/libluajit-5.1.so.2 /lib64/libluajit-5.1.so.2
- nginx lua配置
nginx配置文件加入如下配置:
location ~* ^/2328(/.*) {
default_type ‘text/plain’;
content_by_lua ‘ngx.say(“hello, ttlsa lua”)’;
} - 启动测试
5.1 启动nginx
/usr/local/nginx-1.4.2/sbin/nginx
5.2 访问测试
curl http://test.ttlsa.com/2328/
hello, ttlsa lua //使用curl测试
nginx lua测试截图
lua
nginx lua测试
nginx ngx_lua的安装到此结束
转载请注明出处: http://www.ttlsa.com/html/2328.html
- nginx + ngx_lua安装测试
- nginx + ngx_lua安装测试
- centOS下nginx + ngx_lua安装测试
- Nginx,LuaJIT,ngx_devel_kit,ngx_lua,cjson安装
- Ngx_lua
- Nginx ngx_Lua模块中的重定向
- Nginx安装与测试
- ubuntu 12.04 安装测试nginx
- nginx 扩展 ngx_lua 的数据量连接池(1)
- ngx_lua利用nginx内部跳转提高访问效率
- nginx使用ngx_lua访问后端Thrift-Server实现和介绍
- Nginx-Lua-Module Manual for ngx_lua v0.10.11
- 在linux下安装ngx_lua模块,iconv模块
- NGINX安装与简单的压力测试
- FastDFS+nginx---(二)安装配置测试
- win7系统下安装、配置、测试nginx
- FastDFS、Nginx安装、配置、测试(java client)
- nginx负载均衡安装及测试
- Mac下使用git入门
- Linux下Socket编程的端口问题( Bind error: Address already in use )
- 操作4 mongodb备份脚本
- 玩codehunter level02
- 关于connect: network is unreachable 问题的解决
- nginx + ngx_lua安装测试
- Mastering Dart(读书笔记)——有意思的地方在于它的Future、Isolates和Zones
- linux环境变量的临时设置,永久设置和其他。
- c++primer要点-表达式
- CodeForces 3DLeast Cost Bracket Sequence优先队列
- Android 分包机制
- 【设计模式】动态代理Proxy_02
- 黑马程序员——Java 面向对象(下)
- 根据浏览器导入不同css文件