馬上要做個連網的東東,需要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()的內容