NGINX can interface with PHP on Windows via a FastCGI daemon, which ships with PHP: php-cgi.exe. You need to run php-cgi.exe -b 127.0.0.1: and use fastcgi_pass 127.0.0.1:; in the NGINX configuration file. After being launched, php-cgi.exe will keep listening for connections in a command prompt window. To hide that window, use the tiny utility RunHiddenConsole
First
Second
- Extract nginx to "C:\nginx"
 - Extract php to "C:\php"
 - Create folder "www" in your "C" system , "C:\www"
 
Third
- Edit your nginx.conf at "C:\nginx\conf\nginx.conf"
 - 
Change root
root c:/www; Save nginx.conf
Open yout php folder, find php-ini-development
- 
Edit your php-ini-development, like down below.
extension_dir = "ext" enable_dl = On cgi.force_redirect = 1 fastcgi.impersonate = 1 cgi.rfc2616_headers = 1 extension=php_gd2.dll extension=php_mbstring.dll extension=php_exif.dll extension=php_mysql.dll extension=php_mysqli.dll extension=php_pdo_mysql.dll date.timezone = "Asia/Jakarta" Save it.
Open your nginx.conf again
- 
Uncoment on php configuration and change to this
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9999 location ~ \.php$ { fastcgi_pass 127.0.0.1:9999; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } Save nginx.conf again.
Fourth
- Set Php path
 - Open your environment variable
- Open "edit the system environment variables"
 - Click, "Environtment variables ..."
 - Edit "path" on "Sytem ariables"
 - Add new path "C:\php"
 
 
Create nginx start, stop & restart .bat
- Download RunHiddenConsole first, and move RunHiddenConsole.exe to "C:\".
 - 
Create file "nginx-start.bat", edit file with down below, make your php-cgi.exe port same as in nginx.conf
@ECHO OFF ECHO Starting PHP FastCGI... C:\RunHiddenConsole.exe C:\php8\php-cgi.exe -b 127.0.0.1:9999 ECHO Starting NGINX start nginx.exe popd EXIT /b - 
Create file "nginx-stop.bat", edit with this
@ECHO OFF taskkill /f /IM nginx.exe taskkill /f /IM php-cgi.exe EXIT /b - 
Create file "nginx-restart.bat"
@ECHO OFF call nginx-stop.bat call nginx-start.bat EXIT /b 
Test
- Doble click on "nginx-start.bat"
 - Open your browser if every thing work you can see like this
 - Create folder like "test-php" in "C:\www"
 - 
Create file "index.php"
<?php phpinfo(); ?> Open your browser and go to "localhost/test-php"
At the end , nginx php now working.
Notes:
Sometimes , nginx & php cannot working properly if your run with nginx-start.bat
so you need to run php manually
open your terminal, run your php "php-cgi -b 127.0.0.1:9999"
and now your nginx & php work properly
              
    
Top comments (2)
why is it said at the beginning of the article that we must download NON STABLE version of PHP ?
I tried to use stable version , but its not work in my system