Centos6-OpenResty安装

2020-06-03  本文已影响0人  testerzhang

1.前言

最近需要安装OpenResty,如果是直接yum安装还是很方便的,这里记录一下openresty/1.15.8.3安装过程

2.安装

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.2 追加环境变量

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

3.3 生效环境变量

# source  ~/.bash_profile 

3.4 启动服务

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

3.5 验证

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

上一篇下一篇

猜你喜欢

热点阅读