Take the 2-minute tour ×

First of all, I'm on ubuntu 12.10 and running latest apache patch. I know how to access the default localhost directory of my server from other computers. When I type in 192.168.1.** in a different computer, I can access the /var/www/ directory.

But what if I want to appoint that to a different directory? Where and how do I modify it? hosts, conf.d etc? And how can I access it with a domain name instead of the IP? Thanks ahead.

share|improve this question
192.168.1.** isn't localhost. localhost is specifically defined as Your 192.168.1.** is a local network IP address, which is not the same thing at all. –  Ken White Jan 24 '13 at 0:14
yes, I meant'the localhost directory of my server' from another computer. –  lovetostrike Jan 24 '13 at 1:52

1 Answer 1

up vote 1 down vote accepted

Look in /etc/apache2/sites-available. You will most likely find a file named default and another named default-ssl. The DocumentRoot can be changed within this file. Remember to restart Apache...

sudo service apache2 restart


sudo apache2ctl graceful


sudo /etc/init.d/apache2 reload

It's not unusual to have several virtual hosts listed in sites-available, and remember that these configs have to have symbolic links in sites-enabled in order to be seen by Apache.

A Virtual Host file looks something like this...

Listen 80
<VirtualHost *:80>
    DocumentRoot /www/example1
    ServerName www.example.com

    # Other directives here

Further reading: Apache Documentation - Virtual Hosts

share|improve this answer
thanks, it works. What about 'And how can I access it with a domain name instead of the IP? Thanks ahead.'? It's only for my local network. –  lovetostrike Jan 24 '13 at 1:40
If you want to use a domain name, then you need to register one. You can create a fake domain name (i.e. local.myawesomeserver) but you'll only be able to use it after editing your hosts file and assigning your IP address to it, and that will only work for any machine that has an edited hosts file. –  Gordon Freeman Jan 24 '13 at 1:43
that clarifies many things. so I just need to register the ip and domain in the hosts file on clients. cool :) –  lovetostrike Jan 24 '13 at 2:18

Your Answer


