美文网首页
Nginx动态加载模块

Nginx动态加载模块

作者: 小网管 | 来源:发表于2018-08-27 13:22 被阅读0次

    简介:

    简单说说tengine动态加载http_concat_module模块,并说说我遇见的问题。

    1、说明

    1.1、Tengine动态加载模块的编译安装方法,官方文档:http://tengine.taobao.org/document_cn/dso_cn.html

    1.2、Tengine所有的HTTP功能模块,都可以在configure的时候,通过 --with-http_XXXX_module=shared 的形式编译为动态加载模块,如果不指定=shared 则会被静态编译到Tengine的核心中,安装动态加载模块用 make dso_install 命令

    1.3、http_concat_module模块官方文档:http://tengine.taobao.org/document_cn/http_concat_cn.html

    2、安装

    2.1、切换至tengine源码目录,没有的话下载对应版本并解压

    [root@localhost ~]# cd /soft/tengine-2.1.2
    [root@localhost ~]# ./configure --sbin-path=/usr/local/nginx --with-pcre=/soft/pcre-8.36 --with-http_concat_module=shared
    [root@localhost ~]# make dso_install
    

    2.2、安装完后,ngx_http_concat_module.so文件将会生成到/usr/local/nginx/modules/目录下

    3、修改nginx.conf配置文件并启用concat模块
    3.1、修改nginx.conf文件:vim /usr/local/nginx/nginx.conf

    3.2、添加如下代码,让Tengine启动时动态加载刚刚编译的ngx_http_concat_module.so

    dso {
        #可以指定模块路径 
        #path /usr/local/nginx/modules/
        load ngx_http_concat_module.so;
    }
    

    3.3、开启concat模块:在nginx.conf的location内添加concat on,例如下面:

    server {
        listen       80;
        server_name  www.ydcss.com;
     
        location / {
            concat on; 
            # 还有其他参数请参看官网
            root   /yddata/www/www.ydcss.com;
            index  index.php index.html index.htm;
        }
     
        location ~ .php$ {
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME  /yddata/www/www.ydcss.com$fastcgi_script_name;
            include        fastcgi_params;
        }
    }
    

    3.4、保存配置并重启nginx

    4、编写测试文件,具体内容自己定
    4.1、新建js/css/html什么的,都能加载出来就对了

    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8" />
        <title>Document</title>
    </head>
    <body>
        <script src="js/??test1.js,test2.js"></script>
    </body>
    </html>
    

    5、本人基础较差,遇到下面的问题
    5.1、已经生成了ngx_http_concat_module.so文件,编译时却提示

    [emerg] load module "/usr/local/nginx/modules/ngx_http_concat_module.so"; failed(然后提示找不到文件什么的)

    5.2、解决办法:

    5.2.1、查看ngx_http_concat_module.so包含动态函式库,发现libpcre.so这个鬼东西没有,如下图:


    image.png

    5.3、重新编译,编译时带上--with-pcre=/soft/pcre-8.36就可以了

    6、结束语
    6.1、本文有任何错误,或有任何疑问,欢迎留言说明。

    转自:http://www.ydcss.com/archives/666

    相关文章

      网友评论

          本文标题:Nginx动态加载模块

          本文链接:https://www.haomeiwen.com/subject/ufwziftx.html