LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 12-21-2004, 06:08 PM   #1
r_squared
Member
 
Registered: Oct 2004
Distribution: RedHat Fedora core 2
Posts: 35

Rep: Reputation: 15
Arrow Setting up user directorys with apache


I am trying to set up an apache web server so that when I type in the URL/username I will get the content from the users home directory (no sub directory e.g. /home/user/index.htm)
I added the line 'userdir /' in the httpd.conf file; is there something else I need to do also? I am running red hat fc 2 with apache version: 2.0.49 Thanks in advance r^2

Last edited by r_squared; 12-21-2004 at 06:12 PM.
 
Old 12-22-2004, 03:30 AM   #2
peteABK
Member
 
Registered: May 2003
Location: Canada
Distribution: Fedora 13
Posts: 49

Rep: Reputation: 15
Look for tag like this int the conf

Code:
<IfModule mod_userdir.c>
and change
UserDir disable
to
UserDire enable

also change
#UserDir public_html
to
UserDir public_html

know when you make a new user make sure they are a member of the apache group and, as that user make a directory called "public_html" save all your website stuff in their and your off.

Just a side note, the conf comments discourage doing this because it confirms user names on your system which can be a security risk.
 
Old 12-22-2004, 05:08 PM   #3
r_squared
Member
 
Registered: Oct 2004
Distribution: RedHat Fedora core 2
Posts: 35

Original Poster
Rep: Reputation: 15
Ok I have it working... well some what. I had to use the directive UserDir /home instead of UserDir /. That fixed that problem but now when I type the username in the address bar e.g. server.com/~user I get a message saying that it is forbidden. This is what part of my configuration file looks like:


<IfModule mod_userdir.c>
#
# UserDir is disabled by default since it can confirm the presence
# of a username on the system (depending on home directory
# permissions).
#
UserDir disabled root

#
# To enable requests to /~user/ to serve the user's public_html
# directory, remove the "UserDir disable" line above, and uncomment
# the following line instead:
#
UserDir /home

</IfModule>

#
<Directory /home/*>
AllowOverride None
Allow from all
</Directory>

I added the <Directory /home/*> tags after I received the forbidden message and restarted apache but it still gives me the same message.
 
Old 12-22-2004, 05:21 PM   #4
peteABK
Member
 
Registered: May 2003
Location: Canada
Distribution: Fedora 13
Posts: 49

Rep: Reputation: 15
I think you replace
UserDir disable root
with
#UserDir disable root

I don't think you even need the "root", root's $HOME is /root and Apache isn't allowed to read there

Apache will look in the $HOME folder of each user on you system in /home/username
so when you add "/home" to UserDir, Apache looks for "/home/username/home", the most common solution is to have:

UserDir public_html

"public_html" is just a folder in the user's home directory that Apache can read. It's good to limit Apache's access to a specific folder in the user's home directory because then the user can still have files that are not readable by everyone looking at their website, such as logs and so on. Hope this helps
 
Old 12-23-2004, 01:32 AM   #5
r_squared
Member
 
Registered: Oct 2004
Distribution: RedHat Fedora core 2
Posts: 35

Original Poster
Rep: Reputation: 15
Ok I changed the Userdir option to public_html now, but I am still getting the 403 forbidden error message. What can I do to so apache displays the contents insead of saying it's forbidden. Also on a related matter I am trying to get the cgi module to work correctly. I have the following typed in my httpd.conf file:

ScriptAlias /cgi-bin/ "/var/www/cgi-bin/"

#
# "/var/www/cgi-bin" should be changed to whatever your ScriptAliased
# CGI directory exists, if you have that configured.
#
<Directory "/var/www/cgi-bin">
AllowOverride None
Options none
Order allow,deny
Allow from all
</Directory>

Everytime I type in a simple cgi script into the browser I get an "internal server error" message. The script is very simple this is it:

#!/bin/bash
echo "<html><head>"
echo "<title>some title</title>"
echo "<body> somebody </body></html>"


now obviously this is a shell script, so I typed in ./filename.cgi at the command promt to test it out and it works fine. Although I keep getting an internal server error. I tryed looking at the error logs but for some reason they are written in some forein language.
 
Old 12-23-2004, 02:11 AM   #6
peteABK
Member
 
Registered: May 2003
Location: Canada
Distribution: Fedora 13
Posts: 49

Rep: Reputation: 15
Quick question: are you serving virtual hosts or no?
 
Old 12-23-2004, 05:59 AM   #7
Butt-Ugly
Member
 
Registered: Nov 2004
Location: Brisbane, Australia
Distribution: Fedora Core 5
Posts: 89

Rep: Reputation: 15
If you are running SELinux in enforcing mode, you will get 403 on user dirs..

Type "setenforce 0" to disable, and "setenforce 1" to re-enable..

See this guide: http://www.brennan.id.au/13-Apache_Web_Server.html

SELinux for httpd can be disabled in "system-config-securitylevel"

Miles..
 
Old 12-26-2004, 12:37 AM   #8
r_squared
Member
 
Registered: Oct 2004
Distribution: RedHat Fedora core 2
Posts: 35

Original Poster
Rep: Reputation: 15
Ok I typed in the following command "setenforce 0" and I got the following message: setenforce: setenfore() failed. Then I checked my /etc/sysconfig/selinux file and it says that selinux is disabled. also I changed the public_html folder to file permission 777. I am confused why it is giving me the 403 error. I can email or post my entire httpd.conf file if someone wants it.
p.s I am not serving virtual hosts.
 
Old 12-26-2004, 03:00 AM   #9
Butt-Ugly
Member
 
Registered: Nov 2004
Location: Brisbane, Australia
Distribution: Fedora Core 5
Posts: 89

Rep: Reputation: 15
You need the following minimum permissions..

Directories
chmod 701 /home/bob
chmod 705 /home/bob/public_html
chmod 705 /home/bob/public_html/cgi-bin

Files
chmod 604 /home/bob/public_html/*.html
chmod 705 /home/bob/public_html/cgi-bin/*.cgi

Most people miss the first one..

You can set 'group' permissions if you want, but probably best not to.


Miles

PS.. If that fails then post a link to your httpd.conf file.
 
Old 12-26-2004, 11:07 AM   #10
r_squared
Member
 
Registered: Oct 2004
Distribution: RedHat Fedora core 2
Posts: 35

Original Poster
Rep: Reputation: 15
Thanks man, that did the trick. I guess I over looked the previous directory (didn't think to allow access to it).

p.s. and I forgot to add the line "index.htm" to the directoryindex directive.( I had my index file with the .htm extension)

p.s.s. oh I just changed my file permissions back to normal and it turns out that I just needed to add the "index.htm" line to my directoryindex directive. but I still appreciate your help.

Last edited by r_squared; 12-26-2004 at 11:14 AM.
 
  


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
user home directorys can't be accessed anymore r_squared Linux - General 1 01-04-2005 09:35 PM
adding directorys to apache karupt Linux - Networking 2 08-12-2004 02:49 PM
Apache Webserver 403 Forbidden Errors (User not in apache group?) Mankind75 Mandriva 4 07-08-2004 06:30 AM
copy directorys Luc Linux - Newbie 4 11-05-2002 03:12 AM
Protecting directorys antken Linux - Security 3 07-30-2002 10:01 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 06:33 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