OpenResty 教程

Install

Manjaro

  • 编译安装
1
yaourt -S openresty
  • 添加环境变量

默认安装路径 /opt/openresty/, ~/.bashrc 或者 ~/.bash_profile file,
添加以下变量

1
2
RESTY=/opt/openresty
PATH=$RESTY/bin:$RESTY/nginx/sbin::$PATH

检查当前resty安装是否成功

1
resty -e 'print("hello, world!")'

Configure

创建openrest目录

1
2
mkdir openresty
mkdir logs conf
  • 在conf创建默认配置文件nginx.conf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
worker_processes  1;
error_log logs/error.log;
events {
worker_connections 1024;
}
http {
server {
listen 8080;
location / {
default_type text/html;
content_by_lua '
ngx.say("<p>hello, world</p>")
';
}
}
}
  • 启动Nginx
1
nginx -p `pwd`/ -c nginx.conf