CentOS 7 中的 yum 没法直接使用 yum install nginx 这个指令去安装nginx,因为nginx这个服务不是yum库中自带的。图1是官方提供的大致安装步骤,图2是官网提供的多个版本的nginx安装包,下面是我给合自己的系统环境总结的安装方法,供大家参考:

图1

图2

1、按图1中的要求vi nginx.repo这个文件,将图中[nginx]字段中的内容复制进去,保存退出!
[root@lnboxue ~]# vi  /etc/yum.repos.d/nginx.repo
[nginx]
name=nginx repo
baseurl=http://nginx.org/packages/centos/7/x86_64/
gpgcheck=0
enabled=1
这里需要注意的是:要将$releasever替换为7,将$basearch替换成x86_64。可以通过下面这条指令获取你自己系统的$releasever和$basearch。
[root@lnboxue ~]# rpm -qa | grep centos-release
centos-release-7-3.1611.el7.centos.x86_64

2、yum安装nginx,参见图3和图4。
[root@lnboxue ~]# yum install nginx

图3

图4

3、可以使用两种方法启动nginx服务
[root@lnboxue ~]# service nginx start

[root@lnboxue ~]# systemctl start nginx

4、查看nginx服务是否已经启动
[root@lnboxue ~]# netstat -ntl

图5

5、查看nginx版本

[root@lnboxue ~]# nginx -v

nginx version: nginx/1.12.0

6、本地测试nginx服务
[root@lnboxue ~]# curl -i localhost
HTTP/1.1 200 OK
Server: nginx/1.12.0
Date: Tue, 04 Jul 2017 05:27:07 GMT
Content-Type: text/html
Content-Length: 612
Last-Modified: Wed, 12 Apr 2017 15:23:46 GMT
…………
…………
<h1>Welcome to nginx!</h1>
<p>If you see this page, the nginx web server is successfully installed and
working. Further configuration is required.</p>
<p>For online documentation and support please refer to
<a href="http://nginx.org/">nginx.org</a>.<br/>
Commercial support is available at
<a href="http://nginx.com/">nginx.com</a>.</p>
<p><em>Thank you for using nginx.</em></p>
</body>

</html>

看到以上信息,说明你的nginx服务已安装成功!

来源:http://blog.csdn.net/lnboxue/article/details/74783885

CentOS 7 yum安装nginx-1.12.0的更多相关文章

  1. centos 下yum 安装nginx

    centos 下yum 安装nginx 1. 直接yum install nginx不行,要先处理下源: rpm -ivh http://nginx.org/packages/centos/6/noa ...

  2. Centos下yum安装Nginx报错 No package nginx available.

    在Centos6下使用yum安装Nginx报错 解决方案: yum install epel-release

  3. centos直接yum安装nginx

    Ubuntu下安装nginx,直接apt-get install nginx就行了,很方便. 但是今天装了CentOS6.2,直接yum install nginx不行,要先处理下源,下面是安装完整流 ...

  4. 服务器 CentOS上yum安装Nginx服务

    一.更改yum源为网易的源加快速度 vi /etc/yum.repos.d/CentOS-Base.repo 更改内容如下 # CentOS-Base.repo # # This file uses ...

  5. CentOS 7.4安装Nginx 1.14.0

    一.安装所需环境   1.gcc 安装         yum install gcc-c++    

  6. CentOS上yum安装Nginx服务

    一.更改yum源为网易的源加快速度 vi /etc/yum.repos.d/CentOS-Base.repo更改内容如下 # CentOS-Base.repo # # This file uses a ...

  7. CentOS 7 yum 安装 Nginx

    1.添加Nginx到YUM源 添加CentOS 7 Nginx yum资源库,打开终端,使用以下命令: sudo rpm -Uvh http://nginx.org/packages/centos/7 ...

  8. CentOs 7 yum 安装Nginx

    打开官网下载文档:http://nginx.org/en/download.html 2进入操作系统 centOs 7,建立文件夹 nginx ,进入nginx ,拷贝 上图1编辑命令:/etc/yu ...

  9. centos 下 yum 安装 nginx 平滑切换安装到 Tengine

    ---恢复内容开始--- 据说淘宝的Tengine很牛X,所以我们今天也来玩玩,我们这里是某开放云的vps,现在已经安装好了nginx,现在我们要平滑切换到安装Tengine. 下载Tengine,解 ...

随机推荐

  1. 上海MVP见面会

    很愉快,很有收获的一次见面!

  2. mysql源码版安装

    mysql源码版安装 创建配置文件 创建 my.ini,注意修改,如下的 设置mysql的安装目录和设置mysql数据库的数据的存放目录,设置自己本机的上的对应路径 [mysql] # 设置mysql ...

  3. Ubuntu系统建立交叉编译环境

    飞凌 FET6818核心板 解压编译器: tar zxvf arm-cortex_a9_eabi-4.7-eglibc-2.18.tar.gz  -C/opt 设置默认编译环境: vi /etc/pr ...

  4. unity中编辑器直接截屏代码

    using UnityEngine; using System.Collections; using System.Windows.Forms; public class screenshots : ...

  5. python之路-----python操作 mysql

    ========================pymysql============================ 一.pymysql 基础 安装命令:pip3 install pymysql - ...

  6. 2072. Kirill the Gardener 3

    http://acm.timus.ru/problem.aspx?space=1&num=2072 回忆一下 #include <iostream> #include <st ...

  7. winfrom程序Datagridview列名问题

    之前在做程序的时候,有遇到过这个问题: 无法将类型“string”隐式转换为“System.Windows.Forms.DataGridViewTextBoxColume"解决方法 解决办法 ...

  8. pip 在win10下安装

    http://blog.csdn.net/yupu56/article/details/50470970C:\Users\sunof\AppData\Local\Programs\Python\Pyt ...

  9. java代码生成json数据

    https://www.cnblogs.com/libo0125ok/p/7905665.html

  10. 以太坊Bootstrap和Kademlia算法实现逻辑简介(基于cpp-ethereum)