6

Our old server has it in /home/user/public_html/ but it seems like it makes more sense in /var/www/.

The old server had cpanel and I suppose that as part of that setup, it separates virtual servers into their own folders in /home/ and gives them each a web root. All the files in /home/user/ were also owned by user, rather than root.

But we don't have sub accounts and I'm used to creating various virtual hosts in /var/www/ (from my Ubuntu experience), so is there any downside to just using /var/www/ in CentOS? I would then have all the files owned by a group that would include me and the other developer.

Skyhawk
  • 14,200
  • 4
  • 53
  • 95
Buttle Butkus
  • 1,741
  • 8
  • 33
  • 45

4 Answers4

4

Never put anything system critical under /home. I say /var/www.

Edit: In response to Butthle's comment, which I concede is a fair criticism of my otherwise correct answer, emphasis mine:

FHS (Linux Filesystem Hierarchy v 2.3, Section 3.8) PDF Link

3.8. /home : User home directories (optional)

3.8.1. Purpose /home is a fairly standard concept, but it is clearly a site-specific filesystem.

The setup will differ from host to host. Therefore, no program should rely on this location.

dmourati
  • 25,540
  • 2
  • 42
  • 72
  • That`s the default if you use apache2 from the CentOS-distribution. – Nils Jan 26 '12 at 21:39
  • Yes it is Nils, but I think Cpanel changes that to /home/user/publichtml. Our new server does not have Cpanel though. – Buttle Butkus Jan 30 '12 at 02:45
  • I don't think an answer like this "Never put anything system critical under /home. I say /var/www." actually contributes anything to any reader. There is no "why" here, so it is not edifying. – Buttle Butkus Jan 30 '12 at 02:51
  • 1
    I don't know why you are getting upvotes when the source you quote is referring to installable programs, not using the directory as a virtual host webroot. Your bolded text, "no program should rely on this location" looks very authoritative, but a quick read of the document shows that it's just wrong. I think everyone else here is correct in saying it doesn't really matter. Your answer is incorrect. But the document you link to is great and gave me more confidence in the correct answer. Thank you! – Buttle Butkus Jan 30 '12 at 10:28
  • 1
    FHS is wrong? "Installable progams"? You mean like apache, that "relies" on /home/somedir for its doc root? I don't understand what you are saying, and frankly, neither do you. Carry on. – dmourati Jan 30 '12 at 22:13
  • 1
    Interesting that the linked document doesn't contain a reference to `/var/www`. – Isius Feb 15 '13 at 18:18
4

I don't see any difference. Put it in /var/www or /home/USER/www with the same owner has strictly the same security level.

However the question is confusing: you don't have sub accounts, but you do have vhost and other developers. Those developers share the same account with you, or each have one account in the same group? It is hard to manage in this case. I think you would need a deployment system: developers work with git/subversion, and in the server, you use a tool (it could just be a simple shell script doing svn up or git pull) so that all files for those web apps are under the unique user.

jcisio
  • 588
  • 1
  • 9
  • 22
  • 1
    Your git/subversion suggestion is something I would be happy to explore at some point (maybe in a week or two) but for now it's way over my head. For now I think it would be simpler to just have me as owner of all files except ones that need to be written by apache, and then perhaps give the other developer ftp access to some files and keep track of his activity with the ftp log. Versioning just seems like way past my skill level at this point. – Buttle Butkus Jan 30 '12 at 02:48
  • 1
    I'll give you the check mark for actually giving explanation ("no difference because ... exactly the same security level"), and a +1 for making me think about other stuff. – Buttle Butkus Jan 30 '12 at 02:49
3

/var/www is the default root for CentOS (5 and up). The only differences I can think of are about maintainence (slightly easier if you use /var/www)

Alien Life Form
  • 2,309
  • 2
  • 21
  • 32
  • 1
    maintenance in what sense? – Buttle Butkus Jan 30 '12 at 02:52
  • I'm intrigued. Perhaps you can explain to us just why you believe maintenance is easier if the web root is in /var/www. – John Gardeniers Jan 30 '12 at 09:08
  • 2
    Because most packages/documentation/material/configuration examples will point to/assume /var/www. If you have pointed your DR elsewhere, you will forever need to correct those assumptions. As stated it is a "slight" advantage. – Alien Life Form Jan 30 '12 at 15:40
  • See the answer I posted. One of the reasons my web files are in different locations is in fact because that's where various packages put them, which goes against what you're saying. – John Gardeniers Jan 30 '12 at 20:47
  • most packages != all packages != various packages (last time I looked, that is). Also "slight" means "little, not very important" and "default location" means "unless overridden". Bottom line, you can put your files where you well please, but changing the default (on a pristine CentOS machine) takes more work (a little bit more, to be precise). – Alien Life Form Jan 31 '12 at 12:05
2

Where would you like to put it? I have one machine with web files in both of those locations (the reasons don't matter). As long as you configure and document everything correctly it doesn't matter.

John Gardeniers
  • 27,458
  • 12
  • 55
  • 109
  • Good point. My question arose from the fact that cPanel uses /home/user/public_html/ to split up virtual hosts among users, with each user having access only to their home/user/ directory and subdirectories (useful if you're hosting various customers' websites). Our new server does not have cPanel installed and so uses the usual location. But I didn't know any of this before, so I thought I'd ask. – Buttle Butkus Jan 30 '12 at 10:33