/var/www/ vs. /home/user/public/mydomain.com/ ?

I've only had my Linode set up for a couple weeks now. I don't know when exactly it happened but the instructions for Configuring Name Based Virtual Hosts in this guide https://www.linode.com/docs/websites/hosting-a-website have changed since my initial set up.

It's basically the same but the big difference I see is that now this guide is putting virtual hosts in the /var/www/ directory. When I set up my hosts a couple weeks ago this same guide said to put virtual hosts in /home/user/public/mydomain.com/

so my DocumentRoot in my .conf files look like:

DocumentRoot /home/user/public/mydomain.com/public

The DocumentRoot in the current version of .conf code in the guide look like :

DocumentRoot /var/www/example.com/public_html

Why would this have changed?

What is the difference between these two different DocumentRoots?

Is is better to file in /var/www/?

Does having multiple Virtual Hosts affect where they should be filed?

3 Replies

saladdays,

You can use either location. The /var/www location is the default for some distributions, such as Ubuntu. I always use the /home/user location.

Just so you know, you can use any directory you want. For example, I don't use the 'public' directory. I use something like:

  • /home/msj/mainstreetjames.com (for the main site)

  • /home/msj/demos.mainstreetjames.com (for the demos site for my clients to see)

  • /home/msj/test.mainstreetjames.com (test code for clients before the changes go live)

I could just as easily use:

  • /var/www/msj/mainstreetjames.com (for the main site)

  • /var/www/msj/demos.mainstreetjames.com (for the demos site for my clients to see)

  • /var/www/msj/test.mainstreetjames.com (test code for clients before the changes go live)

or:

  • /var/www/mainstreetjames.com (for the main site)

  • /var/www/demos.mainstreetjames.com (for the demos site for my clients to see)

  • /var/www/test.mainstreetjames.com (test code for clients before the changes go live)

or:

  • /clients/sites/msj/mainstreetjames.com (for the main site)

  • /clients/sites/msj/demos.mainstreetjames.com (for the demos site for my clients to see)

  • /clients/sites/msj/test.mainstreetjames.com (test code for clients before the changes go live)

MSJ

I usually use /srv/www/mydomain.com or /var/www/mydomain.com - I try to keep everything really organized because I usually have a lot of virtual hosts on my servers.

I use /var/www/users// for their domains. Then they have a -web chroot'd to their folder.

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct