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.

In my pc (running on Ubuntu) , I have configured apache and php. I wanted to create a subdomain 'mysite.localhost' on my localhost

I have a folder /var/www/mysite Which I would like to access like http://mysite.localhost/

I followed the steps in http://thinkingnectar.com/2008/getting-ubuntu-to-work-creating-subdomain-in-localhost/

Basically did the following

Edited /etc/host and added the following line

  127.0.0.1 mysite.localhost

Created a new configuration file in /etc/apache2/sites-available/mysite using

gksudo gedit /etc/apache2/sites-available/mysite

<VirtualHost *:80>
    DocumentRoot /var/www/mysite
    ServerName mysite.localhost

    <Directory /var/www/mysite>
        Options Indexes FollowSymLinks MultiViews +Includes
        AllowOverride all
        Order allow,deny
        allow from all
    </Directory>
</VirtualHost>

Saved the file, and run the following:

sudo a2ensite mysite

Finally restarted the Apache Server.

sudo /etc/init.d/apache2 restart

But on browsing http://mysite.localhost/ I get this message

" Network Error (dns_unresolved_hostname) .Your requested host "mysite.localhost" could not be resolved by DNS. "

Can anyone suggest what could be going wrong?

share|improve this question

migrated from stackoverflow.com Nov 30 '11 at 11:26

This question came from our site for professional and enthusiast programmers.

add comment

4 Answers

Everything seems to be okay. Please double check following entries in their respective files.

127.0.0.1 mysite.localhost

ServerName mysite.localhost
share|improve this answer
    
did check..Everything appears to be as it should . –  Annibigi Nov 30 '11 at 10:17
add comment

I have a couple of suggestions that might help, but these are just "shots in the dark" since I don't have access to a system right now that I can set up with a similar situation to yours for testing.

  1. If you had your browser running prior to editing /etc/hosts, then restart your browser. That should allow it to pick up changes to your hosts file.
  2. In your question, you state that you want to serve your mysite files from /var/www/mysite, but in your Apache config file, you specify that the directory will be served from DocumentRoot /home/username/mysite/. One of the two needs to change; either your expectation that the files will come from /var/www/mysite, or the DocumentRoot must be set to /var/www/mysite (and correspondingly, the <Document ...> declaration must then change as well.)

If neither of these work, then you should also try pinging the system to make sure it's responding correctly, as in the following:

$ ping mysite.localhost
ping: unknown host mysite.localhost

$ sudo vi /etc/hosts
(/etc/hosts now reads:
127.0.0.1   localhost mysite.localhost)

$ ping mysite.localhost
PING localhost (127.0.0.1) 56(84) bytes of data.
64 bytes from localhost (127.0.0.1): icmp_req=1 ttl=64 time=0.044 ms
64 bytes from localhost (127.0.0.1): icmp_req=2 ttl=64 time=0.037 ms
share|improve this answer
    
you are right about correcting the document root directory path.I checked the path I have set and it is indeed pointing to the correct path (I made a typo while asking the question,i'm going to correct it).About pining the subdomain, that works too. but simply cannot browse the url mysite.localhost :-( –  Annibigi Dec 1 '11 at 6:11
add comment
up vote 0 down vote accepted

I resolved this issue. Apparently, there is nothing wrong with the sub-domain creation process. I could not access the page because of some proxy settings. I bypassed all proxy settings for localhost, 127.0.0.1 (to do this in Ubuntu: go to browser Edit>Preferences>Advance>Network >Settings tab and set localhost, 127.0.0.1 for No proxy field ) And now it works!

share|improve this answer
add comment

Make sure you have added localhost and 127.0.0.1 entries in proxy server ,

Path: google chrome-->settings--> Show advanced settings--> Change proxy settings--> lan settings --> proxy server/advanced/ and add entries in the Exceptions box.

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.