<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                [TOC] ## apache與nginx的區別 > nginx本身只能處理靜態頁的解析,如果要解析動態頁面的話,需要用到反向代理的功能 > nginx有**反向代理功能**,能做負載均衡。apache沒有 > nginx更輕量級,占用的內存很小。而apache更穩定 > nginx更適合高并發,因為nginx處理請求屬于異步非阻塞的,可以多個連接(萬級別)對應一個進程。而apache 則是阻塞型的,一個連接對應一個進程。 > nginx 處理 靜態資源 性能高于apache,處理 動態語言 性能低于apache,因為nginx處理動態語言經過的層次太多了。 ![](https://box.kancloud.cn/b2c8983a7ef36e3294da56cf03fea8f4_1508x414.png) > **A**. 使用nginx的反向代理將請求轉發到php-fpm -> **B**.fastcgi進程管理器(php-fpm)收到請求后選擇并連接一個cgi解釋器 ## nginx的兩種負載均衡方式 > 輪詢加權(也可以不加權,就是1:1負載)和 > ip_hash(根據ip分配后端服務器,解決session問題) ``` // 輪詢加權 upstream lb { server 192.168.196.130 weight=1; server 192.168.196.132 weight=2; } // ip_hash輪詢 upstream lb { server 192.168.196.130; server 192.168.196.132; ip_hash; } ``` ## 服務器環境假設 > 假設 > 192.168.1.111(主) -> 安裝有LNMP,進行負載均衡控制 > 192.168.1.112(從) -> 安裝有LNMP,進行應用運行 > 192.168.1.113(從) -> 安裝有LNMP,進行應用運行 ## LNMP的安裝 > 每臺服務器都安裝LNMP > 參考:http://www.hmoore.net/wangking/linux/280755 ## 負載均衡配置 ### 主服務器(192.168.1.111)負載均衡配置 > vim /opt/nginx/conf/vhosts/zhuifanba.conf ``` upstream load_balance{ # 設置負載均衡的機器列表(采用輪詢的方式) server 192.168.1.112:80; #從服務器1 server 192.168.1.113:80; #從服務器2 } server { listen 80; server_name www.zhuifanba.com; location / { #設置反向代理 proxy_pass http://load_balance; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; } location ~ .*\.(php|php5)?$ { #設置反向代理 proxy_pass http://load_balance; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; } location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$ { # 設置靜態文件的反向代理 proxy_pass http://load_balance; expires 30d; } location ~ .*\.(js|css)?$ { # 設置靜態文件的反向代理 proxy_pass http://load_balance; expires 1h; } } ``` ### 從服務器(192.168.1.112~113)運行環境配置 > vim /opt/nginx/conf/vhosts/zhuifanba.conf ``` server { listen 80; server_name www.zhuifanba.com; index index.html index.htm index.php; root /var/www/zhuifanba/frontend/web; location / { if (!-e $request_filename){ rewrite ^/(.*) /index.php last; } } location ~ .*\.(php|php5)?$ { fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME /var/www/zhuifanba/frontend/web$fastcgi_script_name; include fastcgi.conf; } location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$ { expires 30d; } location ~ .*\.(js|css)?$ { expires 1h; } error_log /var/log/zhuifanba.error.log; access_log /var/log/zhuifanba.access.log; } ```
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看