1.nginx安装第三方模块

nginx安装第三方模块需要进行编译安装,安装方法如下:

./configure --prefix=/你的安装目录  --add-module=/第三方模块目录 ...

注意:编译第三方模块时需要把原来编译的选项全部加上,否则新编译的功能不回包含之前的编译功能,查看当前nginx的编译选项的方法为:

[root@xuzhichao ~]# nginx -V

注意:编译第三方模块时只需要执行make,不需要make install,否则会完全覆盖之前的nginx。

下面以nginx的第三方echo模块安装为例进行演示:

  • 第一步:测试nginx的配置文件

    [root@xuzhichao ~]# cat /etc/nginx/conf.d/vhost.conf
    [root@xuzhichao nginx-1.20.1]# cat /etc/nginx/conf.d/vhost.conf
    server {
    listen 80;
    server_name www.module.com; root /data/nginx/html/web01;
    location / {
    index index.html;
    } location /test/ {
    echo "this is a test dir!";
    }
    location /main {
    index index.html;
    echo "hello world,main-->";
    echo_reset_timer;
    echo_location /sub1;
    echo_location /sub2;
    echo "took $echo_timer_elapsed sec for total.";
    } location /sub1 {
    echo_sleep 1;
    echo sub1;
    } location /sub2 {
    echo_sleep 1;
    echo sub2;
    }
    } #nginx不识别echo语句。
    [root@xuzhichao ~]# nginx -t
    nginx: [emerg] unknown directive "echo" in /etc/nginx/conf.d/vhost.conf:11
    nginx: configuration file /etc/nginx/nginx.conf test failed
  • 进行安装echo模块,使用wget或git下载echo模块

    #下载echo模块
    [root@xuzhichao ~]# yum install git -y
    [root@xuzhichao ~]# git clone https://github.com/openresty/echo-nginx-module.git #新建third_moule目录专门用于存放第三方模块
    [root@xuzhichao ~]# cd nginx-1.20.1/
    [root@xuzhichao nginx-1.20.1]# mkdir third_moule
    [root@xuzhichao nginx-1.20.1]# cp -a /root/echo-nginx-module/ third_moule/
  • 重新编译

    #首先查看当前nginx的编译选项
    [root@xuzhichao nginx-1.20.1]# nginx -V
    nginx version: nginx/1.20.1
    built by gcc 4.8.5 20150623 (Red Hat 4.8.5-39) (GCC)
    built with OpenSSL 1.0.2k-fips 26 Jan 2017
    TLS SNI support enabled
    configure arguments: --prefix=/apps/nginx --conf-path=/etc/nginx/nginx.conf --sbin-path=/usr/sbin/nginx --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx.pid --lock-path=/var/run/nginx.lock --http-client-body-temp-path=/var/cache/nginx/client_temp --http-proxy-temp-path=/var/cache/nginx/proxy_temp --http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp --http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp --http-scgi-temp-path=/var/cache/nginx/scgi_temp --user=nginx --group=nginx --with-http_ssl_module --with-http_v2_module --with-http_realip_module --with-http_dav_module --with-http_stub_status_module --with-http_gzip_static_module --with-pcre --with-stream --with-stream_ssl_module --with-stream_realip_module --with-file-aio #编译第三方模块
    [root@xuzhichao nginx-1.20.1]# ./configure --prefix=/apps/nginx --conf-path=/etc/nginx/nginx.conf --sbin-path=/usr/sbin/nginx --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx.pid --lock-path=/var/run/nginx.lock --http-client-body-temp-path=/var/cache/nginx/client_temp --http-proxy-temp-path=/var/cache/nginx/proxy_temp --http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp --http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp --http-scgi-temp-path=/var/cache/nginx/scgi_temp --user=nginx --group=nginx --with-http_ssl_module --with-http_v2_module --with-http_realip_module --with-http_dav_module --with-http_stub_status_module --with-http_gzip_static_module --with-pcre --with-stream --with-stream_ssl_module --with-stream_realip_module --with-file-aio --add-module=/root/nginx-1.20.1/third_moule/echo-nginx-module #执行make操作
    [root@xuzhichao nginx-1.20.1]# make
    ......
  • 替换nginx二进制文件

    #查看当前nginx二进制文件路径
    [root@xuzhichao ~]# which nginx
    /usr/sbin/nginx #复制时报错,因为nginx正在运行
    [root@xuzhichao nginx-1.20.1]# cp objs/nginx /usr/sbin/nginx
    cp: overwrite ‘/usr/sbin/nginx’? y
    cp: cannot create regular file ‘/usr/sbin/nginx’: Text file busy #强行复制,成功。
    [root@xuzhichao nginx-1.20.1]# cp objs/nginx /usr/sbin/nginx -f
    cp: overwrite ‘/usr/sbin/nginx’? y
  • 重启nginx服务

    #检测语法无报错
    [root@xuzhichao nginx-1.20.1]# nginx -t
    nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
    nginx: configuration file /etc/nginx/nginx.conf test is successful #重启nginx服务,restart而不是reload,新模块需要重启生效
    [root@xuzhichao nginx-1.20.1]# systemctl restart nginx #查看nginx编译选项
    [root@xuzhichao nginx-1.20.1]# nginx -V
    nginx version: nginx/1.20.1
    built by gcc 4.8.5 20150623 (Red Hat 4.8.5-39) (GCC)
    built with OpenSSL 1.0.2k-fips 26 Jan 2017
    TLS SNI support enabled
    configure arguments: --prefix=/apps/nginx --conf-path=/etc/nginx/nginx.conf --sbin-path=/usr/sbin/nginx --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx.pid --lock-path=/var/run/nginx.lock --http-client-body-temp-path=/var/cache/nginx/client_temp --http-proxy-temp-path=/var/cache/nginx/proxy_temp --http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp --http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp --http-scgi-temp-path=/var/cache/nginx/scgi_temp --user=nginx --group=nginx --with-http_ssl_module --with-http_v2_module --with-http_realip_module --with-http_dav_module --with-http_stub_status_module --with-http_gzip_static_module --with-pcre --with-stream --with-stream_ssl_module --with-stream_realip_module --with-file-aio --add-module=/root/nginx-1.20.1/third_moule/echo-nginx-module
  • 客户端测试访问

    [root@nginx01 ~]# curl http://www.module.com/test/
    this is a test dir!
    [root@nginx01 ~]# curl http://www.module.com/main/
    hello world,main-->
    sub1
    sub2
    took 2.019 sec for total.

WEB服务与NGINX(15)-NGINX安装第三方模块的更多相关文章

  1. Nginx编译安装第三方模块http_substitutions_filter_module

    Nginx编译安装第三方模块http_substitutions_filter_module 分类:服务器技术  作者:rming  时间:-- . >>ngx_http_substitu ...

  2. nginx安装第三方模块echo

    要使用第三方模块ngx_echo的功能,请重新配置添加到nginx插件中 ##下载第三方模块 wget https://github.com/openresty/echo-nginx-module/a ...

  3. Nginx编译安装第三方模块http_substitutions_filter_module2222

    Nginx编译安装第三方模块http_substitutions_filter_module Rming -- 阅读 安装 Http 编译 module filter nginx 模块 >> ...

  4. nginx 安装第三方 模块

    查看nginx在安装时开启了哪些模块 如果你nginx是rpm包安装的,直接用如下命令nginx -V 如果你是源码包编译安装,假如你的安装路径是/usr/local/nginx,那么你可以使用: / ...

  5. sae python安装第三方模块

    sae python安装第三方模块 经过这一个星期的折腾,发现编程真心不是看出来的,真心是跟着书上的代码敲出来的.sae的服务做得很好,不过有时候会崩就是了.当sae上没有自己所需要的第三方模块时,可 ...

  6. python——模块(Module)的概念、使用以及安装第三方模块

    一.模块定义 python中,一个.py文件就是一个模块(Module). 使用模块的好处:1.提高了代码的可维护性.我们把函数进行分组,分别放在不同的模块中.2.编写代码不必要从0开始,当一个模块编 ...

  7. 【Python】[模块]使用模块,安装第三方模块

    一个.py文件就称之为一个模块(Model)按目录来组织模块的方法,称为包(Package)每一个包目录下面都会有一个__init__.py的文件内置函数1.使用模块 导入模块 import sys ...

  8. 安装第三方模块方法和requests

    如何安装第三方模块 pip3         pip3 install xxxx          源码         下载,解压         进入目录 python setup.py inst ...

  9. python 安装第三方模块

    在Python中,安装第三方模块,是通过setuptools这个工具完成的. 如果你正在使用Mac或Linux,安装setuptools本身这个步骤就可以跳过了. 如果你正在使用Windows,请首先 ...

  10. Anaconda安装第三方模块

    Anaconda安装第三方模块 普通安装: 进去\Anaconda\Scripts目录,conda install 模块名 源码安装: 进去第三方模块目录,python install setup.p ...

随机推荐

  1. 基于rv1126 rkmeida 一路多出 原理

    基于rv1126 rkmeida 一路多出的坑 首先说要的是介绍一下rkmedia 相关内容 ​ RKMedia提供了一种媒体处理方案,可支持应用软件快速开发.RKMedia在各模块基础API上做进一 ...

  2. 5W1H聊开源之Why——为什么要参与开源?

    中国开源的发展速度发展加快,个人和组织对于为开源作贡献有着前所未有的激情.据<2020年IT行业项目管理调查报告>,约四成受访者以自己开发开源项目.为他人提交项目代码.作为成员开发维护项目 ...

  3. 5W1H聊开源之Who/When/Where——谁在何时何地“发明”了开源?

    美国政治传播学家拉斯韦尔提出了5W传播模式,经过后人的不断运用和发展总结,形成了一套逐渐成熟的"5W1H"体系,即:对选定的项目.工序或操作,都要从原因(何因Why).对象(何事W ...

  4. #差分约束系统,最长路,线段树优化建边#洛谷 3588 [POI2015] PUS

    题目 给定一个长度为\(n\)的正整数序列 \(a\) ,每个数都在 \(1\) 到 \(10^9\) 范围内, 告诉你其中 \(s\) 个数,并给出 \(m\) 条信息,每条信息包含三个数 \(l, ...

  5. 一种基于DeltaE(CIE 1976)的找色算法Cuda实现

    书接上文 一种基于DeltaE(CIE 1976)的找色算法 Delta E 是评估色彩准确度的重要测量指标.摄影师.影片编辑和平面设计师等创意专业人士都应重视这项标准,因其是选择专业级显示器的重要考 ...

  6. Spring内存马分析

    环境搭建 踩了很多坑....,不过还好最后还是成功了 IDEA直接新建javaEE项目,然后记得把index.jsp删了,不然DispatcherServlet会失效 导入依赖: <depend ...

  7. 使用Helm部署Wikijs

    使用 Helm 部署 Wiki.js ️ 参考文档: Wiki.js 官方文档 - 安装 - Kubernetes Wiki.js 使用 Helm 安装 Wiki.js 官方文档 - 安装 - 侧加载 ...

  8. 第十三篇:HTML和CSS入门

    一.HTML本质以及在WEB程序中的作用 1.一套规则,浏览器认识的规则. 2.开发者: 学习html规则 开发后台程序 - 写html文件(充当模板的作用) - 数据库获取数据,然后替换到html文 ...

  9. sql 语句系列(列举非索引外键)[八百章之第九章]

    列举非索引外键 列举出那些外键没有添加索引. 目的: 1.减少锁. 2.外键添加索引,提示了查询性能,因为要与父表做连接查询做笛卡尔积. 下面只要会复制即可,没有会去从新写一遍的. select fk ...

  10. lattice烧录器回读功能。

    经常被人问,lattice的 怎么回读,下面就说这个步骤. 烧录器检测到设备以后,以后选择operation,选择flash programming mode ,选择flash read and sa ...