Need tutorial for setting up Apache with a custom www folder

Asked by kjudd

I think I just need some help finding the correct documentation for this...

I have installed Apache on Ubuntu 10.04 LTS. I can load the default test page fine. I go to and I get the page "It works!"

This test file is located at: /var/www/index.html

However, I do not have permission to write files to this directory (yes I can move files there with sudo, but that is very inconvenient.) I need to figure out how to specify a www directory within my home folder so that I can easily edit files.

I tried several things including setting up a symbolic link and changing the DocumentRoot path in the Apache config files. The result always seems to be a 403 Forbidden error, which I assume means that the files or folders are not set with the correct permissions. Using chmod 755 on the directory and 644 on the file did not help.

I come from using a Mac where the Apache configuration seemed a little more straight-forward, with a Sites folder already setup in my home folder. I'm basically trying to get that same functionality here.

(Note: this is not a production web server, this is going to be used for testing web development locally before uploading to live server.)

Question information

English Edit question
Ubuntu apache2 Edit question
No assignee Edit question
Solved by:
Last query:
Last reply:
Revision history for this message
actionparsnip (andrew-woodhead666) said :

using sudo with that folder will keep your site secure and will also keep non-amin users from editting your data. Can you give the output of:

ls -la /var/www


Revision history for this message
kjudd (kjudd) said :

Here is the output of ls -la /var/www

total 12
drwxr-xr-x 2 root root 4096 2010-08-26 17:12 .
drwxr-xr-x 15 root root 4096 2010-07-02 01:33 ..
-rw-r--r-- 1 root root 177 2010-07-02 01:34 index.html

Revision history for this message
actionparsnip (andrew-woodhead666) said :

ok then make a group and add your user and root to the group. You can then run:

sudo chown -R :groupname /var/www; sudo chmod -R g+w /var/www

replace groupname with the name of the group you make (make it something obscure so you dont replicate the system group names)

Your user will now have write access as it is in the group and the group has write access. The owner will still be root which makes it secure. As you have the ownership on this page you can easily refer to it and roll back should you need to

Revision history for this message
kjudd (kjudd) said :

I figured out a solution to the permission problem by adding execute privilege (701) to the /home/user folder. Then I enabled the Apache userdir mod, and it works as expected. I guess this would open my home folder to peeking by other users, but this is my own personal machine, so I don't think it would be an issue... unless anyone knows of a better solution, I think I'm all set.

Revision history for this message
kjudd (kjudd) said :

actionparsnip - I missed you latest post before my last reply. I think that makes sense and might be the better solution, so I'll give it a try. Thanks!