• centos7安装openresty


    介绍:

       Nginx 采用一个 master 进程管理多个 worker 进程(master-worker)模式,基本的事件处理都在 woker 中,master 负责一些全局初始化,以及对 worker 的管理。在OpenResty中,每个 woker 使用一个 LuaVM,当请求被分配到 woker 时,将在这个 LuaVM 里创建一个 coroutine(协程)。协程之间数据隔离,每个协程具有独立的全局变量_G。OpenResty致力于将服务器应用完全运行与nginx中,充分利用nginx事件模型进行非阻塞I/O通信。其对MySQL、redis、Memcached的IO通信操作也是非阻塞的,可以轻松应对10K以上的超高连接并发。

    1、安装openresty

       1)、通过在CentOS 系统中添加 openresty 仓库,便于未来安装或更新我们的软件包(通过 yum update 命令)

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

      2)、安装openresty

    sudo yum install openresty
    

      3)、安装命令行工具 resty

    sudo yum install openresty-resty
    

      命令行工具 opm 在 openresty-opm 包里,而 restydoc 工具在 openresty-doc 包里头。

       4)、查看openresty 仓库里头的软件包

    sudo yum --disablerepo="*" --enablerepo="openresty" list available
    

      

      至此安装成功,默认安装在  /usr/local/openresty

    2、测试

      1)、启动

    --此命令运行在/usr/local/openresty目录下
    sudo /sbin/service openresty start 
    --停止
    sudo /sbin/service openresty stop
    

      

    3、hello word

       1)、创建example文件夹

    cd usr/
    
    mkdir example
    

      2)、创建lua.conf及lua脚本

    cd example/
    
    vim lua.conf

    server {  
        listen       80;  
        server_name  _;  
        lua_code_cache off;  #关闭lua缓存
        location /lua {  
            default_type 'text/html';   
            content_by_lua_file /usr/example/lua/test.lua;  
        }  
    } 

    --此文件夹用于存放lua脚本

    mkdir luafile

    vim test.lua

    ngx.say("hello world");

      3)、配置nginx.conf

    worker_processes  1;
    events {
        worker_connections  1024;
    }
    http {
        include       mime.types;
        default_type  application/octet-stream;
        include /usr/example/lua.conf;#引入lua脚本配置文件
        server {
            listen       80;
            server_name  localhost;
            location / {
                root   html;
                index  index.html index.htm;
            } 
            error_page   500 502 503 504  /50x.html;
            location = /50x.html {
                root   html;
            }
        }
    }
    
            
                
    

      4)、重启openrsty

     openresty介绍参考自:https://www.cnblogs.com/zampo/p/4269147.html 以及自己的理解

  • 相关阅读:
    linux多线程学习笔记五--线程安全【转】
    linux多线程学习笔记六--一次性初始化和线程私有数据【转】
    【Linux】可重入函数和线程安全的区别与联系【转】
    【Linux】自主实现my_sleep【转】
    Linux/Unix编程中的线程安全问题【转】
    C语言字符串操作总结大全(超详细)【转】
    linux中的strip命令简介------给文件脱衣服【转】
    FTK应用程序编程接口(API)手册-1【转】
    python编程(python开发的三种运行模式)【转】
    ftk学习记(label篇)【转】
  • 原文地址:https://www.cnblogs.com/staticking/p/9933575.html
Copyright © 2020-2023  润新知