其实有点类似WampServer一站式安装包
wget http://openresty.org/download/ngx_openresty-1.7.10.1.tar.gz tar -zxvf ngx_openresty-1.7.10.1.tar.gz cd ngx_openresty-1.7.10.1 ./configure make && make install
configure之前需要安装的相关组件
yum -y install pcre-devel yum -y install gcc zlib zlib-devel openssl openssl-devel
安装目录默认会在
cd /usr/local/openresty/
测试lua环境是否正常
lua print("hello")
测试nginx+lua
cd /usr/local/openresty/nginx/conf
在nginx.conf里添加测试内容
location /hello { default_type ‘text/plain‘; content_by_lua ‘ngx.say("ok")‘; }
location /say {
default_type text/html;
content_by_lua ‘
ngx.say("<p>hello, world</p>")
ngx.say(tostring(ngx.var.remote_addr),"<br/>")
ngx.say(tostring(ngx.var.arg_name),"<br/>")
‘;
}
启动nginx
sbin/nginx
测试:
[[email protected] nginx]# curl ‘http://localhost/hello‘ ok
浏览器访问:
参考:
http://openresty.org/
https://m.oschina.net/blog/344540
时间: 2024-10-03 21:41:55