美文网首页
Centos6系统安装OpenResty

Centos6系统安装OpenResty

作者: testerzhang | 来源:发表于2020-08-31 14:17 被阅读0次

本文转自我的头条号:testerzhang,现同步自我的简书。

1.OpenResty是什么

OpenResty是一个基于 Nginx 与 Lua 的高性能 Web 平台,其内部集成了大量精良的 Lua 库、第三方模块以及大多数的依赖项。

用于方便地搭建能够处理超高并发、扩展性极高的动态 Web 应用、Web 服务和动态网关。

让我们开始安装吧

2.安装

下面以openresty/1.15.8.3为例,进行说明如何安装。

2.1 安装系统依赖库

# yum install readline-devel pcre-devel openssl-devel

2.2 安装yum源

# wget https://openresty.org/package/centos/openresty.repo
# mv openresty.repo /etc/yum.repos.d/
# yum check-update

2.3 安装openresty

# yum install -y openresty

2.4 验证

#  openresty -h
nginx version: openresty/1.15.8.3
Usage: nginx [-?hvVtTq] [-s signal] [-c filename] [-p prefix] [-g directives]
Options:
  -?,-h         : this help
  -v            : show version and exit
  -V            : show version and configure options then exit
  -t            : test configuration and exit
  -T            : test configuration, dump it and exit
  -q            : suppress non-error messages during configuration testing
  -s signal     : send signal to a master process: stop, quit, reopen, reload
  -p prefix     : set prefix path (default: /usr/local/openresty/nginx/)
  -c filename   : set configuration file (default: conf/nginx.conf)
  -g directives : set global directives out of configuration file
安装完成,下面我们继续部署吧

3.部署

3.1 准备目录

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

3.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_block {                
                                    ngx.say("<p>hello, world</p>")
                                  }        
              }    
         }
}

注意:

  1. 如果端口被其他进程占用,改下端口即可。
  2. 建议配置文件增加一个配置user root;

3.3 追加环境变量

# vim ~/.bash_profile 
PATH=/usr/local/openresty/nginx/sbin:$PATH
export PATH

3.4 生效环境变量

# source  ~/.bash_profile 

3.5 启动服务

# cd ~/work
# nginx -p `pwd`/ -c conf/nginx.conf

3.6 验证

访问网址http://localhost:8080/,出现hello, world就部署成功了。

相关文章

网友评论

      本文标题:Centos6系统安装OpenResty

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