I have installed PHP7 and Nginx on Windows 10 bash.

PHP is installed at /etc/php/7.1 Nginx installed at /etc/nginx

I get 502 Bad Gateway when I try to go to localhost and load index.php

How can I configure /etc/nginx/sites-available/default so that it runs PHP scripts properly? So far, nothing I have tried works.

  • So what have you actually tried? Did you check the log files? What does your current configuration look like? – Seth Feb 3 '17 at 9:30
  • I tried to uncomment the section related to PHP in the configuration nginx file but that did not work. Thanks for idea for checking log files. Will do that next. – Scott Yu - builds stuff Feb 3 '17 at 17:53
  • Did you adjust it to match your configuration? Maybe include it in your post to clarify. Did you look at one of the various guides/tutorials for it? – Seth Feb 3 '17 at 17:59

Okay, I finally got PHP + Nginx working on Windows 10 bash.


location ~ \.php$ {
    fastcgi_split_path_info ^(.+\.php)(/.+)$;
    fastcgi_index index.php;
    include fastcgi_params;


listen =

Installed php-fpm using apt-get install php5-cgi php5-fpm

Edit php.ini at /etc/php5/fpm/php.ini

Restarted using service nginx restart && service php5-fpm restart

One thing I noticed is symbolic links doesnt work. So I had to copy configuration file for virtual hosts from the sites-available to sites-enabled directory.

  • I got it working via tips from digitalocean.com/community/questions/… – Scott Yu - builds stuff Feb 4 '17 at 4:43
  • You've just solved this after an hour of searching for me, cheers! - Why not mark yourself as the right answer? – Jamie Taylor Feb 20 '17 at 0:21
  • Wondering how much this would change using php7.0. Running into the same issue as the above on WSL. – markbratanov Apr 13 '17 at 4:00
  • Great! it works on php 7.0 on my machine. thank you. – Fery W Jun 3 '17 at 18:53
  • how can i upgrade php 7.0 on WSL? also, what does it mean when NGINX is described as a "reverse proxy" server? – oldboy Aug 11 '17 at 9:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.