localhost on apache2
I'm a noob and I'm using a new install of Debian 3.1 kernel 2.6.8. I installed apache2 and set up a localhost site. I edited '/etc/hosts' to include a fake domain name, and edited '/etc/apache2/sites-available/default' to look like this (in part)
Code:
NameVirtualHost 127.0.0.1 (I read about how apache had a bug where you had to take the trailing slash off of the 'DocumentRoot' line, or certian things wouldn't work. I thought initially that was my problem, but alas, following that line of thinking produced no solution for me.):confused: |
When you visit a webpage on space allocated for user X on an Apache server you basically have the permissions that user has on that server. Okay, it's a shortcut, but it helps to understand the permissions issue. When that user doesn't have permission to access a particular directory on the server, neither do you! The solution is quite simple: make sure both directories are owned by the same user ;) Or, in case that troubles you: make a group with both users and change ownership of the directory to that group.
|
Dutch Master, thanks for the reply! I'm not sure I totally understand what you're saying. You mean I should make sure that either I start a group for my directories that are under document root, or I change their ownership, to make sure that the user who requests the web page has permission on those directories...
OK. I should have written before, I have permission on all those directories... '/var/www/' and the test directory '/var/www/pics/'. I tried to change the permission on '/var/www/' itself to my user (from root). I still can't see files that reside in '/var/www/pics' when I look at '/var/www/index.html'. Bummer. ('/var/www/index.html' has some pictures on it that reside in '/var/www/pics'). Anybody have any more ideas??? EDIT: it seems in a way you were right. I got it to work by changing the permissions. Files in the '/var/www/pics' directory had to be changed from r permission to rw permission. 'chmod 666 *' in the pics directory seemed to do the trick. Thanks. |
In the apache config there is a bit that sets what user and/or group apache runs. say for example it runs as user=apache and group=apache.
Make ensure apache can read the directories that you want to view from a web browser. an example of ownership and permissions ### apache user can read/write/execute, apache can group read/execute, all others can not. However people viewing it from a web browser can see it cause apache is the user that accesses it. /var/www drwxr-x--- apache apache ### apache user/group and any other can not read/write/execute this directory. only root can do stuff, so no one with a web browser can see it cause apache can not read the contents of the directory /var/www/pics drwxr-x--- root root Be careful when setting write permissions to directory that are viewable from the web, it can be possible that someone will put nasty stuff there. :) |
The best thing I've found is to put the public_html folder inside the user's home directory and configure apache to look for its www root under ~/public_html.
|
Thanks for the replies!! I tried out some different things. setting the 'other' permission to 'read' is what made my pics in my '/var/www/pics' folder work. 'chmod 604 sample.bmp' works and 'chmod 773 sample.bmp' doesn't. That sort of supports the special 'apache' group idea. I'm transferring these over from a mounted windows partition, so the files all end up with root as the owner and 400 the permissions.
Where do you find the info on what group and user apache works as? |
From the apache docs which can be found at http://httpd.apache.org/docs/2.0/
user to run as group to run as :) |
Thanks. I went to the links above. I also found the lines for 'User' and 'Group' in the apache2.conf file. Thanks again.
|
All times are GMT -5. The time now is 02:51 PM. |