安装
根据官网安装页说明
http://openresty.org/en/linux-packages.html
# 这三个包已经存在, 所以新安装为0 apt install --no-install-recommends wget gnupg ca-certificates # 清理了一下之前升级留下来的文件 apt autoremove # key wget -O - https://openresty.org/package/pubkey.gpg | sudo apt-key add - # 安装依赖 apt install --no-install-recommends software-properties-common # 将OpenResty添加到软件源 add-apt-repository -y "deb http://openresty.org/package/ubuntu $(lsb_release -sc) main" # 安装OpenResty, 未安装默认自带的open和resty-doc apt install --no-install-recommends openresty
安装完后, 服务会自动启动
修改工作目录
需要将工作目录转移到 /opt/openresty
cd /opt # 首先将工作目录(包含权限)复制过去, 注意 -p 参数, 用于复制权限 cp -rp /usr/local/openresty/nginx/ . # 修改目录名 mv nginx/ openresty
修改systemd服务文件, 修改完的内容是这样的, 需要修改的三处: pid路径, 启动增加 -p 工作目录路径 和 -c 配置文件路径.
# Stop dance for OpenResty # ========================= # # ExecStop sends SIGSTOP (graceful stop) to OpenResty's nginx process. # If, after 5s (--retry QUIT/5) nginx is still running, systemd takes control # and sends SIGTERM (fast shutdown) to the main process. # After another 5s (TimeoutStopSec=5), and if nginx is alive, systemd sends # SIGKILL to all the remaining processes in the process group (KillMode=mixed). # # nginx signals reference doc: # http://nginx.org/en/docs/control.html # [Unit] Description=full-fledged web platform After=network.target [Service] Type=forking PIDFile=/opt/openresty/logs/nginx.pid ExecStartPre=/usr/local/openresty/nginx/sbin/nginx -t -q -g 'daemon on; master_process on;' -p /opt/openresty -c /opt/openresty/conf/nginx.conf ExecStart=/usr/local/openresty/nginx/sbin/nginx -g 'daemon on; master_process on;' -p /opt/openresty -c /opt/openresty/conf/nginx.conf ExecReload=/usr/local/openresty/nginx/sbin/nginx -g 'daemon on; master_process on;' -s reload -p /opt/openresty -c /opt/openresty/conf/nginx.conf ExecStop=-/sbin/start-stop-daemon --quiet --stop --retry QUIT/5 --pidfile /opt/openresty/logs/nginx.pid TimeoutStopSec=5 KillMode=mixed [Install] WantedBy=multi-user.target
然后 systemctl daemon-reload , systemctl restart openresty 就可以了.