Search the web
Sign In
New User? Sign Up
lucknow-lug · Uttar Pradesh Linux Users Group
? Already a member? Sign in to Yahoo!

Yahoo! Groups Tips

Did you know...
Want your group to be featured on the Yahoo! Groups website? Add a group photo to Flickr.

Best of Y! Groups

   Check them out and nominate your group.
Having problems with message search? Fill out this form to ensure your group is one of the first to be migrated to the new message search system.

Messages

  Messages Help
Advanced
apache - allow users to share their web pages in ~user/public_html   Message List  
Reply | Forward Message #138 of 247 |
This tutorial is for configuring apache to allow users to share their
web pages in ~user/public_html directory.
I configured it on Debian and Redhat Enterprise 4 (RHEL4), Fedora
Core4. The second implementation is to password protect a web directory.
In RHEL and FC4 you may have to put a little more effort due to
SELinux Policy in case you enabled it and.
First step is to configure your apache configuration file i.e.
/etc/httpd/conf/httpd.conf

Open apache configuration file in your favorite text editor and locate
following lines,

<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 disable
#
# 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 public_html

</IfModule>
Now for allowing password protection in users public_html directory
uncomment the follwing lines:

<Directory /home/*/public_html>
AllowOverride FileInfo AuthConfig Limit
Options MultiViews Indexes SymLinksIfOwnerMatch IncludesNoExec
<Limit GET POST OPTIONS>
Order allow,deny
Allow from all
</Limit>
<LimitExcept GET POST OPTIONS>
Order deny,allow
Deny from all
</LimitExcept>
</Directory>

restart or start apache service with
[root@fedora]/etc/init.d/httpd restart
make it start automatically after boot (RHEL/FEDORA)
[root@fedora]chkconfig httpd on

Now your apache is configured to share web pages in public_html
directory of a user .

In case of using debian users have to create a public_html direcory
with permissions set to 755
chmod 755 ~user/public_html

In case you are using Redhat Enterprise4 or Fedora Core4 or above and
SELinux policy is enabled then you have to take few more steps for
making it work.
To check whether it is enabled or disabled you can do two things:

[root@fedora ~]# cat /etc/selinux/config
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
# enforcing - SELinux security policy is enforced.
# permissive - SELinux prints warnings instead of enforcing.
# disabled - SELinux is fully disabled.
SELINUX=enforcing
# SELINUXTYPE= type of policy in use. Possible values are:
# targeted - Only targeted network daemons are protected.
# strict - Full SELinux protection.
SELINUXTYPE=targeted

as you can see my selinux is enabled.

The second method is simple. You can find out about wheter SELinux is
enabled simply by using
command ls -lZ

[anuj@fedora ~]$ ls -dZ public_html
drwxrwxr-x anuj anuj user_u:object_r:user_home_t public_html

4th column is telling about SELinux and if it's security context has
to be changed to share my web pages.

To change the context use command:
[anuj@fedora ~]$ chcon -v --reference /var/www/html/ public_html/
context of public_html/ changed to system_u:object_r:httpd_sys_content_t

now user anuj can share his personal pages in his ~anuj/public_html
directory

To make any directory in public_html or public_html itself
autentication based the steps are

Create a file named .htaccess in directory which you want to make
authentication based.

[anuj@fedora]cd public_html
[anuj@fedora]vi .htaccess

My entried for this file are
AuthName "Please enter user/pass"
AuthType basic
AuthUserFile /path/to/your/password/file
Require user anuj gunjan xavier

now next step is to generate users and passwords
[anuj@fedora ~]$ htpasswd -c .password anuj
New password:
Re-type new password:
Adding password for user anuj

Note: -c is used for creating this file. now for adding next users
[anuj@fedora ~]$ htpasswd .password gunjan
New password:
Re-type new password:
Adding password for user gunjan
[anuj@fedora ~]$

Now .password file is created give the same path to this file in my
.htaccess file pointed to file I created.

Last step is to change the context of file with user/pass
Do this with:
[anuj@fedora ~]$ chcon -v --reference public_html/ .password
context of .password changed to system_u:object_r:httpd_sys_content_t

Now to URL http://server.com/~anuj will ask for a user/pass before
allowing client to access the page.

Thats it ! Simple and easy.
Anuj Singh




Sun Dec 3, 2006 11:53 am

anujsingh_1
Offline Offline

Forward
Message #138 of 247 |
Expand Messages Author Sort by Date

This tutorial is for configuring apache to allow users to share their web pages in ~user/public_html directory. I configured it on Debian and Redhat Enterprise...
anujsingh_1
Offline
Dec 3, 2006
11:53 am
Advanced

Copyright © 2009 Yahoo! Inc. All rights reserved.
Privacy Policy - Terms of Service - Guidelines - Help