Thursday, January 03, 2008

the userdir apache module

By default, the apache webroot, in ubuntu, or most distro. Is in /var/www. Which is not really a big deal, except, it's a pain to finish writing a php script, then as root, or sudo to cp to /var/www.
If it's just a server, it's perfectly fine, for a development machine, it's a pain.

On the other hand. There is a userdir, module in apache. What it does basically, is it enable you to put your file in your home directory, then apache will serve the file there. By default, apache will search in /home/youraccount/public_html, or /home/useraccount/www or /usr/www. To access the file, you just need to call by http://yourserveraddress/~youraccount, with a browser.

To make it easy for me to write stuff into, i just use the form in my home directory. The implication is that, you can redirect your ide to use the directory as your work space.

To do it on ubuntu, inside, /etc/apache2 have a mods-available directory, another is mods-enabled directory. The former is the modules available, the latter is just a symbolic links, to the modules in mods-available.

To enable userdir, in /etc/apache2
run the following in a shell
sudo ln -s mods-available/userdir.load mods-enabled/
sudo ln -s mods-available/userdir.conf mods-enabled/
and don't forget to create, public_html in your home directory.
to test it just call your browser direct to http://localhost/~yourusername

Or do it properly, we can start a small web hosting business
, or have friends to share a web space, on your server. etc.

No comments:

Post a Comment