Sunday, March 21, 2010

Activating the User's public_html Directory with userdirectory (Using Apache2 )

Create a directory (folder) called "public_html" in your home directory, with your file browser or the command below. Do NOT use the sudo command.
me@myhost$ mkdir public_html

I have found that on a simple development machine, it is easier to have your work all within your own home directory and not have to worry about permissions and folders owned by the root user. What it gets you is the ability to access your websites in your home directory by a URL in the form http://localhost/~USER_NAME. We can improve upon this with fake domains, but first things first.
There are only two commands you need to enter to activate the User Directory feature, and then one command to reload the configuration files. The last command includes an absolute path, so it doesn't matter where you execute it from. The first two "ln" commands assume you are in the directory /etc/apache2/mods-enabled. What you need to do is create two symbolic links (soft links, symlinks) in the stated directory pointing to the corresponding module in /etc/apache2/mods-available. So, if "$" is your prompt,
 
me@myhost$ cd /etc/apache2/mods-enabled
me@myhost$ sudo ln -s ../mods-available/userdir.conf userdir.conf
me@myhost$ sudo ln -s ../mods-available/userdir.load userdir.load
me@myhost$ sudo /etc/init.d/apache2 restart

On your home system, restarting apache will give you a warning "apache2:

3 comments:

  1. Don't you require change in permission of some folders?

    ReplyDelete
  2. yes , we can change permission for userdirectory and public_html.

    ReplyDelete