The answers to this question https://askubuntu.com/a/25045/9598 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.