This is covered in the Introduction and Appendices F through I of the Definitive Guide to Drupal 7.
Here are a few quick reminders of where drupal files should go depending on your set-up.
In general you can put a site's files anywhere as long as you point the server to look at them, but it can be convenient to follow what a given set-up expects by default.
Note On UNIX-like systems, including Ubuntu and Mac OS X, a ~ represents your home directory, which is often home/yourname or user/yourname.
Drubuntu (Ubuntu)
~/workspace/
At one point in the book, we recommended making a symlink from this directory to the web roots of projects hosted in another directory, ln -s ~/code/projectname/web ~/workspace/projectname
because this allows a full project to be automatically reachable in the browser at http://projectname.localhost
.
XAMPP on Windows
C:/xampp/htdocs/