OpenResty 點滴

jopen 8年前發布 | 8K 次閱讀 Web服務器



安裝腳本


$ cat build.sh 

#!/bin/bash

#


PCRE_DIR=$PWD/pcre-8.38


cd ngx_openresty-*

APPDIR=$HOME/s/apps/resty

LOGDIR=$HOME/s/logs/resty


./configure   \

        --prefix=$APPDIR        \

        --error-log-path=$LOGDIR/error.log    \

        --pid-path=$LOGDIR/resty.pid  \

        --lock-path=$LOGDIR/resty.lock \

        --http-log-path=$LOGDIR/access.log \

        --with-http_stub_status_module  \

        --with-pcre=$PCRE_DIR \

        --http-client-body-temp-path=$LOGDIR/client/ \

        --http-proxy-temp-path=$LOGDIR/proxy/   \

        --http-fastcgi-temp-path=$LOGDIR/fastcgi/    \

        --http-uwsgi-temp-path=$LOGDIR/uwsgi/    \

        --http-scgi-temp-path=$LOGDIR/scgi/    \

        --user=search   \

        --group=search  

make && make install



#        --without-pcre  \

#        --without-http_rewrite_module   \

#        --without-http_gzip_module      \


搭建測試環境

mkdir $HOME/work/resty

cd $HOME/work/resty

mkdir logs/ conf/  lua/ lua/app/

$ cat conf/nginx.conf 


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>")

            ';

        }


        location ~ ^/app/([-_a-zA-Z0-9/]+) {

            set $path $1;

            content_by_lua_file lua/app/$path.lua;

        }


    }

}


$ cat lua/app/hello.lua 

ngx.say("Hello, Lua !")


$ cat nginx.sh 

#!/bin/bash

#

cd $(dirname $0)

APPDIR=$(pwd)

export PATH=$HOME/s/apps/resty/nginx/sbin:$PATH

nginx -p $APPDIR/ -c conf/nginx.conf $@


# 啟動nginx server

./nginx.sh


# 測試結果

wget -O- -q -d 127.0.0.1:8080

wget -O- -q -d 127.0.0.1:8080/app/hello



來自: http://my.oschina.net/kuerant/blog/603627

 本文由用戶 jopen 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
 轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
 本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!