Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I ask my question first and below are details of what I have so far trying to solve the thing:

On Apache running on localhost, I want to have different virtual hosts that would be accessible through url: http://name-of-the-virtual-host.name-of-the-machine/

Details:

So I have Apache running on port 8080 of my laptop. Linux Mint, so Debian distro. Everything is in local for testing purposes, so no DNS involved! The IP address I use is 127.0.1.1 which has the domain of my computer, called fabjoa. On the file /etc/apache2/apache2.conf, I've put:

ServerName fabjoa

In the file /etc/hosts, there is indeed the line

127.0.1.1 fabjoa

In the file /etc/apache2/ports.conf

NameVirtualHost *:8080
Listen 8080

Now, the conf file of my virtual host. The file is called is goyahkla and is located on /etc/apache2/sites-available/ and has a symbolic link in /etc/apache2/sites-enabled. On this file, I have the following:

<VirtualHost *:8080>
 ServerName goyakhla.fabjoa
 ServerAdmin webmaster@localhost
 DocumentRoot /var/sites/goyahkla

....

<Directory /var/sites/goyahkla/>
  Options Indexes FollowSymLinks MultiViews
  AllowOverride All
  Order allow,deny
  allow from all
 </Directory>

...

</VirtualHost>

Running apache2ctl configtest gives me Syntax OK. Now, on browser, opening http://fabjoa:8080/ does point to the Virtual Host goyahkla (beacause that's the only one I have), but http://goyahkla.fabjoa:8080 is not found. Other debugging:

telnet goyahkla.fabjoa:8080
telnet: could not resolve goyahkla.fabjoa:8080/telnet: Name or service not known

lynx goyahkla.fabjoa:8080
Looking up  'goyahkla.fabjoa' first
Looking up  'www.goyahkla.fabjoa.com', guessing...

Looking up goyahkla.fabjoa first
Looking up www.goyahkla.fabjoa.com, guessing...
Looking up www.goyahkla.fabjoa.com:8080
Making HTTP connection to www.goyahkla.fabjoa.com:8080
Alert!: Unable to connect to remote host.

lynx: Can't access startfile http://www.goyahkla.fabjoa.com:8080/ 

Any idea on how purpose could be achieved?

share|improve this question
add comment

2 Answers

I have to create new entries in /etc/hosts for each virtual host.

For example, I've added the following line:

127.0.2.1 goyahkla

Which allows me to access it through

http://goyahkla/
share|improve this answer
add comment

What you're looking for is a 127.0.1.1 *.fabjoa style syntax in your hosts file. Unfortunately, the hosts file doesn't support this. You'd have to use DNS for that or enter each one individually like you mentioned above.

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.