美文网首页侠骨留香的专辑
nginx Installation on Linux

nginx Installation on Linux

作者: 侠骨留香 | 来源:发表于2020-01-16 23:02 被阅读0次

    Installation on Linux


    nginx can be installed differently, depending on the operating system.
    For Linux, nginx packages from nginx.org can be used.

    Installation instructions

    Before you install nginx for the first time on a new machine, you need to set up the nginx packages repository. Afterward, you can install and update nginx from the repository.

    RHEL/CentOS

    Install the prerequisites:

    sudo yum install yum-utils
    

    To set up the yum repository, create the file named /etc/yum.repos.d/nginx.repo with the following contents:

    [nginx-stable]
    name=nginx stable repo
    baseurl=http://nginx.org/packages/centos/$releasever/$basearch/
    gpgcheck=1
    enabled=1
    gpgkey=https://nginx.org/keys/nginx_signing.key
    module_hotfixes=true
    
    [nginx-mainline]
    name=nginx mainline repo
    baseurl=http://nginx.org/packages/mainline/centos/$releasever/$basearch/
    gpgcheck=1
    enabled=0
    gpgkey=https://nginx.org/keys/nginx_signing.key
    module_hotfixes=true
    

    By default, the repository for stable nginx packages is used. If you would like to use mainline nginx packages, run the following command:

    sudo yum-config-manager --enable nginx-mainline
    

    To install nginx, run the following command:

    sudo yum install nginx
    

    When prompted to accept the GPG key, verify that the fingerprint matches 573B FD6B 3D8F BC64 1079 A6AB ABF5 BD82 7BD9 BF62, and if so, accept it.

    Ubuntu

    Install the prerequisites:

    sudo apt install curl gnupg2 ca-certificates lsb-release
    

    To set up the apt repository for stable nginx packages, run the following command:

    echo "deb http://nginx.org/packages/ubuntu `lsb_release -cs` nginx" \
        | sudo tee /etc/apt/sources.list.d/nginx.list
    

    If you would like to use mainline nginx packages, run the following command instead:

    echo "deb http://nginx.org/packages/mainline/ubuntu `lsb_release -cs` nginx" \
        | sudo tee /etc/apt/sources.list.d/nginx.list
    

    Next, import an official nginx signing key so apt could verify the packages authenticity:

    curl -fsSL https://nginx.org/keys/nginx_signing.key | sudo apt-key add -
    

    Verify that you now have the proper key:

    sudo apt-key fingerprint ABF5BD827BD9BF62
    

    The output should contain the full fingerprint 573B FD6B 3D8F BC64 1079 A6AB ABF5 BD82 7BD9 BF62 as follows:

    pub   rsa2048 2011-08-19 [SC] [expires: 2024-06-14]
          573B FD6B 3D8F BC64 1079  A6AB ABF5 BD82 7BD9 BF62
    uid   [ unknown] nginx signing key <signing-key@nginx.com>
    

    To install nginx, run the following commands:

    sudo apt update
    sudo apt install nginx
    

    关于本文

    参考资料

    1. http://nginx.org/en/linux_packages.html

    相关文章

      网友评论

        本文标题:nginx Installation on Linux

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