由於一直用Apache做爲服務器,對Apache的使用和配置已經相對熟悉,今天換了一下nginx的服務器,整個配置流程相對比較簡單,php的配置沒有任何變化。php
主要的參考文檔爲nginx
http://blog.csdn.net/zjiang1994/article/details/72878374windows
這個介紹的十分的詳細,幾乎照着操做就不會用問題,可是在windows環境下配置批處理時出現幾個問題。服務器
因爲域名比較多,php-cgi的進程也相對多開了幾個。.net
代碼以下:blog
REM REM是bat文件的註釋相似於php的// REM 設置不輸出命令 @ECHO off REM 設置Nginx和php-cgi的目錄 SET php_home=D:/WorkSpace/lnmp/php/ SET nginx_home=D:/WorkSpace/lnmp/nginx-1.13.6/ REM 輸出狀態 ECHO Starting PHP FastCGI... REM 啓動php-cgi -b 端口 -c php.ini位置 REM %php_home%爲獲取上面set的php_home的值 REM RunHiddenConsole %php_home%php-cgi.exe -b 127.0.0.1:9000 -c %php_home%php.ini echo %php_home%php-cgi.exe -b 127.0.0.1:9000 -c %php_home%php.ini RunHiddenConsole %php_home%php-cgi.exe -b 127.0.0.1:9000 -c %php_home%php.ini ping -n 1 127.0.0.1 > nul RunHiddenConsole %php_home%php-cgi.exe -b 127.0.0.1:9001 -c %php_home%php.ini ping -n 1 127.0.0.1 > nul RunHiddenConsole %php_home%php-cgi.exe -b 127.0.0.1:9002 -c %php_home%php.ini ping -n 1 127.0.0.1 > nul RunHiddenConsole %php_home%php-cgi.exe -b 127.0.0.1:9003 -c %php_home%php.ini ping -n 1 127.0.0.1 > nul RunHiddenConsole %php_home%php-cgi.exe -b 127.0.0.1:9004 -c %php_home%php.ini ping -n 1 127.0.0.1 > nul RunHiddenConsole %php_home%php-cgi.exe -b 127.0.0.1:9005 -c %php_home%php.ini ping -n 1 127.0.0.1 > nul RunHiddenConsole %php_home%php-cgi.exe -b 127.0.0.1:9006 -c %php_home%php.ini ping -n 1 127.0.0.1 > nul RunHiddenConsole %php_home%php-cgi.exe -b 127.0.0.1:9007 -c %php_home%php.ini ping -n 1 127.0.0.1 > nul REM 輸出狀態 ECHO Starting nginx... REM 啓動Nginx -p Nginx的根目錄 RunHiddenConsole %nginx_home%nginx.exe -p %nginx_home% pause