美文网首页
安装 Nginx 最新版本(1.13.9+) 到 EC2 上,并

安装 Nginx 最新版本(1.13.9+) 到 EC2 上,并

作者: 守望_小方_顺方弟兄 | 来源:发表于2018-03-13 13:48 被阅读0次

    Preface

    From Nginx v1.13.9, we gain HTTP2/Server Push eventually.

    Here is the doc for you to install it, via yum.

    Steps

    Add repo and yum update

    sudo vim /etc/yum.repos.d/nginx.repo
    

    Add followed:

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

    Allow extra duplicated packages besides Amazon AMI Linux repo

    sudo vim /etc/yum/pluginconf.d/priorities.conf 
    
    [main]
    enabled = 0
    

    Yum Update

    # update
    sudo yum update
    

    Show duplicated repo candidates and install it

    repoquery --show-duplicates nginx
    

    Terminal Output:

    nginx-0:1.13.6-1.el6.ngx.x86_64
    nginx-0:1.13.7-1.el6.ngx.x86_64
    nginx-0:1.13.8-1.el6.ngx.x86_64
    nginx-0:1.13.9-1.el6.ngx.x86_64
    nginx-1:1.12.1-1.33.amzn1.x86_64

    Select latest and install it

    # assume nginx-0:1.13.9-1.el6.ngx.x86_64 is the latest
    sudo yum remove nginx
    sudo yum install --setopt=obsoletes=0  -y nginx-0:1.13.9-1.el6.ngx.x86_64
    

    Change Nginx config

    sudo vim /etc/nginx/conf.d/YOUR_CONFIG_FILE
    

    File content

    server {
    
            # listen 443 ssl;
            listen 443 ssl http2;
    
            # SSL configuration
            #
            listen [::]:443 ssl http2;
            # move upload size into server block
            client_max_body_size 50M;
            # ...
            }
    
            root /PATH_TO_YOUR_DOC_ROOT;
            http2_push_preload on;
    
     location ~ .php$ {
                    #NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
    
                    # Or fastcgi_pass unix:/run/php/php7.0-fpm.sock;
                    fastcgi_pass    unix:/var/run/php-fpm/php-fpm.sock;
                    #fastcgi_index   index.php;
    
                    # nginx 1.13 
                    #include fastcgi.conf;
                    include fastcgi_params;
    
                    fastcgi_param   SCRIPT_FILENAME  $document_root/$fastcgi_script_name;
                    fastcgi_intercept_errors on;
                    #fastcgi_pass php;
            }
    

    Restart Nginx and check

    sudo service nginx restart
    nginx -v
    

    Terminal output

    nginx version: nginx/1.13.9

    原文:https://www.xiaofang.me/2018/03/13/yum-install-nginx-latest-build-%EF%BC%881-13-9-in-amazon-ec2-ami-linux-and-enable-http2-server-push-%E5%AE%89%E8%A3%85-nginx-%E6%9C%80%E6%96%B0%E7%89%88%E6%9C%AC%E5%88%B0-ec2-%E4%B8%8A%EF%BC%8C/

    相关文章

      网友评论

          本文标题:安装 Nginx 最新版本(1.13.9+) 到 EC2 上,并

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