Lemp on Ubuntu - where should I place my website

Posted January 21, 2014 2.6k 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/ /var/www/ What about multiple sites? /var/www/public_html/ /var/www/public_html/ 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!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Submit an Answer
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:

This Server Fault post is also related to your question:
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!