[轉]CENTOS 6.5 配置YUM安裝NGINX+伺服器負載平衡

來源:互聯網
上載者:User

標籤:

原文串連: CENTOS 6.5 配置YUM安裝NGINX  http://blog.sina.com.cn/s/blog_69f467b70102uyux.html

 

本文介紹一下如何用yum源安裝Nginx。

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

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

填寫如下內容:

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

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

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

yum install nginx -y

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

/etc/init.d/nginx start

我是用:服務啟動並設定開機啟動

service nginx startchkconfig nginx on --level 35

簡單負載平衡 

公司目前只有兩台伺服器做負載:

我的配置如下:

user  nginx;worker_processes  1;error_log  /var/log/nginx/error.log warn;pid        /var/run/nginx.pid;events {    use epoll;    worker_connections  1024;}http {    include       /etc/nginx/mime.types;    default_type  application/octet-stream;    log_format  main  ‘$remote_addr - $remote_user [$time_local] "$request" ‘                      ‘$status $body_bytes_sent "$http_referer" ‘                      ‘"$http_user_agent" "$http_x_forwarded_for"‘;    access_log  /var/log/nginx/access.log  main;    sendfile        on;    #tcp_nopush     on;    keepalive_timeout  65;    #gzip  on;    include /etc/nginx/conf.d/*.conf;    #設定負載平衡的伺服器列表    upstream myServer {      #weigth參數表示權值,權值越高被分配到的幾率越大      #本機上的apache開8080連接埠      server 本機ip:8080 weight=5;      server  webserver2  weight=5;    }    server {      listen 80;      server_name 本機ip;      location / {      proxy_pass http://myServer;      proxy_set_header Host $host;      proxy_set_header X-Real-IP $remote_addr;      proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;      }    }}

大功告成!只是這樣資料庫訪問會不會成為瓶頸?以後再解!

 

[轉]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.