美文网首页
openresty起步

openresty起步

作者: 无止无尽 | 来源:发表于2018-07-23 16:41 被阅读0次

openresty

  • 安装openresty

1、源码安装

安装前准备:

    yum install pcre-devel openssl-devel gcc curl

源码下载地址:openresty

解压、安装

    tar -xzvf openresty-VERSION.tar.gz
    cd openresty-VERSION/
    ./configure
    make
    sudo make install

2、仓库安装

    sudo yum install yum-utils
    sudo yum-config-manager --add-repo https://openresty.org/package/centos/openresty.repo
    sudo yum install openresty
  • helloworld
    1/创建工程目录
    mkdir ~/work
    cd ~/work
    mkdir logs/ conf/

2/nginx配置文件

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

3/启动nginx服务器
(1)配置环境变量

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

(2) 启动nginx

nginx -p `pwd`/ -c conf/nginx.conf

(3) 测试服务器是否启动成功

* 查看端口

netstat -nultp|grep nginx

* curl命令

curl http://localhost:8080

(4) 查看结果
<p>hello, world</p>

相关文章

网友评论

      本文标题:openresty起步

      本文链接:https://www.haomeiwen.com/subject/owujmftx.html