1. Nginx+PHP安裝
-
下載 Nginx,安裝到指定目錄,如D:\nginx-1.7.5。
-
下載 PHP,安裝到指定目錄,如D:\php。註:window環境下的PHP二進位包括安全執行緒版本和非安全執行緒版本,選擇相應的版本安裝後獨立安裝的擴充包需要和其保持一致。
2. 環境配置
1).Nginx配置:
# nginx.confserver { listen 80; server_name localhost; access_log logs/localhost.access.log; location / { root D:/localhost/trunk; index index.html index.htm index.php; } error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } location ~ \.php$ { root D:/localhost/trunk; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; }}
2).配置本地Host
127.0.0.1 localhost
3.啟動/停用服務指令碼
#start_service.bat@echo offREM 每個進程處理的最大請求數,或設定為 Windows 環境變數set PHP_FCGI_MAX_REQUESTS=1000echo Starting PHP FastCGI...RunHiddenConsole D:/php/php-cgi.exe -b 127.0.0.1:9000 -c D:/php/php.ini echo Starting nginx...RunHiddenConsole D:/nginx-1.7.5/nginx.exe -p D:/nginx-1.7.5
#stop_service.bat@echo offecho Stopping nginx...taskkill /F /IM nginx.exe > nulecho Stopping PHP FastCGI...taskkill /F /IM php-cgi.exe > nulexit
最後,雙擊start_service.bat啟動相應服務。
4.訪問localhost/index.php即可看到首頁