Localhost subdomain set up on ubuntu not working

5,092

Solution 1

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!

Solution 2

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:
5,092

Related videos on Youtube

Paolo Irrera
Author by

Paolo Irrera

Learning a lot of stuff

Updated on September 18, 2022

Comments

  • Paolo Irrera
    Paolo Irrera almost 2 years

    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?

  • Paolo Irrera
    Paolo Irrera over 12 years
    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 :-(