文章目錄
這裡僅提供簡單的配置樣本,關於比較詳細的設定檔的資訊,以後再做交流
實驗環境:
系統: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