centos 安装 openresty

安装

sudo yum install yum-utils
sudo yum-config-manager --add-repo https://openresty.org/package/centos/openresty.repo
sudo yum install openresty

systemctl管理

/usr/lib/systemd/system/nginx.service

[Unit]
Description=The nginx HTTP and reverse proxy server
After=network.target remote-fs.target nss-lookup.target

[Service]
Type=forking
ExecStart=/usr/local/openresty/nginx/sbin/nginx
ExecStop=/usr/local/openresty/nginx/sbin/nginx -s quit
ExecReload=/usr/local/openresty/nginx/sbin/nginx -s reload

[Install]
WantedBy=multi-user.target
systemctl enable nginx #自启动
systemctl start nginx  #启动
systemctl reload nginx  #重启
systemctl stop nginx  #停止
systemctl status nginx # 查看状态

Ubuntu 安装

安装

# 导入我们的 GPG 密钥:
wget -qO - https://openresty.org/package/pubkey.gpg | sudo apt-key add -

# 安装 add-apt-repository 命令
# (之后你可以删除这个包以及对应的关联包)
sudo apt-get -y install software-properties-common

# 添加我们官方 official APT 仓库:
sudo add-apt-repository -y "deb http://openresty.org/package/ubuntu $(lsb_release -sc) main"

# 更新 APT 索引:
sudo apt-get update
# 然后就可以像下面这样安装软件包,比如 openresty:
sudo apt-get install openresty

问题

有问题直接看 tail -f /var/log/syslog

openresty.service: Can't open PID file /usr/local/openresty/nginx/logs/nginx.pid (yet?) after start: No such file or directory

修改 /lib/systemd/system/openresty.service PIDFile 路径