nginx location root question
I have a linux/nginx noob question though.
when I set up the nginx.conf file with the documentation found in the linode tutorials it has the root directive set to this :
root /srv/http/example.com/public;
it works; however I made a directory in my root
/mywebfiles
and changed the root directive appropriately
root /mywebfiles;
and it gives me a 404 when ever I point to my web address.
Am I missing something here? Am I not allowed to server up files from anywhere else other then the /srv/ directory? or do I need to CHMOD my /mywebfiles/ directory ?
this is most likely a simple issue to an expirienced user.
Thank you for reading.
-Isaac
9 Replies
chown nginx:nginx -R /root/mywebfiles
Hope that helps!
however now I am getting a 403 forbidden error.
both of the /root/srv/ and /root/mywebfiles have the same chmod value -> of drwxr-xr-x
the chown command did not work, as I am logged in as root and I don't have a nginx user or group …
what now could be the cause for nginx not being able to access /root/mywebfiles?
Try putting your files in /srv (not /root/srv) or somewhere else.
@Jay3ld:
/root is a protected directory, you shouldn't let non root users access it.
Try putting your files in /srv (not /root/srv) or somewhere else.
Thanks for the reply Jay3ld , in taking your advice I have decided to move the folder into the home directory of 'isaac'
/home/isaac/mywebfiles
but I still get the same 403 error :/ I honestly don't mind keeping serving up my site from the srv directory, however this is something simple that should be possible but I cannot get it to work.
chown www-data:www-data -R /yourfullpath
Do you have an index.html file in the directory? If there isn't, nginx will keep throwing 403 errors. If you want to use index.php or some other file as the home page, you must make sure that there's an "index" or "try_files" directive that points to the right file.
I just put all websites in the /srv/www/ directory (default dir for nginx on ubuntu):
/srv/www/site1/
/srv/www/site2/
…
Owner is main user, in your case this would be isaac, but files are readable by www-data (nginx user on ubuntu). I never used arch linux and am no expert, but if you want more help, could you post your nginx.conf, virtual host config file and nginx error log (and virtual host error log)?
Are you running any sort of access control mechanism (e.g. AppArmor) that restricts server programs to specific directories?
Are you running nginx in a chroot? (Probably not, since nginx can find /srv, but it's still worth looking into.)
If the problem persists and you really really want to put your website files somewhere else,y you could try using symlinks, you know…