3

So I have a website.

www.example.com directory pointed at /var/www/html/

I can load a webpage at

www.example.com/foo/

The file for that page is at

/var/www/html/foo/index.html

that index.html has a style sheet and object in the foo folder and tries to request it using

www.example.com/foo/bar.css

However, bar.css returns 404 not found even though it's at

/var/www/html/foo/bar.css

What gives? The files have 644 user rights. If index.html can be found shouldn't the other files be too?

3
  • 1
    Update your question with the nginx configuration file(s) and relevant entries from your nginx-access.log and nginx-error.log – Richard Smith Sep 4 '16 at 8:07
  • logs are located at /var/log/<application name>/ – CausingUnderflowsEverywhere Sep 4 '16 at 14:08
  • Maybe the execute permission wasn't set on the parent directory(s). In order to view files inside a directory, you must be able to execute the directories. – CausingUnderflowsEverywhere Aug 4 '17 at 15:17
4

Your folders must be set to file permission 755 using chmod. I successfully got it working after the following steps:

After changing the owner of foo/

$ /var/www/html# chown root foo

and the subfiles to root, as well as changing the chmod of foo/ to 755

chmod 755 foo

to mimic /var/www/html/ 's permissions, my files became accessible.

Remember to use

ls -l 

in your directory to check for the right file permissions. Also check your access and error logs at /var/log/nginx/ (this is accurate for debian at the very least, since this is what I am using)

If you can't find your log files, use

find / | grep error.log > results.txt

and open results.txt with your favourite text editor such as vi results.txt (Assuming you're on a server and it's easier to read text files than the terminal).

Thank you to Richard for telling me to check my logs.

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.