Need tutorial for setting up Apache with a custom www folder

Asked by kjudd on 2010-08-26

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 http://127.0.0.1/ 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

Language:
English Edit question
Status:
Solved
For:
Ubuntu apache2 Edit question
Assignee:
No assignee Edit question
Solved by:
kjudd
Solved:
2010-08-26
Last query:
2010-08-26
Last reply:
2010-08-26

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

Thanks

kjudd (kjudd) said : #2

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

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

kjudd (kjudd) said : #4

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.

kjudd (kjudd) said : #5

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!