Find the answer to your Linux question:
Results 1 to 8 of 8
I am a newbie to linux and in particular working with apache and server side software and have a problem configuring virtual hosts. I added entries to the hosts file ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    May 2010
    Posts
    11

    virtual hosts error/ NameVirtualHost *:80 has no VirtualHosts


    I am a newbie to linux and in particular working with apache and server side software and have a problem configuring virtual hosts.

    I added entries to the hosts file to reflect the virtual sites I want to run on the server


    Following a college tutorial I opened /etc/apache2/sites-available and renamed the default file as default.old and created a document named default and inserted the following

    NameVirtualHost 192.168.40.138

    <VirtualHost 192.168.40.138>
    *** ServerAdmin webmaster"site1.com
    *** DocumentRoot /var/www/
    *** ServerName 192.168.40.138
    <Directory /var/www/>
    *** *** Options Indexes FollowSymLinks Multiviews +Includes
    *** *** AllowOverride None
    *** *** Order allow,deny
    *** *** XBitHack On
    *** </Directory>
    </VirtualHost>

    ##Entry for site1.com
    <VirtualHost 192.168.40.138>
    *** ServerAdmin webmaster"site1.com
    *** DocumentRoot /var/www/site1.com
    *** ServerName site1.com
    </VirtualHost>

    ##Entry for site2.com
    <VirtualHost 192.168.40.138>
    *** ServerAdmin webmaster"site2.com
    *** DocumentRoot /var/www/site2.com
    *** ServerName site2.com
    </VirtualHost>

    The next step is to run apache2ctl graceful and after I do I get the error message of [Mon Jan 17 11:08:37 2011] [warn] NameVirtualHost *:80 has no VirtualHosts

    Anyone got any suggestions, help would be appreciated.

    For the purpose of posting with less than 15 posts I had to change *** ServerAdmin webmaster"site2.com and replace the @ with a " to be able to post.

  2. #2
    Trusted Penguin Irithori's Avatar
    Join Date
    May 2009
    Location
    Munich
    Posts
    3,377
    Add a :80 to NameVirtualHost and all the VirtualHosts.
    aka:
    NameVirtualHost 192.168.40.138:80
    <VirtualHost 192.168.40.138:80>

    Also, grep for conflicting NameVirtualHosts directives.

    On a side note:
    Is it intended, that the files of *all* sites are available via the first host?
    Depending on the environment/use case this is a security hole.
    You must always face the curtain with a bow.

  3. #3
    Just Joined!
    Join Date
    May 2010
    Posts
    11
    Quote Originally Posted by Irithori View Post
    Add a :80 to NameVirtualHost and all the VirtualHosts.
    aka:
    NameVirtualHost 192.168.40.138:80
    <VirtualHost 192.168.40.138:80>

    Also, grep for conflicting NameVirtualHosts directives.

    On a side note:
    Is it intended, that the files of *all* sites are available via the first host?
    Depending on the environment/use case this is a security hole.
    Thanks for the reply, I followed your advice and added :80 to NameVirtualHost and all the VirtualHosts. After running apache2ctl graceful I am still getting the [Mon Jan 17 11:45:53 2011] [warn] NameVirtualHost *:80 has no VirtualHosts.

    It is a test, security isn't an issue at the moment to be honest I just want to learn how to set up and run a basic server then try more intensive things like security and monitoring server usage.

  4. #4
    Trusted Penguin Irithori's Avatar
    Join Date
    May 2009
    Location
    Munich
    Posts
    3,377
    Did you grep for conflicting NameVirtualHost ?

    Another thing, the "***" indicate white spaces, not actually "***"?
    You must always face the curtain with a bow.

  5. #5
    Just Joined!
    Join Date
    May 2010
    Posts
    11
    Quote Originally Posted by Irithori View Post
    Did you grep for conflicting NameVirtualHost ?

    Another thing, the "***" indicate white spaces, not actually "***"?
    Yeah the *** represent blank spaces.

    What is grep for conflicting NameVirtualHost ?

  6. #6
    Trusted Penguin Irithori's Avatar
    Join Date
    May 2009
    Location
    Munich
    Posts
    3,377
    cd /etc/apache2
    grep -ri namevirtualhost *
    You must always face the curtain with a bow.

  7. #7
    Just Joined!
    Join Date
    May 2010
    Posts
    11
    Quote Originally Posted by Irithori View Post
    cd /etc/apache2
    grep -ri namevirtualhost *
    Do I run the command, grep -ri namevirtualhost * in the terminal after moving to the /etc/apache2 directory?

    If so, I did that and nothing seemed to take place, and I had to press control and c to end the process.

  8. #8
    Trusted Penguin Irithori's Avatar
    Join Date
    May 2009
    Location
    Munich
    Posts
    3,377
    That grep will search all files for namevirtualhost recursively and case-insensitive.
    And yes, change to /etc/apache2 before.

    The grep should come back almost instantly, as the amount of files in that apache configdirectory is usually fairly small.
    You must always face the curtain with a bow.

Posting Permissions

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