nginx+php(5.4.14)安裝、配置詳解(負載平衡)

來源:互聯網
上載者:User
文章目錄
  • 3.1php的安裝與配置

這裡僅提供簡單的配置樣本,關於比較詳細的設定檔的資訊,以後再做交流

實驗環境:

系統:centos6.2  linux 2.6核心

php version: 5.4.14 (當前最新)

nginx version : 1.3.16 (當前最新)

1.配置框圖

配置的架構圖如下:

可以看到有三台機器

串連代理:192.168.66.20  其它兩台為後台伺服器,IP與監聽連接埠上面已標明

2.代理的安裝與配置

nginx 的安裝比較簡單了,詳細內容請參照:http://blog.csdn.net/rao_warrior/article/details/8948063

對nginx的配置如下:

下面的設定檔中,為了理解方便,我把部分暫時不需要的東西都給刪掉了

#user  nobody; 
worker_processes  1;

#error_log  logs/error.log;
#error_log  logs/error.log  notice; 
#error_log  logs/error.log  info;

#pid        logs/nginx.pid;

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;

    #gzip  on;

    upstream myproject {
        server 192.168.66.11:9000 ;
        server 192.168.66.10:9000 ;
    }
   server {
        listen       80;
        server_name  192.168.66.20;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location / {
            root   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   html;
        }

        # proxy the PHP scripts to Apache listening on 127.0.0.1:80
        #
        #location ~ \.php$ {
        #    proxy_pass   http://192.168.66.20;
        #
        #}

        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
        #
        location ~ \.php$ {
            root           html;
            fastcgi_pass   myproject ;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME  /home/php/$fastcgi_script_name;  #指定後台server的php網站存放的目錄
            include        fastcgi_params;
        }
    }
}

3.後台server的安裝配置3.1php的安裝與配置

詳細安裝資訊,請參考:http://blog.csdn.net/rao_warrior/article/details/8948063

配置/usr/local/etc/php-fpm.conf檔案如下:

找到  listen = 127.0.0.1:9000 這一行,改成:

listen = 192.168.66.10:9000   #以server 192.168.66.10為例

啟動php-fpm 就OK

聯繫我們

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