| Author |
Message |
nthvision
Joined: 11 Feb 2012
Posts: 23
|
| Posted: Sat Feb 11, 2012 2:38 pm Post subject: nginx location root question |
|
|
Hey everybody, I just bought a linode last night and I ended up installing the Arch Linux flavor. I installed the nginx server succesfully with the pacman package handler. And the server is up and running.
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 :
Code: root /srv/http/example.com/public;
it works; however I made a directory in my root
Code: /mywebfiles
and changed the root directive appropriately
Code: 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 |
|
| Back to top |
|
iWizardPro
Joined: 15 Jun 2011
Posts: 19
|
| Posted: Sat Feb 11, 2012 3:04 pm Post subject: |
|
|
You need to set the proper location and permissions for your directories. If you created the folder "mywebfiles" in your /root directory, you will need to point it to /root/mywebfiles for it to function properly. You also need to run chown for nginx to access the folder:
Code: chown nginx:nginx -R /root/mywebfiles
Hope that helps! |
|
| Back to top |
|
nthvision
Joined: 11 Feb 2012
Posts: 23
|
| Posted: Sat Feb 11, 2012 8:09 pm Post subject: |
|
|
iWizardPro, thank you! it worked.. for the most part.
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? |
|
| Back to top |
|
Jay3ld
Joined: 24 May 2010
Posts: 19
|
| Posted: Sat Feb 11, 2012 8:15 pm Post subject: |
|
|
/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. |
|
| Back to top |
|
nthvision
Joined: 11 Feb 2012
Posts: 23
|
| Posted: Sat Feb 11, 2012 9:20 pm Post subject: |
|
|
Jay3ld wrote: /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'
Code: /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. |
|
| Back to top |
|
Tiven
Joined: 25 Apr 2010
Posts: 12
|
| Posted: Sun Feb 12, 2012 8:30 pm Post subject: |
|
|
Please do try
chown www-data:www-data -R /yourfullpath |
|
| Back to top |
|
hybinet
Joined: 02 May 2008
Posts: 1058
|
| Posted: Mon Feb 13, 2012 12:00 am Post subject: |
|
|
You shouldn't have to chown your directories and files to the nginx (or www-data) user. As long as your directories and files are world-readable (which they usually are by default), nginx will have no trouble serving them over the web, no matter who owns them. In fact, it's a potential security risk to have web files owned by the same user as the web server.
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. |
|
| Back to top |
|
nthvision
Joined: 11 Feb 2012
Posts: 23
|
| Posted: Mon Feb 13, 2012 4:14 am Post subject: |
|
|
| hybinet, I do have an Index.html file, and try_files directive, for some reason it just doesn't serve up files from any other directory other than the /srv Im completely puzzeled. |
|
| Back to top |
|
pannix
Joined: 01 Dec 2010
Posts: 39
Location: Belgium
|
| Posted: Tue Feb 14, 2012 12:59 pm Post subject: |
|
|
Am a newbie like yourself, but have my LEMP up and running (ubuntu server).
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)? |
|
| Back to top |
|
hybinet
Joined: 02 May 2008
Posts: 1058
|
| Posted: Tue Feb 14, 2012 2:47 pm Post subject: |
|
|
Does anything appear in the error log when you get 403 errors? The error log might contain more detailed information about the problem.
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... |
|
| Back to top |
|
| |