CentOS7.0安裝Nginx


安裝Nginx

yum install nginx

正常情況下必定是:

已加載插件:fastestmirror, langpacks
base                                                            | 3.6 kB  00:00:00     
docker-main                                                     | 2.9 kB  00:00:00     
extras                                                          | 3.4 kB  00:00:00     
updates                                                         | 3.4 kB  00:00:00     
(1/2): extras/7/x86_64/primary_db                               | 122 kB  00:00:00     
(2/2): updates/7/x86_64/primary_db                              | 2.9 MB  00:00:28     
Loading mirror speeds from cached hostfile
 * base: mirrors.163.com
 * extras: mirrors.163.com
 * updates: mirrors.163.com
沒有可用軟件包 nginx。 錯誤:無須任何處理

遂百度查找,CentOS7系統庫中默認是沒有Nginx的rpm包的,所以我們自己需要先更新下rpm依賴庫。。。

#rpm -Uvh http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm

還是去Nginx官網看了下官方的說法,點擊這里(Install|NGINX)。

a、先創建一個yum的一個repository文件:/etc/yum.repos.d/nginx.repo;

b、然后將下面配置黏貼進文件后保存。

[nginx]
name=nginx repo
baseurl=http://nginx.org/packages/centos/$releasever/$basearch/
gpgcheck=0
enabled=1

接下來基本上就順了。

(1)安裝Nginx

#yum install nginx

(2)啟動Nginx

#service nginx start

或

#systemctl start nginx.service

測試一下是否正常。

curl http://127.0.0.1
<!DOCTYPE html>
<html>
<head>
<title>Welcome to nginx!</title>
<style>
    body {
        width: 35em;
        margin: 0 auto;
        font-family: Tahoma, Verdana, Arial, sans-serif;
    }
</style>
</head>
<body>
<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>

  

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM