Saturday, July 21, 2007

how to set a virtual host directory in apache2

open your terminal konsole

create a directory

unos@xoxo:~$ mkdir virtual

define your host for the directory

unos@xoxo:~$ sudo nano /etc/hosts
127.0.0.1 localhost
127.0.0.2 virtual

# The following lines are desirable for IPv6 capable hosts
::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts

define your virtual path in the apache httpd.conf

unos@xoxo:~$ sudo nano /etc/apache2/httpd.conf
NameVirtualHost 127.0.0.2:80

"<"VirtualHost 127.0.0.2:80">"
ServerName virtual
DocumentRoot /home/unos/virtual
"<"Directory /home/unos/virtual">"
AllowOverride All
Options Indexes SymLinksIfOwnerMatch IncludesNoExec
"<"/Directory">"
"<"/VirtualHost">"

then restart your apache2

unos@xoxo:~$ sudo /etc/init.d/apache2 restart

open your browser and just type virtual and it will direct you to your site
till then :">

notes:please ignore the double-quote..im putting it there because blogspot does not recognize < symbol

No comments: