Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I come from a strong Windows background. Therefore with IIS I have some site on my D drive, I then point IIS at this location and start serving files. With Apache though it seems var/www is the default location. This would match IIS in the sense that IIS uses wwwroot or similar.

For local development I am used to using something within my user directory, but is this the standard practice for development on Linux?

  • Should I copy my code to var/www whenever I make a change?
  • Should I use folders within my home directory?
  • Or should I use another location all together?
  • Does anyone know of an IIS to Apache tutorial?

I should add that when I change var/www to home/shaun/sites I cannot serve any files, hence I think I should not be doing this, or at least use another directory.

share|improve this question

Apache is a powerful and flexible web server and there is ample documentation on the web.

To get you started:

1) Yes, the default web root is /var/www

2) You can change Apache's behavior if you wish. From your question , I would activate the home directory option.

sudo  a2enmod userdir

Restart apache

To use a directory in your home, make a directory public_html

mkdir ~/public_html

Put your web pages in ~/public_html

FYI: ~ is short hand for your home directory.

You can browse them with




Where "username" is your log in user name.

That should get you started, do not feel overwhelmed if you do not understand all that code yet, you will learn.


Apache symlinked to home directory - Permission Errors

share|improve this answer

The answers to this question can be illustrative also. In my case I don't wish to change Apache's behavior, just the folder that I am going to use for testing purposes, of which I suggest you to give a chance to this:

However, if we wish to use another local folder for testing in our PHP code, we can change the default folder location used by our php engine to manage these files. This is done using the following procedure:

gksu gedit /etc/apache2/sites-available/default

Provide user password

Then, change all occurrences of "/var/www/" to the folder that we use to test our PHP. (Example: /home/geppettvs/www/ or where appropriate, change "geppettvs" by your local folder.

After that you must restart the computer for the purpose of the changes to take effect. Do not forget also that the files must have the proper file permissions to run properly. (755 is usually sufficient, but some folders [and/or files] may need 777 permissions to read and write them correctly.)

This procedure was working on Natty, and I can't say for 11.10 yet. And I use this trick in order to test PHP, that's why I drop the warning about the 777 permissions for some files/folders.

If you do this, you can gain access to your files via http://localhost instead of calling a given folder name. The "www" folder (or whatever you name it) will be your "public_html" folder.

Good luck!

IMPORTANT: People have suggested that you don't need to restart your machine in order to the changes take effect, but if you don't, then you must stop and restart apache, restart your session and pray for everything to work without a hassle. I suggest you to restart the computer and I can say for sure it will work.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.