CentOS 7 yum安装nginx-1.12.0

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服务已安装成功!
  • 1
    点赞
  • 19
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值