Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question
Funny how popular this question is and how lowly it is rated. – Buttle Butkus Dec 1 '12 at 0:23
up vote 2 down vote accepted

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.

share|improve this answer
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 2:48
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 2:49

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.

share|improve this answer
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 2: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 2:51
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
Interesting that the linked document doesn't contain a reference to /var/www. – Isius Feb 15 '13 at 18:18

/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)

share|improve this answer
maintenance in what sense? – Buttle Butkus Jan 30 '12 at 2: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 9:08
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

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.

share|improve this answer
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

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.