
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
正文完