Nginx downloads php files does not run!

I have installed nginx and php7. However the browser just downloads the php files rather than executing them! php works fine in the command line

Any help appreciated! have also posted on the rpi org forum

Hey Peter,

You need to tell Nginx that it should read php files not just serve them to clients. To do this you need to update
/etc/nginx/sites-enabled/default to include index.php there is a great guide on the Rpi foundation website that should get you up and running.

Thanks I have partially solved this issue and do have index.php in the default file

If I include the network address in the browser and rename the file to.php it does run

192.168.1.17/phpfile.php

However if I double click on that file in the raspbian the browser just downloads the php file

Peter

Hi Pete,

Php are a server side script so they need to server to run them if you open the file directly it won’t know what it is. If you don’t want to use the external IP you can use the self referencing IP of 127.0.0.1/phpfile.php.

127.0.0.1 always points to the current machine no matter what your IP is.

Thanks - I did not realise this! I thought one could double click on a php file and the browser would open it.

Using 127.0.0.1 or localhost works fine

1 Like

It would make editing php a lot more convenient. Happy coding, let us know if you run into any other issues. setting up web servers is always fun!