1

I am attempting to open a php file by pointing the path in the url.

First
I add the testfile.php in the pub fodler since that is the root folder specified in nginx.conf.sample

Second
I edit nginx.conf.sample around line 109 from this:

location ~ (index|get|static|report|404|503|health_check)\.php$ {

to

location ~ (index|get|static|report|404|503|health_check|testfile)\.php$ {

Third
Execute:
sudo service nginx reload

I can access files like .txt .jpg but not files like php by entering www.mywebsite.net/testfile.txt

Why I still can't open the testfile.php?

  • Use nginx -T to test the configuration file, but nginx.conf.sample is probably just an example file, the real configuration file should be called nginx.conf. – Richard Smith Apr 14 '18 at 21:41
  • If you want to execute that file then you can run via command line. Asummed you have kept test.php in root folder then you can run like : php test.php – Pramod Kharade Apr 15 '18 at 11:26

Browse other questions tagged or ask your own question.