zoukankan      html  css  js  c++  java
  • [nginx] 从源码编译安装NGINX

    nginx通过rpm包进行的安装和配置:

    [web][nginx] 初识nginx -- 使用nginx搭建https DPI解码测试环境

    现在,要通过源码进行安装。

    参考:https://nginx.org/en/docs/configure.html

    1. 下载PCRE-8.41   https://ftp.pcre.org/pub/pcre/ 并解压。

    2.  安装 zlib

    yum install zlib-devel

    3.  configure

    root@D128 ~/S/nginx-1.13.9# ./configure --prefix=/root/BUILD --with-pcre=/root/Src/pcre-8.41/
    root@D128 ~/S/nginx-1.13.9# make

    4.  安装

    root@D128 ~/S/nginx-1.13.9# make install

    安装完了,在这里

    root@D128 ~/BUILD# ls
    client_body_temp/  conf/  fastcgi_temp/  html/  logs/  proxy_temp/  sbin/  scgi_temp/  uwsgi_temp/

    5. 启动,

    执行这个程序,就会用默认配置启动了。

    /root/BUILD/sbin/nginx 

    但是,关掉iptables,selinux之后,依然报错

    2018/03/21 14:50:31 [error] 1146#0: *4 "/root/BUILD/html/index.html" is forbidden (13: Permission denied), client: 127.0.0.1, server: localhost, request: "GET / HTTP/1.1", host: "127.0.0.1"
    2018/03/21 14:52:24 [error] 1146#0: *5 "/root/BUILD/html/index.html" is forbidden (13: Permission denied), client: 127.0.0.1, server: localhost, request: "GET / HTTP/1.1", host: "127.0.0.1"

    原来是因为我放在了 /root/目录下,root的目录权限导致了这个问题。

    root@D128 /# chmod 755 root/

    6 GDB

    默认编译文件objs/Makefile就是-g的,所以默认就能gdb

    https://www.ibm.com/developerworks/cn/linux/l-cn-gdbmp/

    (gdb) set follow-fork-mode child

    在fork后的子进程中设置断点:

    (gdb) b ngx_daemon.c:23
    Breakpoint 2 at 0x42f014: file src/os/unix/ngx_daemon.c, line 23.

    nginx的进程启动大流程: (配置文件的初始化在第一次fork之前进行。)

     

    7. loction


    http://nginx.org/en/docs/http/ngx_http_core_module.html#location

    今天重点研究的侧重点是location与pcre的问题,用来提升7层LB的性能。

    现在,要搞清楚下面两个函数的调用契机和逻辑

    ngx_http_core_find_config_phase

        ngx_http_core_find_location 调用了 PCRE (ngx_http_regex_exec -> pcre_exec)

    ngx_http_core_location

        ngx_http_core_regex_location 调用了PCRE (ngx_http_regex_compile)

    从如下代码中可以发现,该ngx_http_core_location函数用于做location关键字的配置

    src/http/ngx_http_core_module.c: line 273

     273     { ngx_string("location"),                                                                                 
     274       NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_BLOCK|NGX_CONF_TAKE12,       
     275       ngx_http_core_location,                                                   
     276       NGX_HTTP_SRV_CONF_OFFSET,                                                 
     277       0,                                                                                                                                                                                                    
     278       NULL },     
  • 相关阅读:
    matlab中绘制折线图、绘制条形图(柱形图)的简单方法
    2.序列类型方法
    年度KPI绩效面谈记录
    软件开发工作杂谈——更杂版
    软件研发工作杂谈
    FFI Navigtor在Windows环境下的"No Such File or Directory"Bug解决过程
    Linux环境部署帆软报表(FineReport)说明
    IIS负载均衡Application Request Route 安装配置说明(ARR)
    python使用了resetKeyboard输入法打不开怎么办
    python 执行时报错AttributeError: 'dict' object has no attribute 'has_key'
  • 原文地址:https://www.cnblogs.com/hugetong/p/8617759.html
Copyright © 2011-2022 走看看