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中成长