OpenResty入门,


转载:
https://openresty.org/cn/linux-packages.html

安装

CentOS

sudo yum install yum-utils
sudo yum-config-manager --add-repo https://openresty.org/package/centos/openresty.repo
sudo yum install openresty-resty

列出所有 openresty 仓库里头的软件包:
sudo yum --disablerepo="*" --enablerepo="openresty" list available

HelloWorld

mkdir ~/work
cd ~/work
mkdir logs/ conf/

Prepare the nginx.conf config file

Create a simple plain text file named conf/nginx.conf with the following contents in it:

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>")
            ';
        }
    }
}

Start the Nginx server

PATH=/usr/local/openresty/nginx/sbin:$PATH
export PATH

Then we start the nginx server with our config file this way:
nginx -p `pwd`/ -c conf/nginx.conf

Access our HelloWorld web service

curl http://localhost:8080/
If everything is okay, we should get the output
<p>hello, world</p>

相关内容

    暂无相关文章