Skip to content

Instantly share code, notes, and snippets.

@brosahay
Last active May 24, 2020 22:06
Show Gist options
  • Save brosahay/917d23fea77801b0a5dc6b9249fc725b to your computer and use it in GitHub Desktop.
Save brosahay/917d23fea77801b0a5dc6b9249fc725b to your computer and use it in GitHub Desktop.
Setup Nginx Server with PHP on windows

Downloads:

Installation:

  1. Extract the nginx to a location. example C:\nginx
  2. Extract the PHP for Windows into nginx folder. example C:\nginx\php
  3. Configure PHP in nginx:
    1. Remove nginx.conf
    2. add the below nginx.conf :
      location ~ .php$ {
      	root           html;
      	fastcgi_pass   127.0.0.1:9000;
      	fastcgi_index  index.php;
      	fastcgi_param  SCRIPT_FILENAME  C:/nginx/html/$fastcgi_script_name;
      	include        fastcgi_params;
      }
  4. To start the nginx server and php:
    @echo OFF
    start C:\nginx\nginx.exe
    start C:\nginx\php\php-cgi.exe -b 127.0.0.1:9000 -c C:\nginx\php\php.ini
    ping 127.0.0.1 -n 1>NUL
    echo Starting nginx
    echo .
    echo ..
    echo ...
    ping 127.0.0.1 >NUL
    exit
  5. To stop nginx and php:
    @echo OFF
    taskkill /f /IM nginx.exe
    taskkill /f /IM php-cgi.exe
    exit
  6. Check the server at 127.0.0.1 or localhost
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment