系统环境:

lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 12.04.5 LTS
Release:        12.04
Codename:       precise

下载nginx_lua_module

下载ngx_devel_kit

安装 luajit
apt-get install libluajit-5.1-dev luajit


 ls /opt/nginx_comp
 lua-nginx-module-0.9.16         nginx-1.2.7-no_buffer-v6.patch  nginx_upload_module-2.2.0.tar.gz         ngx_devel_kit-0.2.19         pcre-8.34.zip
lua-nginx-module-0.9.16.tar.gz  nginx-1.2.7.tar.gz              nginx-upload-progress-module-master      ngx_devel_kit-0.2.19.tar.gz  php-5.5.7
nginx-1.2.7                     nginx_upload_module-2.2.0       nginx-upload-progress-module-master.zip  pcre-8.34                    php-5.5.7.tar.gz 
 cd /opt/nginx_comp/nginx-1.2.7/
 ./configure --user=www-data --group=www-data --prefix=/usr/local/nginx-1.2.7/ --with-http_stub_status_module --with-http_ssl_module --with-http_sub_module  --with-http_gzip_static_module --with-http_mp4_module --add-module=../ngx_devel_kit-0.2.19   --add-module=../lua-nginx-module-0.9.16 
 
vi  objs/Makefile 

CFLAGS =   -pipe  -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g  -DNDK_SET_VAR
CFLAGS =   -pipe  -O -W -Wall -Wpointer-arith -Wno-unused-parameter -g -DNDK_SET_VAR

make -j4
make install

测试是否成功:

nginxconfig中加入

 

location /hello {    
      default_type 'text/plain';    
      content_by_lua 'ngx.say("hello, lua")';    
}



访问192.168.100.1/hello

会出现“hello,lua”