Linux – Where is the best location to keep shared-developer website files in the linux hierarchy

apache-2.2hierarchylinuxweb-hosting

Serving html and php files

I just started hosting files for a website on my server, and I'm not sure where is an appropriate place to keep them to provide access for multiple users.
When I started hosting the site, I put the site files in: /var/www/name.of.virtualhost.site/www/.

I am deploying directly from a checked out repository, for convenience & simplicity, so to update the website codebase another developer or I only have to check out the latest version of the files in order to have everything up to date (using git, in this case). However, the root of the repository has files that I prefer to be non-public.

Right now that's obviously not the case because anything below the final public /www/ folder is also available on the default domain or ip since the /var/www/ contents are already being served up by default by apache. For example, /var/www/name.of.virtualhost.site/docs/site_policies.txt is accessible via some url like
defaultsite.com/name.of.virtualhost.site/docs/site_policies.txt.

So where is a better place to store a website's files on linux?

When it's a site that only I'm developing, I can obviously just stick them in /home/my_username/sites/name.of.virtualhost.site/, but that doesn't work well when I want other developers to be checking out the repository and sometimes editing the site's files as well. And I'm running a LAMP stack, not that I expect it to matter.

Best Answer

There is no one size fits all answer to your problem. /tmp would be accessible to all users but is a poor place to put such files.

I am not sure why you aren't using proper version control so all developers are developing in their respective development environments and then pushing to a master repository.

If you are referring to a dev box (which you don't say) then create directory, in some place like /usr/local/src and make it writable by a group that all the developers belong to. Then create a deployment script that puts the files that need to be publicly accessible under the web root.

Related Topic