当前位置:

在 Ubuntu 上使用源码安装 OpenResty

访客 2024-01-05 335 0

本文将介绍如何在Ubuntu上使用源码安装OpenResty。

目标
  • Ubuntu18.04
  • OpenResty1.19.3.2
安装依赖
  • 启用HTTP基本状态模块:--with-http_stub_status_module
  • 启用HTTPgzip静态文件压缩模块:--with-http_gzip_static_module
  • 启用HTTP/2模块:--with-http_v2_module

zlib1g-dev:theHTTPgzipmodulerequiresthezliblibrary.

apt-getupdate-yapt-getinstall-ylibpcre3-dev\libssl-dev\perl\make\build-essential\curl\zlib1g-dev下载OpenRestycd/optcurl-LOhttps://openresty.org/download/openresty-1.19.3.2.tar.gztarzxfopenresty-1.19.3.2.tar.gz安装OpenResty.configure\--with-http_gzip_static_module\--with-http_v2_module\--with-http_stub_status_modulemakemakeinstall使用systemd管理OpenResty服务编写Service文件

/usr/lib/systemd/system目录下创建一个openresty.service文件,文件内容如下:

#StopdanceforOpenResty#=========================##ExecStopsendsSIGSTOP(gracefulstop)toOpenResty'snginxprocess.#If,after5s(--retryQUIT/5)nginxisstillrunning,systemdtakescontrol#andsendsSIGTERM(fastshutdown)tothemainprocess.#Afteranother5s(TimeoutStopSec=5),andifnginxisalive,systemdsends#SIGKILLtoalltheremainingprocessesintheprocessgroup(KillMode=mixed).##nginxsignalsreferencedoc:#http://nginx.org/en/docs/control.html#[Unit]Description=TheOpenRestyApplicationPlatformAfter=syslog.targetnetwork-online.targetremote-fs.targetnss-lookup.targetWants=network-online.target[Service]Type=forkingPIDFile=/usr/local/openresty/nginx/logs/nginx.pidExecStartPre=/usr/local/openresty/nginx/sbin/nginx-t-q-g'daemonon;master_processon;'ExecStart=/usr/local/openresty/nginx/sbin/nginx-g'daemonon;master_processon;'ExecReload=/usr/local/openresty/nginx/sbin/nginx-g'daemonon;master_processon;'-sreloadExecStop=-/sbin/start-stop-daemon--quiet--stop--retryQUIT/5--pidfile/usr/local/openresty/nginx/logs/nginx.pidTimeoutStopSec=5KillMode=mixed[Install]WantedBy=multi-user.target启动OpenResty#设置自启动systemctlenableopenresty#启动OpenRestysystemctlstartopenresty#查看OpenResty服务状态systemctlstatusopenresty●openresty.service-TheOpenRestyApplicationPlatformLoaded:loaded(/usr/lib/systemd/system/openresty.service;enabled;vendorpreset:enabled)Active:active(running)sinceSat2021-07-1011:36:07CST;26minagoProcess:12735ExecStart=/usr/local/openresty/nginx/sbin/nginx-gdaemonon;master_processon;(code=exited,status=0/SUCCESS)Process:12734ExecStartPre=/usr/local/openresty/nginx/sbin/nginx-t-q-gdaemonon;master_processon;(code=exited,status=0/SUCCESS)MainPID:12736(nginx)Tasks:2(limit:1126)CGroup:/system.slice/openresty.service├─12736nginx:masterprocess/usr/local/openresty/nginx/sbin/nginx-gdaemonon;master_processon;└─12737nginx:workerprocessJul1011:36:07iZj6c0qglm7rjjctj7zxnfZsystemd[1]:StartingTheOpenRestyApplicationPlatform...Jul1011:36:07iZj6c0qglm7rjjctj7zxnfZsystemd[1]:openresty.service:FailedtoparsePIDfromfile/usr/local/openresty/nginx/logs/nginx.pid:Jul1011:36:07iZj6c0qglm7rjjctj7zxnfZsystemd[1]:StartedTheOpenRestyApplicationPlatform.一键安装脚本

GitHubGist

发表评论

  • 评论列表
还没有人评论,快来抢沙发吧~