需要軟件信息:
nginx
php
RunHiddenConsole
首先安裝之前要規划一下把他們放到那里,比如我將他們統一放在e :/web下
那么將這些都拷貝過來,開始吧,window要執行php-cgi.exe, nginx等,都要配置環境變量,將nginx和php的目錄加到里面就好了

php.ini的配置信息我就不說明了
就說nginx配置吧
nginx.conf
#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;
sendfile on;
keepalive_timeout 65;
#gzip on;
include vhost/*.conf; #加載vhost目錄下的虛擬主機配置文件,這里主要用於配置虛擬主機
}
然后在conf目錄下新建虛擬主機(可以配置很多)
server {
listen 8888;
server_name localhost;
location / {
root e:/web/nginx/local; #網站文件路徑
index index.php;
if ( !-f $request_filename ) {
rewrite ^/(.*)$ /index.php last;#rewrite
}
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
location ~ \.php$ {
root e:/web/nginx/local;#這個目錄自己定
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
然后在命令控制台執行
e:/web/php/php-cgi.exe -b 127.0.0.1:9000 -c e:/web/php/php.ini
開啟php監聽
e:/web/nginx/nginx.exe -p e:/web/nginx
打開nginx
然后在html目錄下新加index.php,寫代碼查看就好了
由於默認啟動php-cgi,控制台不隱藏,所以RunHiddenConsole搞定就好
單獨寫一個bat處理文件
@echo off echo Starting PHP FastCGI... RunHiddenConsole e:/web/php/php-cgi.exe -b 127.0.0.1:9000 -c e:/web/php/php.ini echo Starting nginx... RunHiddenConsole e:/web/nginx/nginx.exe -p e:/web/nginx
再寫一個stop的bat
@echo off echo Stopping nginx... taskkill /F /IM nginx.exe > nul echo Stopping PHP FastCGI... taskkill /F /IM php-cgi.exe > nul exit
就然后執行一下ok
