Linode Forum
Linode Community Forums
 FAQFAQ    SearchSearch    MembersMembers      Register Register 
 LoginLogin [ Anonymous ] 
Post new topic  Reply to topic
Author Message
PostPosted: Sat Feb 11, 2012 3:38 pm 
Offline
Junior Member

Joined: Sat Feb 11, 2012 3:29 pm
Posts: 26
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


Top
   
 Post subject:
PostPosted: Sat Feb 11, 2012 4:04 pm 
Offline
Junior Member

Joined: Thu Jun 16, 2011 12:49 am
Posts: 27
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!


Top
   
 Post subject:
PostPosted: Sat Feb 11, 2012 9:09 pm 
Offline
Junior Member

Joined: Sat Feb 11, 2012 3:29 pm
Posts: 26
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?


Top
   
 Post subject:
PostPosted: Sat Feb 11, 2012 9:15 pm 
Offline
Junior Member

Joined: Mon May 24, 2010 6:39 pm
Posts: 20
/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.


Top
   
 Post subject:
PostPosted: Sat Feb 11, 2012 10:20 pm 
Offline
Junior Member

Joined: Sat Feb 11, 2012 3:29 pm
Posts: 26
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.


Top
   
 Post subject:
PostPosted: Sun Feb 12, 2012 9:30 pm 
Offline
Senior Newbie

Joined: Sun Apr 25, 2010 1:12 am
Posts: 12
Please do try

chown www-data:www-data -R /yourfullpath


Top
   
 Post subject:
PostPosted: Mon Feb 13, 2012 1:00 am 
Offline
Senior Member

Joined: Fri May 02, 2008 8:44 pm
Posts: 1121
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.


Top
   
 Post subject:
PostPosted: Mon Feb 13, 2012 5:14 am 
Offline
Junior Member

Joined: Sat Feb 11, 2012 3:29 pm
Posts: 26
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.


Top
   
 Post subject:
PostPosted: Tue Feb 14, 2012 1:59 pm 
Offline
Senior Member

Joined: Wed Dec 01, 2010 10:39 am
Posts: 71
Website: http://www.pannix.net
Location: Belgium
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)?


Top
   
 Post subject:
PostPosted: Tue Feb 14, 2012 3:47 pm 
Offline
Senior Member

Joined: Fri May 02, 2008 8:44 pm
Posts: 1121
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...


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
RSS

Powered by phpBB® Forum Software © phpBB Group