安装nginx(centos 7 环境)

安装nginx(centos 7 环境)_第1张图片

1. 添加yum

    Nginx 不在默认的 yum 源中,可以使用 epel 或者官网的 yum 源
    
    sudo rpm -ivh http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm

2. 查看nginx repo 是否已经安装到本机

    yum repolist
    
    Loaded plugins: fastestmirror
    Determining fastest mirrors
    base                                                                                                                                                                                                                   | 3.6 kB  00:00:00
    epel                                                                                                                                                                                                                   | 5.3 kB  00:00:00
    extras                                                                                                                                                                                                                 | 3.4 kB  00:00:00
    nginx                                                                                                                                                                                                                  | 2.9 kB  00:00:00
    updates                                                                                                                                                                                                                | 3.4 kB  00:00:00
    (1/8): epel/x86_64/group_gz                                                                                                                                                                                            |  88 kB  00:00:00
    (2/8): base/7/x86_64/group_gz                                                                                                                                                                                          | 166 kB  00:00:00
    (3/8): epel/x86_64/updateinfo                                                                                                                                                                                          | 975 kB  00:00:00
    (4/8): extras/7/x86_64/primary_db                                                                                                                                                                                      | 204 kB  00:00:00
    (5/8): base/7/x86_64/primary_db                                                                                                                                                                                        | 6.0 MB  00:00:00
    (6/8): updates/7/x86_64/primary_db                                                                                                                                                                                     | 6.4 MB  00:00:00
    (7/8): epel/x86_64/primary_db                                                                                                                                                                                          | 6.7 MB  00:00:00
    (8/8): nginx/x86_64/primary_db                                                                                                                                                                                         |  46 kB  00:00:12
    repo id                                                                                              repo name                                                                                                                          status
    base/7/x86_64                                                                                        CentOS-7                                                                                                                           10,019
    epel/x86_64                                                                                          Extra Packages for Enterprise Linux 7 - x86_64                                                                                     13,235
    extras/7/x86_64                                                                                      CentOS-7                                                                                                                              417
    nginx/x86_64                                                                                         nginx repo                                                                                                                            152
    updates/7/x86_64                                                                                     CentOS-7                                                                                                                            2,089
    repolist: 25,912
    [root@iZ2zeizsw2xjgxwhbbsxchZ ~]#

3. 安装nginx

    yum install nginx
    
    
    
    Loaded plugins: fastestmirror
    Loading mirror speeds from cached hostfile
    Resolving Dependencies
    --> Running transaction check
    ---> Package nginx.x86_64 1:1.16.0-1.el7.ngx will be installed
    --> Finished Dependency Resolution
    
    Dependencies Resolved
    
    ==============================================================================================================================================================================================================================================
     Package                                               Arch                                                   Version                                                             Repository                                             Size
    ==============================================================================================================================================================================================================================================
    Installing:
     nginx                                                 x86_64                                                 1:1.16.0-1.el7.ngx                                                  nginx                                                 766 k
    
    Transaction Summary
    ==============================================================================================================================================================================================================================================
    Install  1 Package
    
    Total download size: 766 k
    Installed size: 2.7 M
    Is this ok [y/d/N]: y
    Downloading packages:
    nginx-1.16.0-1.el7.ngx.x86_64.rpm                                                                                                                                                                                      | 766 kB  00:00:47
    Running transaction check
    Running transaction test
    Transaction test succeeded
    Running transaction
    Warning: RPMDB altered outside of yum.
      Installing : 1:nginx-1.16.0-1.el7.ngx.x86_64                                                                                                                                                                                            1/1
    ----------------------------------------------------------------------
    
    Thanks for using nginx!
    
    Please find the official documentation for nginx here:
    * http://nginx.org/en/docs/
    
    Please subscribe to nginx-announce mailing list to get
    the most important news about nginx:
    * http://nginx.org/en/support.html
    
    Commercial subscriptions for nginx are available on:
    * http://nginx.com/products/
    
    ----------------------------------------------------------------------
      Verifying  : 1:nginx-1.16.0-1.el7.ngx.x86_64                                                                                                                                                                                            1/1
    
    Installed:
      nginx.x86_64 1:1.16.0-1.el7.ngx
    
    Complete!

4. nginx的相关配置

    systemctl enable nginx           开机启动nginx
    
    systemctl start nginx            启动nginx
    
    systemctl restart nginx          重启nginx
    
    systemctl stop nginx             关闭nginx
    
    systemctl reload nginx           重新加载nginx
    
    systemctl status nginx           查看nginx状态

推荐:
服务器最低86元/年

拼团链接: 阿里云点击进入

你可能感兴趣的:(环境安装,nginx,nginx)