centos下tengine编译ngx_cache_purge,lua,geoip等插件支持
概述:最近有一些需求需要在nginx上支持lua,由于原来的安装基于官方nginx的版本,也没有增加lua等插件的支持,所以基于tengine和增加一些需要的插件,简要的写了下面的安装文档,也做了一下记录,可能插件的版本有所区别,但多数情况下应该可以正常使用,最后将原来的配置文件放到了新部署的tengine的下面,检查后,正常跑起来了,做到了无缝迁移。
系统环境版本:centos 7.9
tengine版本基于:2.3.2
说明:centos7.9基于新安装的系统,安装环境为了避免网络出现不可预估的问题,使用了screen作为终端连接辅助工具。
#开启screen
#yum install screen -y
#screen -S nginxinstall
#mkdir /opt/nginx
#增加运行用户和基础环境包
#groupadd -g 155 -r www && useradd -s /sbin/nologin -u 155 -r -g www www
#yum -y install gcc gcc-c++ unzip make zlib-devel pcre-devel openssl-devel GeoIP-devel lua-devel
#yum -y install gd gd-devel luajit-devel libmaxminddb-devel libmaxminddb
#下载插件包
#wget -c -P /opt/nginx https://tengine.taobao.org/download/tengine-2.3.2.tar.gz
#wget -c -P /opt/nginx https://github.com/FRiCKLE/ngx_cache_purge/archive/2.3.tar.gz
#wget -c -P /opt/nginx https://github.com/openresty/headers-more-nginx-module/archive/v0.30.tar.gz
#wget -c -P /opt/nginx https://github.com/leev/ngx_http_geoip2_module/archive/3.3.tar.gz
#wget -c -P /opt/nginx http://luajit.org/download/LuaJIT-2.1.0-beta3.tar.gz
#wget -c -P /opt/nginx https://github.com/vision5/ngx_devel_kit/archive/v0.3.1.tar.gz
#wget -c -P /opt/nginx https://github.com/openresty/lua-nginx-module/archive/v0.10.10.tar.gz
#编译lua插件和配置环境
#tar -zvxf /opt/nginx/LuaJIT-2.1.0-beta3.tar.gz -C /usr/share/
#cd /usr/share/LuaJIT-2.1.0-beta3/
#make PREFIX=/usr/local/luajit
#make install PREFIX=/usr/local/luajit
#echo '
export LUAJIT_LIB=/usr/local/luajit/lib
export LUAJIT_INC=/usr/local/luajit/include/luajit-2.1' >> /etc/profile
#source /etc/profile
#解压所需要的插件包和tengine安装包
tar -zxvf /opt/nginx/2.3.tar.gz -C /opt/nginx
tar -zxvf /opt/nginx/tengine-2.3.2.tar.gz -C /opt/nginx
tar -zxvf /opt/nginx/v0.30.tar.gz -C /opt/nginx/
tar -zxvf /opt/nginx/3.3.tar.gz -C /opt/nginx/
tar -zvxf /opt/nginx/v0.3.1.tar.gz -C /opt/nginx/
tar -zvxf /opt/nginx/v0.10.10.tar.gz -C /opt/nginx
#mkdir -p /var/log/nginx/ && cd /opt/nginx/tengine-2.3.2
#编译nginx
#./configure --prefix=/usr/local/nginx
--user=www --group=www
--sbin-path=/usr/sbin/nginx
--conf-path=/usr/local/nginx/config/nginx.conf
--error-log-path=/var/log/nginx/error.log
--http-log-path=/var/log/nginx/access.log
--pid-path=/run/nginx.pid
--lock-path=/usr/local/nginx/lock/nginx.lock
--with-pcre-opt=-fPIC
--with-pcre-jit --with-ld-opt='-ljemalloc' --with-ld-opt="-Wl,-rpath,/usr/local/luajit/lib"
--with-http_v2_module --with-http_sub_module
--with-http_gunzip_module
--with-http_realip_module --with-http_flv_module
--with-http_stub_status_module
--with-http_gzip_static_module
--with-http_secure_link_module
--with-http_degradation_module
--with-http_image_filter_module
--with-http_ssl_module
--with-http_geoip_module
--http-proxy-temp-path=/usr/local/nginx/proxy_temp
--http-fastcgi-temp-path=/usr/local/nginx/fastcgi_temp
--http-uwsgi-temp-path=/usr/local/nginx/uwsgi_temp
--http-scgi-temp-path=/usr/local/nginx/scgi_temp
--add-module=/opt/nginx/ngx_cache_purge-2.3
--add-module=/opt/nginx/headers-more-nginx-module-0.30
--add-module=/opt/nginx/ngx_http_geoip2_module-3.3
--add-module=./modules/ngx_http_proxy_connect_module
--add-module=./modules/ngx_http_upstream_check_module
--add-module=./modules/ngx_http_upstream_session_sticky_module
--add-module=./modules/ngx_http_upstream_dynamic_module
--add-module=./modules/ngx_http_user_agent_module
--add-module=./modules/ngx_http_concat_module
--add-module=./modules/ngx_http_footer_filter_module
--add-module=./modules/ngx_http_reqstat_module
--add-module=./modules/ngx_http_slice_module
--add-module=./modules/ngx_http_trim_filter_module
--add-module=./modules/ngx_http_upstream_consistent_hash_module
--add-module=./modules/ngx_multi_upstream_module
--add-module=/opt/nginx/ngx_devel_kit-0.3.1
--add-module=/opt/nginx/lua-nginx-module-0.10.10
#make -j 2 && make install
#增加nginx开机启动
#cd /lib/systemd/system/ && vim nginx.service
[Unit]
Description=nginx service
After=network.target
[Service]
Type=forking
PIDFile=/run/nginx.pid
ExecStartPre=/usr/sbin/nginx -t
ExecStart=/usr/sbin/nginx
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s QUIT $MAINPID
PrivateTmp=true
[Install]
WantedBy=multi-user.target
#systemctl start nginx
#systemctl enable nginx
最后,将原来已经正常在跑和使用中的配置文件放入tengine目录中,并且include进来,测试配置文件后,停原来的nginx启动tengine!
本文标签: ngx_cache_pu lua geoip nginx插件
内容版权声明:【蓝色网居】部分资源来源于网络,如有侵犯您的所有权,请随时告知我们,我们将立即删除!感谢配合!
【手机扫一扫查看文本】
cookie 后台管理 四层 访问控制 错误日志 定义404跳转 接口请求 geoIP模块 404 pass_proxy的使 nginx nginx插件 与(and) 请求频率 语言选择 $server_name 强匹配 ip白名单 referer限制 重写 编译安装 try_files 404自定义 恶意请求 apache 案例分析 日志分析 $http_host geoip lua

