0

Sorry for the rather confusing title, I am trying to understand this error.

I have a php file, inside a folder like site.com/src/app/index.php and this site.com folder is placed in /var/www/html/ in a CentOs 6.5 running Nginx, and PHP-FPM.

So, the problem is that whenever I use any of the path functions and constants like __DIR__, getcwd(), realpath() inside index.php I would expect the full path to be as

/var/www/html/site.com/src/app/ but, only site.com/src/app/ gets returned. It is as if, that php/nginx does not know about var/www/html/ folder.

I event went to the app/ dir and was able to get the full path using sudo pwd but for some reason, php is not reading it.

I would like to know why this is happening, and how to fix it?

robue-a7119895
  • 167
  • 1
  • 8
  • Are you running nginx in a chroot jail configuration? This would be the expected behavior of such a configuration. – swelljoe Jul 31 '14 at 17:28
  • Well, the thing is I am a noob. I followed [the Digital Ocean](https://www.digitalocean.com/community/tutorials/how-to-install-linux-nginx-mysql-php-lemp-stack-on-centos-6) guide to install it altogether. – robue-a7119895 Jul 31 '14 at 17:34

1 Answers1

1

Based on the example configuration I see at the Digital Ocean documentation you've linked, I suspect the following line is where your issue is coming from:

fastcgi_param  SCRIPT_FILENAME   $document_root$fastcgi_script_name;

Or, rather, from a missing or incorrect root directive in one of the parent blocks. Then again, I'm not sure this is the behavior you'd see in such a case...I feel like it would give an error rather than run the script with incorrect results, but I don't have much experience with nginx.

See: https://www.nginx.com/resources/wiki/start/topics/tutorials/config_pitfalls/#fastcgi-path-in-script-filename

If you're still not sure how to proceed, please add your configuration for both nginx and the php-fpm configuration.

Michael Hampton
  • 244,070
  • 43
  • 506
  • 972
swelljoe
  • 1,415
  • 8
  • 12