Ubuntu 20.04.6 安装 OpenResty 过程

step1 下载安装包

https://openresty.org/cn/installation.html

step 2 按照官方给出的步骤解压后安装

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

期间遇到的问题

1、首先你的机子上要安装gcc环境,因为安装的过程涉及大量C文件编译
2、其次遇到的报错做一个汇总
一、error: the HTTP rewrite module requires the PCRE library

解决方法:

安装pcre包。
sudo apt-get update
sudo apt-get install libpcre3 libpcre3-dev

可能还需要安装
sudo apt-get install openssl libssl-dev

二、error: the HTTP gzip module requires the zlib library

解决方案:
安装 zlib-devel 依赖包。
Ubuntu 执行如下命令:
sudo apt-get install zlib1g-dev

step3 配置环境变量

vi /etc/profile
export NGINX_HOME=/usr/local/openresty/nginx
export PATH=${NGINX_HOME}/sbin:$PATH
source /etc/profile

检验安装

键入ng+tab后的命令提示
在这里插入图片描述

启动命令,与nginx基本一致

# 启动nginx
nginx
# 重新加载配置
nginx -s reload
# 停止
nginx -s stop

贴出简化版nginx.conf

#user  nobody;
worker_processes  1;
error_log  logs/error.log;

events {
    worker_connections  1024;
}

http {
    include       mime.types;
    default_type  application/octet-stream;
    sendfile        on;
    keepalive_timeout  65;

    server {
        listen       8081;
        server_name  localhost;
        location / {
            root   html;
            index  index.html index.htm;
        }
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
    }
}

注意此处配置的端口为8081
之后重启nginx

nginx

访问ip:8081

在这里插入图片描述

记录学习中的点点滴滴,在error和exception中成长

  • 7
    点赞
  • 10
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值