Find the answer to your Linux question:
Results 1 to 7 of 7
hello everyone, first post...be nice Okay, I'm having difficulty running virtual hosting on my localhost machine. I am running Apache 1.3 as a standalone on SuSE 8.2. I have edited ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Apr 2004
    Posts
    3

    Virtual Hosts on localhost, SSL


    hello everyone,

    first post...be nice

    Okay, I'm having difficulty running virtual hosting on my localhost machine. I am running Apache 1.3 as a standalone on SuSE 8.2. I have edited httpd.conf by hand and used webmin in an attempt.

    I have tried several directives and configurations, but can't get it to work....maybe I am missing something.

    ServerName myserver.myserver.com

    NameVirtualHost *

    <VirtualHost _default_:*>

    ServerName test.myserver.com
    DocumentRoot /home/myaccount/www

    </VirtualHost>

    When I run apache and go to 'http://localhost', the pages from /home/myaccount/www appear. However, test.myserver.com is 'not found'. Nothing in the error_log either.....Any ideas? Is there something preventing me from running virtual hosts?

    I assume i should be able to run SSL virtual hosts in the same manner when I figure this out (assuming mod_ssl is good-to-go and I only have one virtual host with SSL and have my keys).

    Many thanks!!!

  2. #2
    Linux Engineer Giro's Avatar
    Join Date
    Jul 2003
    Location
    England
    Posts
    1,219
    You are missing the ServerAlias try this
    Code:
    <VirtualHost *>
        ServerName name
        ServerAlias www.mydomain.com
        DocumentRoot /my/web/root
    </VirtualHost>

  3. #3
    Just Joined!
    Join Date
    Apr 2004
    Posts
    3
    Hey,

    This is really odd that I''m not able to get this working....it appears (and I'm sure it is) quite simple.

    I wasn't really looking for an alias (though, well, I suppose I will be needing those too), but rather running multiple virutal hosts (e.g. test.mydomain.com, secure.mydomain.com, www.mydomain.com). Why would the directives below not work? Are there any other very basic configs that would work? I tried the ones in the original httpd.conf, but it doesn't seem to work either.

    My host name is myserver.mydomain.com

    ---from httpd.conf-----

    ServerName myserver.mydomain.com

    NameVirtualHost *

    <VirtualHost *>
    ServerName test.mydomain.com
    DocumentRoot /path/to/my/site
    </VirtualHost>
    ------------------
    Should I replace the * and ServerName with 'localhost'? With my IP? With 127.0.0.1?

    I just tried again with and without name-based.....ugh. the simple stuff always gets me. Lost in this case....shouldn't this be simple? Or, is it something about running on localhost? i though an http request could come from anywhere and served anywhere?

    No errors. When accessing the page, I get the classic 'host not found' error.

    thanks in everyone.

  4. #4
    Linux Engineer Giro's Avatar
    Join Date
    Jul 2003
    Location
    England
    Posts
    1,219
    Did you try the above method i posted?

  5. #5
    Just Joined!
    Join Date
    Apr 2004
    Posts
    3
    Yeah, sorry....I did that too.

    ----from httpd.conf
    ServerName myserver.mydomain.com

    NameVirtualHost *

    <VirtualHost *>
    ServerName myserver #with and without domain
    ServerAlias test #with and without domain
    DocumentRoot #this always appears when i run on 'localhost'
    </VirtualHost *>
    ----------------

    I am truly puzzled why this isn't working. Apache is picking up the document root, but the servername nor the serveralias are working for some reason. I'll also want to run several virtual hosts in the future.

    Could it be a firewall or networking issue? Maybe firewally because this is running on localhost....

    This is odd...I must be missing something....I have all the basics from the sample httpd.conf file too...nothing fancy. Anyway, don't break your back over it.

    thanks for the help mate!

  6. #6
    Linux Engineer Giro's Avatar
    Join Date
    Jul 2003
    Location
    England
    Posts
    1,219
    My first idea is are you using a fake domain name? Or are you using a FQDN(Fully Qulifyed Domain Name)? If you are using the latter you will need to point the domain towards your IP if its the prior the easy way is to add the entry to your hosts file like so.
    Code:
    192.168.1.2    www.myfakedomain.com
    Edit :- Forgot to metion the reason I said use ServerAlias is that HTTP/1.0 does not send the host: field with the get request which is what ServerName expects.

  7. #7
    Linux Newbie
    Join Date
    Apr 2004
    Posts
    158
    NameVirtualHost *:80

    <VirtualHost *:80>

    ServerName test.myserver.com
    DocumentRoot /home/myaccount/www

    </VirtualHost>

    Then it should work...

    Try "httpd -S" from the command line and post the result if you would...

    //jonas

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •