clifton
By:
clifton

Tip: Location of Web Files for Virtual Host

January 25, 2013 6k views
This isn't a question, just a tip that I hope someone finds useful. :) If you follow Digital Ocean's Virtual Host thread (https://www.digitalocean.com/community/articles/how-to-set-up-apache-virtual-hosts-on-ubuntu-12-04-lts) they recommend that you put your web files here: /var/www/example.com/public_html I find it better to add your web files to your user's directory so that you have read/write access when you connect to the server with a Secure FTP client (like Transmit for Mac: http://panic.com/transmit). Otherwise, editing files in /var/www requires sudo permission which can be less convenient. I prefer to put my files for a website in: /home//example.com So here's what my virtual host file (/etc/apache2/sites-available/sandlotillustrated.com) looks like for one of my domains. Note the custom error log location for easier, non-sudo access: http://d.pr/n/6VqI
1 comment
  • Hi,

    can you explain to me the whole process, i think i prefer this idea to storing site data in the /var/www/html/domain.com/public_html folder.

    adding a user per site would be more useful to me.

    Thanks

4 Answers
Thanks for the tip. This will indeed make it easier to manage.
hm, might be a good idea to do this...
Part of my original post got eaten. Here's the corrected line:

I prefer to put my files for a website in: /home/{user}/example.com
Better yet, ust Git. Put a "bare" git repo in your home folder and use a post-receive hook to copy it over to your web folder. That way, you can retain the tighter permissions on the actual web-facing folder and all you have to do is push to your repo!
Have another answer? Share your knowledge.