win11搭建nginx+php環境

lvye1221發表於2024-03-06

win11搭建nginx+php環境

nginx 配置

nginx-1.24.0/nginx.conf

        # 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  $document_root$fastcgi_script_name;
            include        fastcgi_params;
        }

特別注意: $document_root$fastcgi_script_name; 其中1個字元都不能錯,這裡是與預設的配置資訊不同的。

在 html 目錄下放入

index.php

<?php

phpinfo();

?>

php 的配置

D:\tools\php-7.4.33-nts-Win32-vc15-x64\php.ini

cgi.fix_pathinfo=1

extension_dir = "ext"

根據需要開放擴充套件庫

extension=bz2
extension=gd2
extension=mbstring
extension=pdo_mysql
extension=pdo_sqlite

啟動

cd /d D:\tools\nginx-1.24.0
nginx


cd /d D:\tools\php-7.4.33-nts-Win32-vc15-x64
php-cgi.exe -b 127.0.0.1:9000 -c php.ini

http://localhost/index.php

img

參考資料

windows10搭建nginx1.19.3+php7.4
https://blog.csdn.net/u014650004/article/details/109240528