OpenResty入门

来源:互联网 发布:unreal 源码分析 编辑:程序博客网 时间:2024/06/05 00:11

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

安装

CentOS

sudo yum install yum-utilssudo yum-config-manager --add-repo https://openresty.org/package/centos/openresty.reposudo yum install openresty-resty列出所有 openresty 仓库里头的软件包:sudo yum --disablerepo="*" --enablerepo="openresty" list available

HelloWorld

mkdir ~/workcd ~/workmkdir 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:$PATHexport PATHThen 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>
原创粉丝点击