CENTOS 6.5 配置YUM安裝NGINX

來源:互聯網
上載者:User

標籤:input   enable   伺服器   ble   span   ice   root   cep   ror   

摘要: 本文介紹一下如何用yum源安裝Nginx

第一步,在/etc/yum.repos.d/目錄下建立一個源設定檔nginx.repo:

cd /etc/yum.repos.d/vim nginx.repo

填寫如下內容:

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

儲存,則會產生一個/etc/yum.repos.d/nginx.repo檔案。

下面直接執行如下指令即可自動安裝好Nginx:

yum install nginx -y

安裝完成,下面直接就可以啟動Nginx了:

/etc/init.d/nginx start

現在Nginx已經啟動了,直接存取伺服器就能看到Nginx歡迎頁面了的。

如果還無法訪問,則需配置一下Linux防火牆。

iptables -I INPUT 5 -i eth0 -p tcp --dport 80 -m state --state NEW,ESTABLISHED -j ACCEPTservice iptables saveservice iptables restart

Nginx的命令以及設定檔位置:

/etc/init.d/nginx start # 啟動Nginx服務/etc/init.d/nginx stop # 停止Nginx服務/etc/nginx/nginx.conf # Nginx設定檔位置

至此,Nginx已經全部配置安裝完成。

 Nginx伺服器中的default.conf的設定檔設定,正常情況,nginx.conf 一般設定分流請求的時候才會配置對應的資訊

server {    listen       80;    server_name  boss.mydongjia.com;    #charset koi8-r;    #access_log  /var/log/nginx/log/host.access.log  main;    location / {
     #這裡設定Proxy 伺服器的地址和對應的連接埠和應用程式名稱,其實,就是代理的項目路徑地址 proxy_pass http://127.0.0.1:8080/xxxxxx/; proxy_set_header Host $host; proxy_set_header Remote_Addr $remote_addr; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; root /usr/share/nginx/html; index index.html index.htm; } #error_page 404 /404.html; # redirect server error pages to the static page /50x.html # error_page 500 502 503 504 /50x.html; location = /50x.html { root /usr/share/nginx/html; }}

 

CENTOS 6.5 配置YUM安裝NGINX

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.