LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Debian
User Name
Password
Debian This forum is for the discussion of Debian Linux.

Notices


Reply
  Search this Thread
Old 12-03-2006, 04:47 PM   #1
radiodee1
Member
 
Registered: Oct 2006
Location: New York
Distribution: Debian
Posts: 675
Blog Entries: 11

Rep: Reputation: 36
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 
<VirtualHost 127.0.0.1>
#       ServerName www.davenet.com
        ServerAdmin webmaster@localhost

        #DocumentRoot /var/www/
        DocumentRoot /var/www

        <Directory />
                Options FollowSymLinks
                AllowOverride None
        </Directory>

        <Directory /var/www>
                Options Indexes FollowSymLinks MultiViews
                AllowOverride None
                Order allow,deny
                allow from all
                # This directive allows us to have apache2's default start page
                # in /apache2-default/, but still have / go to the right place
                # RedirectMatch ^/$ /apache2-default/
        </Directory>

	#... more stuff here
</VirtualHost>
Well, I can see my '/var/www/index.html' page (at document root) but that page cannot access any resources that are in a directory... a directory in document root too, like a pics directory at '/var/www/pics/'. I did this before on a w32 version of apache 2, but it worked a little differently. Can anybody tell me how to get this to work?

(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.)

Last edited by radiodee1; 12-03-2006 at 04:51 PM.
 
Old 12-03-2006, 06:14 PM   #2
Dutch Master
Senior Member
 
Registered: Dec 2005
Posts: 1,686

Rep: Reputation: 124Reputation: 124
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.
 
Old 12-04-2006, 06:54 AM   #3
radiodee1
Member
 
Registered: Oct 2006
Location: New York
Distribution: Debian
Posts: 675

Original Poster
Blog Entries: 11

Rep: Reputation: 36
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.

Last edited by radiodee1; 12-04-2006 at 07:12 AM.
 
Old 12-04-2006, 07:12 AM   #4
snowtigger
Member
 
Registered: Mar 2005
Location: england
Distribution: slackware, win2k
Posts: 364

Rep: Reputation: 35
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.

 
Old 12-04-2006, 08:31 AM   #5
vharishankar
Senior Member
 
Registered: Dec 2003
Distribution: Debian
Posts: 3,178
Blog Entries: 4

Rep: Reputation: 138Reputation: 138
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.
 
Old 12-04-2006, 05:26 PM   #6
radiodee1
Member
 
Registered: Oct 2006
Location: New York
Distribution: Debian
Posts: 675

Original Poster
Blog Entries: 11

Rep: Reputation: 36
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?

Last edited by radiodee1; 12-04-2006 at 05:38 PM.
 
Old 12-05-2006, 06:19 PM   #7
snowtigger
Member
 
Registered: Mar 2005
Location: england
Distribution: slackware, win2k
Posts: 364

Rep: Reputation: 35
From the apache docs which can be found at http://httpd.apache.org/docs/2.0/

user to run as

group to run as

 
Old 12-06-2006, 05:49 PM   #8
radiodee1
Member
 
Registered: Oct 2006
Location: New York
Distribution: Debian
Posts: 675

Original Poster
Blog Entries: 11

Rep: Reputation: 36
Thanks. I went to the links above. I also found the lines for 'User' and 'Group' in the apache2.conf file. Thanks again.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
apache2 + mod-ssl keeps loading the default localhost.xxxxxx cert STEBEL Linux - Newbie 3 11-26-2005 07:49 AM
[Apache2] Localhost can connect to HTTPS, but not clients in the LAN Akhran Linux - Newbie 3 09-12-2005 05:13 PM
Apache2 debian sarge: browser can't connect to the localhost blueheart Linux - Software 5 07-15-2005 11:12 AM
Message from syslogd@localhost localhost kernel: Disabling IRQ #21 ylts Linux - Hardware 0 02-26-2005 08:01 AM
[apache2] could not connect to host localhost LordFrancis Linux - Networking 1 09-30-2004 02:37 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Debian

All times are GMT -5. The time now is 12:50 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration