配置用于fastcgi的php.ini文件,復制一份并命名為php-cli.ini
開啟以下配置:
enable_dl = On
cgi.force_redirect = 0
cgi.fix_pathinfo=1
fastcgi.impersonate = 1
cgi.rfc2616_headers = 1
將nginx解壓至與PHP同目錄
修改conf目錄下nginx.conf
添加如下server:
server {
listen 80;
server_name localhost;
root D:/xampp/htdocs;
location / {
root D:/xampp/htdocs;
index index.php index.html index.htm;
}
location ~ \.php$ {
root D:/xampp/htdocs/;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
使用指定的php.ini文件啟動php
D:\xampp\php\php-cgi.exe -b 127.0.0.1:9000 -c D:\xampp\php\php-cli.ini
使用netstat -a 查看127.0.0.1:9000是否有啟動
在nginx目錄下
start nginx(啟動nginx服務)
這里可以使用RunHiddenConsole.exe(將此軟件放在nginx目錄)將nginx服務作為后臺運行