3d 男人看的缺失落的拼图
系统依赖包Server Racks In Data Center.
yum -y install pcre-devel openssl-devel gcc curl zlib-devel gcc-c++

LuaJIT:lua的一个即时编译器
Nginx Devel Kit:NDK是一个nginx模块,以一种可浸染于其他nginx模块的办法,扩展nginx核心功能。
Lua Nginx Module:该模块将Lua阐明器或LuaJIT嵌入到nginx核心中,并通过nginx子要求将强大的Lua线程(也称为Lua协程)集成到nginx事宜模型中。
nginx:web做事
Server Racks In Data Center.
下载编译安装wget -c http://luajit.org/download/LuaJIT-2.0.5.tar.gz
tar zxvf LuaJIT-2.0.5.tar.gz
cd LuaJIT-2.0.5
make install PREFIX=/opt/luajit
export LUAJIT_LIB=/opt/luajit/lib
export LUAJIT_INC=/opt/luajit/include/luajit-2.0
( 如果不设置环境变量,在nginx编译的时候会找不到lua模块:./configure: error: ngx_http_lua_module requires the Lua library.)
cd ..
wget -c -O ngx_devel_kit-0.3.0.tar.gz https://codeload.github.com/simplresty/ngx_devel_kit/tar.gz/v0.3.0
tar zxvf ngx_devel_kit-0.3.0.tar.gz
wget -c -O lua-nginx-module-0.10.13.tar.gz https://codeload.github.com/openresty/lua-nginx-module/tar.gz/v0.10.13
tar zxvf lua-nginx-module-0.10.13.tar.gz
wget -c http://zlib.net/zlib-1.2.11.tar.gz
tar zxvf zlib-1.2.11.tar.gz
wget -c https://www.openssl.org/source/openssl-1.0.2p.tar.gz
tar zxvf openssl-1.0.2p.tar.gz
wget -c https://ftp.pcre.org/pub/pcre/pcre-8.42.tar.gz
tar zxvf pcre-8.42.tar.gz
wget -c http://nginx.org/download/nginx-1.12.2.tar.gz
tar zxvf nginx-1.12.2.tar.gz
cd nginx-1.12.2
./configure --prefix=/opt/nginx --add-module=../ngx_devel_kit-0.3.0 --add-module=../lua-nginx-module-0.10.13 --with-openssl=../openssl-1.0.2p --with-zlib=../zlib-1.2.11 --with-pcre=../pcre-8.42 --with-http_ssl_module --with-http_v2_module --with-http_realip_module --with-http_stub_status_module
make
make install
软连接或者添加环境变量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/luajit/lib/libluajit-5.1.so.2 /lib64/libluajit-5.1.so.2
或者添加环境变量:
echo 'export LD_LIBRARY_PATH=/opt/luajit/lib:$LD_LIBRARY_PATH' >> /etc/profile
source /etc/profie
验证vim /opt/nginx/conf/nginx.conf
#在nginx.conf中,server->location配置
location /hello {
default_type 'text/plain';
content_by_lua 'ngx.say(\"大众hello, lua\"大众)';
}
Server Racks In Data Center.
启动nginx/opt/nginx/sbin/nginx
访问http://[做事器IP]/hello
可以看到
hello, lua