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

相關文章
相關標籤/搜索