1、安装OpenResty的依赖库
yum install -y pcre-devel openssl-devel gcc --skip-broken
2、安装OpenResty的依赖开发库
添加仓库后,未来安装或更新只需要通过yum check-update命令
yum-config-manager --add-repo https://openresty.org/package/centos/openresty.repo
3、安装OpenResty
yum install -y openresty
4、安装opm工具
opm是OpenResty的一个管理工具,可以帮助我们安装一个第三方的Lua模块。
yum install -y openresty-opm
5、配置nginx环境变量
vi /etc/profile
最下面加入这两行
export NGINX_HOME=/usr/local/openresty/nginx
export PATH=${NGINX_HOME}/sbin:$PATH
source /etc/profile
6、启动
# 启动nginx
nginx
# 重新加载配置
nginx -s reload
# 停止
nginx -s stop
7、修改nginx配置
如果需要做Lua编程,就要删除nginx中大量的注释,方便编写
#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;
}
}
}
8、测试