Setting up a Web Directory for a User

Posted on 2004-11-30
Last Modified: 2012-05-05
Hi Linux friends,

I would like to set up web directories for the users in my Linux server.  I already have Apache running.  Am I supposed to create a "homepage" directory in the user's home directory and access the web directory with http://localhost/~username ?  Please advise.

Thank you so much,

Jazon from Jacksonville, FL
Question by:piratepatrol
    LVL 18

    Assisted Solution

    You need to use mod_userdir

    Most default apache installations have this set up properly.  There will need to be a directory, often called public_html, in the user's home directory, then yes, /~username/ .
    LVL 38

    Accepted Solution


       Here is my /etc/httpd/conf/httpd.conf for your reference:
    <Directory /home/*/public_html>     <=========== the path may vary
         AllowOverride FileInfo AuthConfig Limit
         Options MultiViews Indexes SymLinksIfOwnerMatch IncludesNoExec
             Order allow,deny
             Allow from all
         <LimitExcept GET POST OPTIONS PROPFIND>
             Order deny,allow
             Deny from all
    UserDir /home/*/public_html     <=== path may vary
    UserDir disabled
    UserDir enabled piratepatrol  <=== add your users here

        So users put their homepages under ~username/public_html, then you can browse them through


    LVL 1

    Assisted Solution

    Yes, however, permissions into the directory tree need to be set so that other has execute.

    chmod o+x /home/<user>
    chmod o+x /home/<user>/public_html

    If other doesn't have execute on the directory then apache can't descend into it to look for files.

    Anything in the public_html tree needs to also be o+r for permissions.
    LVL 3

    Author Comment

    You guys are so helpful.  Thank you so much.  150 points for each of you.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    IT, Stop Being Called Into Every Meeting

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Setting up Secure Ubuntu server on VMware 1.      Insert the Ubuntu Server distribution CD or attach the ISO of the CD which is in the “Datastore”. Note that it is important to install the x64 edition on servers, not the X86 editions. 2.      Power on th…
    Linux users are sometimes dumbfounded by the severe lack of documentation on a topic. Sometimes, the documentation is copious, but other times, you end up with some obscure "it varies depending on your distribution" over and over when searching for …
    Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
    Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.

    759 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    10 Experts available now in Live!

    Get 1:1 Help Now