CentOS 7 yum安装nginx-1.12.0

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


图1
nginx


 

图2web

一、按图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_64centos


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

图3测试

图4ui

三、能够使用两种方法启动nginx服务
[root@lnboxue ~]# service nginx start

[root@lnboxue ~]# systemctl start nginx
this


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

图5spa

五、查看nginx版本

[root@lnboxue ~]# nginx -v

nginx version: nginx/1.12.0

 

六、本地测试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

相关文章
相关标签/搜索