nginx單機負載平衡測試組態檔案 mac os x

來源:互聯網
上載者:User

馬上要做個連網的東東,需要nginx做伺服器。這樣負載平衡啊啥的就不用管啦


#user  nobody;worker_processes  1;error_log  /Users/lingyun/www/log/error.log;events {    worker_connections  1024;}http {    include       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  logs/access.log  main;    sendfile        on;    #tcp_nopush     on;    #keepalive_timeout  0;    keepalive_timeout  65;#upstream設定。預設監聽80連接埠,提供給用戶端的地址也是這個upstream myproject{server 127.0.0.1:8000;server 127.0.0.1:8001;}server{listen 80;server_name localhost;location / {proxy_pass http://myproject;}}    #真正的web伺服器配置。簡單起見,這裡兩個web伺服器配置的路徑是一致的,除了連接埠。這些地址不需要開放給用戶端       server {        listen       8000;        server_name  localhost;location / {            root   /Users/lingyun/www/ko32example/site;            index  index.html index.htm;        } location ~ \.php$ {            root           /Users/lingyun/www/farm/public;            fastcgi_pass   127.0.0.1:9000;            fastcgi_index  index.php;            fastcgi_param  SCRIPT_FILENAME  /Users/lingyun/www/farm/public$fastcgi_script_name;            include        fastcgi_params;        }    }    server {        listen       8001;        server_name  localhost;location / {            root   /Users/lingyun/www/ko32example/site;            index  index.html index.htm;        } location ~ \.php$ {            root           /Users/lingyun/www/farm/public;            fastcgi_pass   127.0.0.1:9000;            fastcgi_index  index.php;            fastcgi_param  SCRIPT_FILENAME  /Users/lingyun/www/farm/public$fastcgi_script_name;            include        fastcgi_params;        }    }}

後面在多台機器啟動web伺服器的時候,修改下這個配置就行了(還沒測試)。現在先在單機上跑通流程就行啦。

環境安裝相關的google百度下就行:)

瀏覽器驗證

http://localhost/test.php

http://localhost:8000/test.php

http://localhost:8001/test.php

都能返回phpinfo()的內容

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.