日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > php >内容正文

php

nginx php 配置 windows_Windows下配置Nginx使之支持PHP

發布時間:2025/3/21 php 35 豆豆
生活随笔 收集整理的這篇文章主要介紹了 nginx php 配置 windows_Windows下配置Nginx使之支持PHP 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

平臺描述:Windows下,使用PHP套件 xampp,因為是測試玩,所以沒在服務器 Linux 環境中配置。

1. 首先,將 nginx.conf 中的 PHP 配置注釋去掉。

# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000

#

#location ~ \.php$ {

# root html;

# fastcgi_pass 127.0.0.1:9000;

# fastcgi_index index.php;

# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;

# include fastcgi_params;

#}

location ~ \.php$ {

root html;

fastcgi_pass 127.0.0.1:9000;

fastcgi_index index.php;

fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;

include fastcgi_params;

}

2. 這里使用的 PHP 是以 cgi 的形式,所以要啟用 php-cgi,修改 php.ini,把注釋去掉:

;cgi.fix_pathinfo=1

cgi.fix_pathinfo=1

3. 啟動 php-cgi 和 nginx,下面介紹兩個腳本:

start_nginx.bat

@echo off

REM set PHP_FCGI_CHILDREN=5

set PHP_FCGI_MAX_REQUESTS=1000

echo Starting PHP FastCGI...

RunHiddenConsole D:/xampp/php/php-cgi.exe -b 127.0.0.1:9000 -c D:/xampp/php/php.ini

echo Starting nginx...

RunHiddenConsole D:/nginx/nginx.exe -p D:/nginx/

stop_nginx.bat

@echo off

echo Stopping nginx...

taskkill /F /IM nginx.exe > nul

echo Stopping PHP FastCGI...

taskkill /F /IM php-cgi.exe > nul

exit

可以看看進程里,如果 nginx 和 php-cgi 都有,那么差不多要成功了。最后,可能會出現 "No input file specified" 的問題,那么修改一下 nginx.conf :

location ~ \.php$ {

#root html;

root D:/nginx/html;

fastcgi_pass 127.0.0.1:9000;

fastcgi_index index.php;

#fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;

#fastcgi_param SCRIPT_FILENAME D:/nginx/html$fastcgi_script_name;

fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

include fastcgi_params;

}

注意注釋的地方,修改成下面那行,請根據你的具體文件配置路徑。

編輯 test.php :

phpinfo();

?>

運行 http://localhost:81/test.php,OK。

總結

以上是生活随笔為你收集整理的nginx php 配置 windows_Windows下配置Nginx使之支持PHP的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。