mkdir -p /usr/servers
cd /usr/servers/
apt-get install libreadline-dev libncurses5-dev libpcre3-dev libssl-dev perl
wget http://openresty.org/download/ngx_openresty-1.7.7.2.tar.gz
tar -xzvf ngx_openresty-1.7.7.2.tar.gz
<>安装LuaJIT
cd bundle/LuaJIT-2.1-20150120/
make clean && make && make install
ln -sf luajit-2.1.0-alpha /usr/local/bin/luajit
<>安装ngx_cache_purge模块
cd /usr/servers/ngx_openresty-1.7.7.2/bundle
wget https://github.com/FRiCKLE/ngx_cache_purge/archive/2.3.tar.gz
tar -xvf 2.3.tar.gz
<>安装nginx_upstream_check_module模块
cd /usr/servers/ngx_openresty-1.7.7.2/bundle
wget https://github.com/yaoweibin/nginx_upstream_check_module/archive/v0.3.0.tar.gz
tar -xvf v0.3.0.tar.gz
<>安装ngx_openresty
cd /usr/servers/ngx_openresty-1.7.7.2
./configure --prefix=/usr/servers --with-http_realip_module --with-pcre --with-luajit --add-module=./bundle/ngx_cache_purge-2.3/ --add-module=./bundle/nginx_upstream_check_module-0.3.0/ -j2
make && make install
<>nginx option
/usr/servers/nginx/sbin/nginx
/usr/servers/nginx/sbin/nginx -s reload
/usr/servers/nginx/sbin/nginx -s stop
/usr/servers/nginx/sbin/nginx -t
<>配置
mkdir /usr/svn/lua_project –p
mkdir /usr/svn/lua_project/conf –p
mkdir /usr/svn/lua_project/lua –p
mkdir /usr/svn/lua_project/lualib –p
touch /usr/svn/lua_project/conf/lua.conf
#lua.conf
server {
listen 80;
server_name _;
location /lua {
default_type 'text/html';
lua_code_cache off;
content_by_lua_file /usr/svn/lua_project/lua/test.lua;
}
}
touch /usr/svn/lua_project/lua/test/lua
#test.lua
ngx.say("Hello,world")
root@xiaoyu:/usr/svn/lua_project# tree
.
├── conf
│ └── lua.conf
├── lua
│ └── test.lua
└── lualib
vi /usr/servers/nginx/conf/nginx.conf
#nginx.conf
http {
include mime.types;
include /usr/svn/lua_project/conf/lua.conf;
default_type application/octet-stream;
lua_package_path "/usr/servers/lualib/?.lua;;"; #lua 模块
lua_package_cpath "/usr/servers/lualib/?.so;;"; #c模块
#log_format main '$remote_addr - $remote_user [$time_local] "$request" '
# '$status $body_bytes_sent "$http_referer" '
# '"$http_user_agent" "$http_x_forwarded_for"';
#access_log logs/access.log main;
}
<>test
cuil –i http://127.0.0.1/lua
Hello,world
<>错误日志
tail -f /usr/servers/nginx/logs/error.log