ビットの海

ゆるふわアラサーエンジニアしゃぜのブログ

ふわっとOpenResty

前提

  • brewがつかえる環境

導入

$ brew install openresty/brew/openresty

設定

$ cd /usr/local/opt/openresty
$ mkdir conf
$ mkdir lua

サンプル配置

/usr/local/opt/openresty/conf/nginx.conf

worker_processes  1;

events {
    worker_connections  1024;
}


http {
    default_type  application/octet-stream;
    sendfile        on;
    keepalive_timeout  65;
    charset UTF-8;
    server {
        listen       80;
        server_name  localhost;

        location / {
                default_type 'text/html';
                content_by_lua_file /usr/local/opt/openresty/lua/hello.lua;
        }

        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }

    }

}

/usr/local/opt/openresty/lua/hello.lua

ngx.say("こんにちは世界")

起動と停止

# 起動
sudo /usr/local/opt/openresty/bin/openresty -c /usr/local/opt/openresty/conf/nginx.conf

# 停止
sudo /usr/local/opt/openresty/bin/openresty -s stop

起動してhttp://localhostにアクセスしてみよう!