• Nginx基础篇-Nginx的编译参数


    Nginx基础篇-Nginx的编译参数

    基础配置

    configure arguments: ----配置参数./configure --help查询帮助
    --prefix=/etc/nginx---- 安装路径
    --sbin-path=/usr/sbin/nginx----程序文件
    --modules-path=/usr/lib64/nginx/modules----模块路径
    --conf-path=/etc/nginx/nginx.conf----主配置文件
    --error-log-path=/var/log/nginx/error.log---错误日志
    --http-log-path=/var/log/nginx/access.log----访问日志
    --pid-path=/var/run/nginx.pid----程序ID
    --lock-path=/var/run/nginx.lock----锁路径,防止重复启动nginx
    --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----php缓存
    --http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp----python缓存 
    --http-scgi-temp-path=/var/cache/nginx/scgi_temp 
    --with-compat ----启用动态模块兼容性
    --user=nginx ----用户
    --group=nginx ----组
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17

    模块类

    –with-file-aio
    1.使用nginx的aio特性会大大提高性能,比如图片站的特点是大量的读io操作,nginx aio不用等待每次io的结果,有助于并发处理大量io和提高nginx处理效率。
    2.aio的优点就是能够同时提交多个io请求给内核,然后直接由内核的io调度算法去处理这些请求(directio),这样的话,内核就有可能执行一些合并,节约了读取文件的处理时间。
    3.就是异步非阻塞
    –with-threads
    多线程模块
    –with-http_addition_module
    1.响应之前或者之后追加文本内容,比如想在站点底部追加一个js广告或者新增的css样式
    2.示例

    nginx配置addition
    配置nginx.conf
    server {
        listen       80;
        server_name  www.ttlsa.com;
    
        root /data/site/www.ttlsa.com;    
    
        location / {
            add_before_body /2013/10/header.html;
            add_after_body  /2013/10/footer.html;
        }
    }
     测试
    以下三个文件,对应请求的主体文件和add_before_body、add_after_body对应的内容
    # cat /data/site/test.ttlsa.com/2013/10/20131001_add.html 
    <html>
    <head>
    <title>I am titletitle>
    head>
    <body>
    ngx_http_addition_module
    body>
    html>
    
    # cat /data/site/test.ttlsa.com/2013/10/header.html 
    I am header!
    
    # cat /data/site/test.ttlsa.com/2013/10/footer.html 
    footer - ttlsa
    
    访问结果如下,可以看到20131001_add.html的顶部和底部分别嵌入了子请求header.html和footer的内容。
    # curl test.ttlsa.com/2013/10/20131001_add.html           
    I am header!
    <html>
    <head>
    <title>I am titletitle>
    head>
    <body>
    ngx_http_addition_module
    body>
    html>
    footer - ttlsa
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43

    –with-http_auth_request_module
    认证模块
    –with-http_dav_module
    增加上传PUT,DELETE,MKCOL:创建集合,COPY和MOVE方法)默认情况下为关闭
    –with-http_flv_module
    NGINX 添加MP4、FLV视频支持模块
    –with-http_gunzip_module
    压缩模块
    –with-http_gzip_static_module
    –with-http_mp4_module
    多媒体模块
    –with-http_random_index_module
    nginx显示随机首页模块
    –with-http_realip_module
    Nginx获取真实IP模块
    –with-http_secure_link_module
    nginx安全下载模块
    –with-http_slice_module
    nginx中文文档
    –with-http_ssl_module
    安全模块
    –with-http_stub_status_module
    访问状态
    –with-http_sub_module
    nginx替换网站响应内容
    –with-http_v2_module
    –with-mail
    邮件客户端
    –with-mail_ssl_module
    –with-stream
    负载均衡模块。nginx从1.9.0开始,新增加了一个stream模块,用来实现四层协议的转发、代理或者负载均衡等。
    –with-stream_realip_module
    –with-stream_ssl_module
    –with-stream_ssl_preread_module

    CPU优化参数

    –with-cc-opt=‘-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong –
    param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -fPIC’
    –with-ld-opt=‘-Wl,-z,relro -Wl,-z,now -pie’

  • 相关阅读:
    双软认证的政策解读、好处及申报指南
    首个集成AI的国产操作系统带来了哪些惊喜
    Jackson 的各种使用
    html 列表标签的学习,表单标签的学习
    面试想吊打面试官?阿里架构师教你吃透Spring(Boot、Cloud、MVC)
    塑料透光率测试可测试塑料部件的透明度和纯度
    【英语语法】but
    python diffusers StableDiffusionXLPipeline 离线使用
    解锁安卓开发利器:深度探析ADB【安卓开发】
    GCC优化相关
  • 原文地址:https://blog.csdn.net/yyf0430/article/details/126159331