CentOS 安装 Openresty
本文只针对使用 yum 进行 openresty 的安装
添加 openresty 的 yum 源
yum install yum-utils
yum-config-manager --add-repo https://openresty.org/package/centos/openresty.repo
安装 openresty
yum install openresty
安装 resty 命令行工具
如果对 resty 命令行工具有兴趣的话,可以使用如下命令安装
yum install openresty-resty
列出软件包
yum --disablerepo="*" --enablerepo="openresty" list available
设为开机自启动
systemctl enable openresty
修改控制脚本
vim /usr/lib/systemd/system/openresty.service
# 将 start, reload 命令进行修改
ExecStart=/usr/local/openresty/nginx/sbin/nginx -c /usr/local/openresty/nginx/conf/nginx.conf
ExecReload=/usr/local/openresty/nginx/sbin/nginx -s reload
测试
vim /usr/local/openresty/nginx/conf/nginx.conf
# 添加如下配置
location / {
default_type text/html;
content_by_lua '
ngx.say("<p>hello, world</p>")
';
}
# 测试
curl -XGET 127.0.0.0