I have a web-server running nginx on my RPi. Now I have a strange problem however. In the nginx root directory I have 3 files, index.php, info.php and test.php.

I can access both index.php and info.php through both localhost and the RPi's IP-address from another computer. But when I try localhost/test.php all I get is "Access denied".

I uploaded test.php using an ftpclient and vsftpd if that matters, but editing and uploading index.php from the other computer I didn't get this problem. The file was updated as it should.

How can I solve this problem?


I couldn't be sure without some logs, but my best guess is that nginx can't read the file because of restrictive permissions.

You must make sure that nginx has permission to read the file (and possibly the directory too).

Your nginx error.log will tell you what the problem is. On the default installation of raspbian, it is /var/log/nginx/error.log

If you have shell access use

chmod a+r /location/of/file.php (you may need root permissions to do this)

With FTP you can change file permissions to something like 744

If you have shell access you can use this to read the error log in real time

tail -f /var/log/nginx/error.log
  • Sweet, chmod a+r /var/www/test.php fixed it. Where do I change file permissions and will this give permission by default to all files? – justanotherhobbyist Nov 4 '13 at 14:34
  • No, it will not be permanent. For a permanent solution you must set the default umask at 022 (or similar) in your ftp server configuration. To enable read for all files in /var/www use chmod -R a+r /var/www/ (-R means recursive) – foibs Nov 4 '13 at 14:38

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