zoukankan      html  css  js  c++  java
  • openresty随笔2---helloworld

    1.安装OpenResty:

    下面是说明:

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

    ubuntu系统可以按照链接里面的教程安装openresty,如果是类ubuntu的系统可能会出一些问题,可以通过源码安装:

    下载源码包:

    wget https://openresty.org/download/openresty-1.13.6.2.tar.gz

    我把文件放到/usr/local/src下,并解压

    sudo tar -zxvf  openresty-1.13.6.2.tar.gz

    安装需要准备相应的依,因为我的是deepin,用的源是ubuntu的,所有我看的是ubuntu的部分的说明:

    apt-get install libpcre3-dev  libssl-dev perl make build-essential curl

    进入安装目录

    cd /usr/local/src/openresty-1.13.6.2

    可以通过./configure --help查看各种模块,因为刚开始做,所以我一切都是默认

    ./configure

    如果报错说明有些依赖没有安装,需要手动安装一下。

    没有报错的话进行编译安装

    make 
    make install

    完成以后发现,/usr/local/下多了一个openresty目录。

    2.使用openresty:

    因为我本地存在一个nginx,安装openresty后需要注意两个nginx.conf的端口不能重复。

    修改nginx.conf配置将默认80端口改为,6001端口:

    cd /usr/local/openresty/nginx/conf
    vim nginx.conf

    只是修改server下的端口好其他不变。

    重启nginx

    cd /usr/local/openresty/nginx/sbin
    ./nginx -c /usr/local/openresty/nginx/conf/nginx.conf
    ./nginx -s reload

    出现:


    Welcome to OpenResty!

    If you see this page, the OpenResty web platform is successfully installed and working. Further configuration is required.

    For online documentation and support please refer to openresty.org.
    Commercial support is available at openresty.com.

    Thank you for flying OpenResty.


    3.helloworld的实现:

    建议开发的时候将openresty目录发到vscode里面开发,修改目录所属权限

    修改nginx.conf文件:

     location / {
                root   html;
                index  index.html index.htm;
            }
    
    #下面是新增的
    location /hello {
                default_type text/html;
                content_by_lua_block {
                    ngx.say("<p>hello, world</p>")
                }
            }

    当服务器请求的路径为/hello的时候会导引hello,world

    conent_by_lua_block:是一个指令,可以通过下面的链接查看:

    https://github.com/openresty/lua-nginx-module#directives

  • 相关阅读:
    grafana+mysql忘记admin密码解决方法
    grafana 的配置文件,和使用mysql数据库做持久化
    贴两个mysql优化的配置文件
    Zabbix监控win10系统
    zabbix监控mysql
    http状态码-备查
    安卓移动端line-height垂直居中出现偏移的解决方法
    Video 自动播放
    渐进式Web应用(PWA)
    基于svg的环形进度条
  • 原文地址:https://www.cnblogs.com/callmelx/p/11123730.html
Copyright © 2011-2022 走看看