Lemp on Ubuntu - where should I place my website

January 21, 2014 1.4k views
Hello, I've always used shared hosting, so this is quite a learning curve...thanks in advance for any help! I've read different things about the default home directory so I'd like to know which is recommended. I'll be using WordPress, and might add more than one site (will start with one and go from there) on the same droplet. Is there any preference between (both are available): /var/www/ /usr/share/nginx/www/ What is considered best practice for adding a single site? /var/www/public_html/mysite.com /var/www/mysite.com/public_html What about multiple sites? /var/www/public_html/mysite1.com /var/www/public_html/mysite2.com etc Or is there more recommended structure? I setup another directory as /home/, but I'm having a lot of permission issues with wordpress and I think I made a mistake in not using the default locations (which I didn't understand until after I was finished). Thanks!
2 Answers
Since you are configuring the sites, it's entirely up to you where you put them, though I recommend that you pick a structure and stick to it. As for what is convention/recommended, /var/www/ is a pretty normal location for web files, though /srv/www is used on some distributions. Serving from home directories is do-able, but it's a pattern usually seen on shared hosting (eg. cPanel) to separate users' files and isn't entirely beneficial in a private system (relaxed permissions or server running as a user).

Virtual hosts can, again, be structured any way you like. Personally I use /var/www as a base, with a folder for each virtual host, and the document root of each virtual host another level deep:


The `htdocs` name aside (just a habit), I find this structure useful to group both public and private (logs, scripts, etc) aspects of a site together.

There's a decent thread on the Unix Stack Exchange site about where /should/ website files go: http://unix.stackexchange.com/questions/47436/why-is-the-root-directory-on-a-web-server-put-by-default-in-var-www/

This Server Fault post is also related to your question: http://serverfault.com/questions/124127/linux-fhs-srv-vs-var-where-do-i-put-stuff
Hi Stephen,

Thanks for your very helpful reply! I took a look at both links, as well as some additional research and it seems there's no set answer, but there are a couple of structures that are considered common practice.

I think I will follow your advice and use:


Thanks again for your help!

Have another answer? Share your knowledge.