Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I have installed apache web server and I need to point 127.1.1.1 with alias (www.someaddress.lan) to local apache. What is the proper way to do it? How to point someaddress.lan to default apache page and www.someaddress.lan to /var/www/wordpress/?

share|improve this question
add comment

2 Answers 2

If you want to do without installing any kind of DNS server in your machine, then you can put an entry into /etc/hosts file.

 127.1.1.1    www.someaddress.lan    someaddress.lan

Actually ever host before resolving the domain name by contacting its DNS server, first checks its own /etc/hosts file. If it founds that domain entry in that file, it doesn't contact its DNS server.

EDIT: You have to add entries for each in /etc/apache2/sites-enabled/000-default

<VirtualHost *>
   ServerName    someaddress.lan
   DocumentRoot  /var/www/html
</VirtualHost>

<VirtualHost *>
   ServerName    www.someaddress.lan
   DocumentRoot  /var/www/wordpress
</VirtualHost>

NOTE: Don't forget to restart the apache2 server after changing the above configuration file by the following command:

$ sudo /etc/init.d/apache2 restart

share|improve this answer
    
Thanks! How to point someaddress.lan to default apache page and www.someaddress.lan to /var/www/wordpress/? –  RCola Apr 8 '12 at 14:27
add comment

For your hosts file:

127.1.1.1     someaddress.lan www.someaddress.lan

By the way, don't you mean 127.0.0.1? That is the loopback ip address for localhost. If so, use the following:

127.0.0.1     someaddress.lan www.someaddress.lan localhost.localdomain localhost

Then you need to edit your apache server config file. Usually /etc/httpd/conf/httpd.conf That is where you associate sub domains (Virtual Hosts) with directories containing the content the apache server serves.

Apache Name Based Virtual Hosts

NameVirtualHost *:80

<VirtualHost *:80>
ServerName www.someaddress.lan
ServerAlias www.someaddress.lan
DocumentRoot /var/www/wordpress
</VirtualHost>

<VirtualHost *:80>
ServerName someaddress.lan
ServerAlias someaddress.lan
DocumentRoot /var/www/html
</VirtualHost>
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.