1. 安装依赖
yum install pcre-devel openssl-devel gcc curl postgresql-devel
2. 下载解压
#下载
wget -c https://openresty.org/download/openresty-1.15.8.1rc2.tar.gz
#解压
tar -zxvf openresty-1.15.8.1rc2.tar.gz
3. 源码编译
//切换目录
cd openresty-1.15.8.1rc2
//开始安装 ./configure #或者下面,后面是参数 不写默认就行
./configure
--prefix=/usr/local/openresty/
--with-http_stub_status_module
--with-luajit
--without-http_redis2_module
--with-http_iconv_module
--with-http_postgres_module
--with-stream gmake && gmake install
4. 添加环境变量
#打开配置文件
vim /etc/profile
#编写配置变量
PATH=/usr/local/openresty/nginx/sbin:$PATH
export PATH
#保存退出
#执行生效命令:
source /etc/profile
#查看是否生效:
echo $PATH
查看配置结果
5. 添加仓库执行命令
#加载依赖
yum install yum-utils
#下载repo
yum-config-manager --add-repo https://openresty.org/package/centos/openresty.repo
6. 执行安装
#安装
yum install openresty
#安装成功后 会在默认的目录如下:
/usr/local/openresty
7. 配置nginx
#默认已经安装好了nginx,在目录:/usr/local/openresty/nginx下。
#修改/usr/local/openresty/nginx/conf/nginx.conf ,将配置文件使用的根设置为root,目的就是将来要使
#用lua脚本的时候 ,直接可以加载在root下的lua脚本。
#进入openresty 中nginx
cd /usr/local/openresty/nginx
#启动nginx
sbin/nginx -c conf/nginx.conf
#重启 OpenResty
nginx -s reload