美文网首页
nginx yum 安装 for CentOS

nginx yum 安装 for CentOS

作者: C86guli | 来源:发表于2016-07-03 16:46 被阅读338次

    nginx yum 安装 for CentOS


    编译自:
    http://nginx.org/en/linux_packages.html

    为 RHEL/CentOS 设置 yum 仓库,使 Linux 可自动升级 nginx。

    预编译的“stable”版程序包


    创建 /etc/yum.repos.d/nginx.repo 文件,内容如下:

    [nginx]
    name=nginx repo
    baseurl=http://nginx.org/packages/OS/OSRELEASE/$basearch/gpgcheck=0
    enabled=1
    

    根据自己的Linux发行版,将 “OS” 替换为 “rhel” 或者 “centos”,
    根据 5.x, 6.x, 7,x 版本,将 “OSRELEASE” 替换为 “5”, “6”, or “7”。

    比如 CentOS:

    [nginx]
    name=nginx repo
    baseurl=http://nginx.org/packages/centos/$releasever/$basearch/
    gpgcheck=0
    enabled=1
    

    预编译的“mainline”版程序包


    创建 /etc/yum.repos.d/nginx.repo 文件,内容如下:

    [nginx]
    name=nginx repo
    baseurl=http://nginx.org/packages/mainline/OS/OSRELEASE/$basearch/
    gpgcheck=0
    enabled=1
    

    根据自己的Linux发行版,将 “OS” 替换为 “rhel” 或者 “centos”,
    根据 5.x, 6.x, 7,x 版本,将 “OSRELEASE” 替换为 “5”, “6”, or “7”。

    比如 CentOS:

    [nginx]
    name=nginx repo
    baseurl=http://nginx.org/packages/mainline/centos/$releasever/$basearch/
    gpgcheck=0
    enabled=1
    

    编译配置参数


    预编译程序包的 configure 参数:

    --prefix=/etc/nginx
    --sbin-path=/usr/sbin/nginx
    --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
    --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_realip_module
    --with-http_addition_module
    --with-http_sub_module
    --with-http_dav_module
    --with-http_flv_module
    --with-http_mp4_module
    --with-http_gunzip_module
    --with-http_gzip_static_module
    --with-http_random_index_module
    --with-http_secure_link_module
    --with-http_stub_status_module
    --with-http_auth_request_module
    --with-threads
    --with-stream
    --with-stream_ssl_module
    --with-http_slice_module
    --with-mail
    --with-mail_ssl_module
    --with-file-aio
    --with-http_v2_module
    --with-ipv6
    

    main nginx 程序包编译了不要求额外库依赖的所有模块。

    动态模块


    从 nginx 1.9.11 版开始,nginx 开始支持动态模块。目前编译为独立动态模块的如下:

    nginx-module-geoip
    nginx-module-image-filter
    nginx-module-njs
    nginx-module-perl
    nginx-module-xslt
    

    如何加载动态模块:

    Syntax: load_module file;
    Default:    —
    Context:    main
    This directive appeared in version 1.9.11.
    Loads a dynamic module.
    
    Example:
    
    load_module modules/ngx_mail_module.so;
    

    Signatures 签名


    RPM 程序包使用数字签名来验证下载的程序包的完整性及是否被改动。

    下载 http://nginx.org/keys/nginx_signing.key ,然后:

    sudo rpm --import nginx_signing.key
    

    因为我们的 PGP key 和程序包位于同一个服务器,所以它们都可被信任。

    我们强烈建议验证 PGP key 的可靠性和真实性。

    PGP 有一个 “Web of Trust” 概念,具体可参考:

    GPG Mini HOWTO

    我们的 keys 拥有足够多的签名,它们的可靠性相对来说容易验证。


    版权信息
    本文编译自 nginx.org ,遵循其原来的 licence 声明: 2-clause BSD-like license

    相关文章

      网友评论

          本文标题:nginx yum 安装 for CentOS

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