'/'var/www/' vs '/home/$USER/public_html'

Solution 1:

The differences are the following:

  1. If you leave it in /var/www you will have some permission problems that you will have to deal with. In your home folder, you are in charge since all files in it have your ownership by default.

  2. Some users have the /home folder in another partition which means a +1 if you happen to format the root partition and leave the home partition alone for an upgrade.

  3. It saves you from adding a user to /var/www or having to change permissions for it if you just put it in your home folder. For example instead of /var/www it would be /home/USER/www.

  4. If you need to share via Samba the files, it is MUCH easier to do it in /home than outside of it.

There are more reasons but this are the ones at the top of my mind right now.

Solution 2:

In general, it will depend on what sort of development are you doing. If it is purely personal or for learning/testing purposes, then having it in ~/public_html is fine - there is no real difference as far as the webserver is concerned, and you won't run into any permission issues that way. But if your development will need to be deployed to other servers where things might not match up with your dev box, testing it in /var/www is a very good idea.

I generally do my web development in a bazaar branch under ~/local/src/ , then I use bzr push to copy completed code into a folder under /var/www for testing. Once it's reasonably tested there, I can use bzr-upload to push the code to my actual production server. This ensures that anything that gets deployed is checked in and tested, keeps /var/www clean, and keeps all of the working source code in my homedir.