久久久久久久视色,久久电影免费精品,中文亚洲欧美乱码在线观看,在线免费播放AV片

<center id="vfaef"><input id="vfaef"><table id="vfaef"></table></input></center>

    <p id="vfaef"><kbd id="vfaef"></kbd></p>

    
    
    <pre id="vfaef"><u id="vfaef"></u></pre>

      <thead id="vfaef"><input id="vfaef"></input></thead>

    1. 站長(zhǎng)資訊網(wǎng)
      最全最豐富的資訊網(wǎng)站

      淺談PHP-FPM、Nginx和FastCGI間的關(guān)系

      本篇文章給大家聊聊PHP-FPM、Nginx、FastCGI三者之間的關(guān)系,以及 Nginx 反向代理和負(fù)載均衡的配置。有一定的參考價(jià)值,有需要的朋友可以參考一下,希望對(duì)大家有所幫助。

      淺談PHP-FPM、Nginx和FastCGI間的關(guān)系

      PHP-FPM,Nginx,FastCGI 之間的關(guān)系

      FastCGI 是一個(gè)協(xié)議,它是應(yīng)用程序和 WEB 服務(wù)器連接的橋梁。Nginx 并不能直接與 PHP-FPM 通信,而是將請(qǐng)求通過 FastCGI 交給 PHP-FPM 處理。

      location ~ .php$ {     try_files $uri /index.php =404;     fastcgi_pass 127.0.0.1:9000;     fastcgi_index index.php;     fastcgi_buffers 16 16k;     fastcgi_buffer_size 32k;     fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;     include fastcgi_params; }

      這里 fastcgi_pass 就是把所有 php 請(qǐng)求轉(zhuǎn)發(fā)給 php-fpm 進(jìn)行處理。通過 netstat 命令可以看到,127.0.0.1:9000 這個(gè)端口上運(yùn)行的進(jìn)程就是 php-fpm.

      淺談PHP-FPM、Nginx和FastCGI間的關(guān)系

      Nginx 反向代理

      Nginx 反向代理最重要的指令是 proxy_pass,如:

      location ^~ /seckill_query/ {     proxy_pass http://ris.filemail.gdrive:8090/;     proxy_set_header Host ris.filemail.gdrive; }  location ^~ /push_message/ {     proxy_pass http://channel.filemail.gdrive:8090/;     proxy_set_header Host channel.filemail.gdrive; }  location ^~ /data/ {     proxy_pass http://ds.filemail.gdrive:8087/;     proxy_set_header Host ds.filemail.gdrive; }

      通過 location 匹配 url 路徑,將其轉(zhuǎn)發(fā)到另外一個(gè)服務(wù)器處理。

      通過負(fù)載均衡 upstream 也可以實(shí)現(xiàn)反向代理。

      Nginx 負(fù)載均衡

      介紹一下 upstream 模塊:

      負(fù)載均衡模塊用于從”upstream”指令定義的后端主機(jī)列表中選取一臺(tái)主機(jī)。nginx先使用負(fù)載均衡模塊找到一臺(tái)主機(jī),再使用upstream模塊實(shí)現(xiàn)與這臺(tái)主機(jī)的交互。

      負(fù)載均衡配置:

      upstream php-upstream {     ip_hash;      server 192.168.0.1;     server 192.168.0.2; }  location / {     root   html;     index  index.html index.htm;     proxy_pass http://php-upstream; }

      該例定義了一個(gè) php-upstream 的負(fù)載均衡配置,通過 proxy_pass 反向代理指令應(yīng)用這個(gè)配置。這里用的 ip_hash 算法,負(fù)載均衡的算法有多種,就不一一列舉了。

      負(fù)載均衡也可以用在 fastcgi_pass 上。

      如:

      fastcgi_pass http://php-upstream

      問題

      反向代理和負(fù)載均衡是什么關(guān)系

      反向代理和負(fù)載均衡這兩個(gè)詞經(jīng)常出現(xiàn)在一起,但他們實(shí)際上是不同的概念,負(fù)載均衡它

      贊(0)
      分享到: 更多 (0)
      網(wǎng)站地圖   滬ICP備18035694號(hào)-2    滬公網(wǎng)安備31011702889846號(hào)