Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game. |
Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
|
12-21-2004, 06:08 PM
|
#1
|
Member
Registered: Oct 2004
Distribution: RedHat Fedora core 2
Posts: 35
Rep:
|
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.
|
|
|
12-22-2004, 03:30 AM
|
#2
|
Member
Registered: May 2003
Location: Canada
Distribution: Fedora 13
Posts: 49
Rep:
|
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.
|
|
|
12-22-2004, 05:08 PM
|
#3
|
Member
Registered: Oct 2004
Distribution: RedHat Fedora core 2
Posts: 35
Original Poster
Rep:
|
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.
|
|
|
12-22-2004, 05:21 PM
|
#4
|
Member
Registered: May 2003
Location: Canada
Distribution: Fedora 13
Posts: 49
Rep:
|
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
|
|
|
12-23-2004, 01:32 AM
|
#5
|
Member
Registered: Oct 2004
Distribution: RedHat Fedora core 2
Posts: 35
Original Poster
Rep:
|
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.
|
|
|
12-23-2004, 02:11 AM
|
#6
|
Member
Registered: May 2003
Location: Canada
Distribution: Fedora 13
Posts: 49
Rep:
|
Quick question: are you serving virtual hosts or no?
|
|
|
12-23-2004, 05:59 AM
|
#7
|
Member
Registered: Nov 2004
Location: Brisbane, Australia
Distribution: Fedora Core 5
Posts: 89
Rep:
|
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..
|
|
|
12-26-2004, 12:37 AM
|
#8
|
Member
Registered: Oct 2004
Distribution: RedHat Fedora core 2
Posts: 35
Original Poster
Rep:
|
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.
|
|
|
12-26-2004, 03:00 AM
|
#9
|
Member
Registered: Nov 2004
Location: Brisbane, Australia
Distribution: Fedora Core 5
Posts: 89
Rep:
|
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.
|
|
|
12-26-2004, 11:07 AM
|
#10
|
Member
Registered: Oct 2004
Distribution: RedHat Fedora core 2
Posts: 35
Original Poster
Rep:
|
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.
|
|
|
All times are GMT -5. The time now is 06:33 PM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|