Ubuntu22.04下OpenResty安装指南

198 次浏览次阅读
Ubuntu22.04下OpenResty安装指南

OpenResty介绍

OpenResty是基于Nginx的再发行版,它通过将Nginx与一系列的Lua模块和第三方插件进行集成,提供了一种高性能、可扩展的Web应用开发环境。

安装

#下载
wget https://openresty.org/download/openresty-1.21.4.3.tar.gz
#解压
tar -xvf openresty-1.21.4.3.tar.gz

cd openresty-VERSION/
#编译
./configure --prefix=/opt/openresty \
            --with-pcre-jit \
            --with-ipv6 \
            --without-http_redis2_module \
            --with-http_iconv_module \
	    --with-http_ssl_module \
            --with-http_v2_module \
	    --with-http_realip_module \
	    --with-http_gzip_static_module \
	    --without-http_gzip_module \
            -j2

make -j2
make install
#更新环境变量,如果配置了别的目录这里需要改
vim ~/.bashrc
#将一下内容复制到~/.bashrc末尾
export PATH=/usr/local/openresty/bin:/usr/local/openresty/nginx/sbin:$PATH
#保存退出之后
source ~/.bashrc

#安装完毕
#命令行执行nginx可以测试下效果

自启动配置

vim /lib/systemd/system/openresty.service
#openresty.service内容
[Unit]
Description=openresty - high performance web server
After=network.target

[Service]
Type=forking
PIDFile=/data/logs/nginx/nginx.pid
ExecStartPost=/bin/sleep 0.1
ExecStartPre=/opt/openresty/nginx/sbin/nginx -t -c /opt/openresty/nginx/conf/nginx.conf
ExecStart=/opt/openresty/nginx/sbin/nginx -c /opt/openresty/nginx/conf/nginx.conf
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s QUIT $MAINPID

[Install]
WantedBy=multi-user.target
#openresty.service内容

#刷新所有服务
sudo systemctl daemon-reload
#添加服务开机自启
systemctl enable openresty.service 
#启动nginx服务
systemctl start openresty.service
#关闭nginx服务
systemctl stop openresty.service
正文完
 2
马化云
版权声明:本站原创文章,由 马化云 2024-01-05发表,共计1306字。
转载说明:除特殊说明外本站文章皆由CC-4.0协议发布,转载请注明出处。