Results 1 to 8 of 8

Thread: Can't figure out apache2 VirtualHosts, webserver won't even start

  1. #1
    Join Date
    Oct 2012
    Location
    Sweden
    Beans
    21
    Distro
    Ubuntu 13.10 Saucy Salamander

    Exclamation Can't figure out apache2 VirtualHosts, webserver won't even start

    Hello once again Ubuntu forums, I need help, again.
    This time it's about apache2, and VirtualHosts.

    Going to jump straight into the problem:
    So I want www.derpnet.nu (and just derpnet.nu) to send the visitor to one place, and map.derpnet.nu to another.
    I tried following this guide, only leading to me breaking everything...

    I have no clue what I'm doing wrong, so I'll just paste the configs.

    Code:
    <VirtualHost *:80>
            ServerAdmin derpishcat@derpnet.nu
            ServerName  www.derpnet.nu
            ServerAlias derpnet.nu
    
            # Indexes + Directory Root.
            DirectoryIndex index.html
            DocumentRoot /var/www/website/htdocs/
    
            # CGI Directory
            ScriptAlias /cgi-bin/ /var/www/website/cgi-bin/
            <Location /cgi-bin>
                    Options +ExecCGI
            </Location>
    
    
            # Logfiles
            ErrorLog  /var/www/website/logs/error.log
            CustomLog /var/www/website/logs/access.log combined
    </VirtualHost>
    Code:
    <VirtualHost *:80>
            ServerAdmin derpishcat@derpnet.nu
            ServerName  map.derpnet.nu
            ServerAlias derpnet.nu
    
            # Indexes + Directory Root.
            DirectoryIndex index.html
            DocumentRoot /var/www/map/htdocs/
    
            # CGI Directory
            ScriptAlias /cgi-bin/ /var/www/map/cgi-bin/
            <Location /cgi-bin>
                    Options +ExecCGI
            </Location>
    
    
            # Logfiles
            ErrorLog  /var/www/map/logs/error.log
            CustomLog /var/www/map/logs/access.log combined
    </VirtualHost>
    The error I'm getting:
    Code:
    derpishcat@DerpNet:/etc/apache2/sites-available$ sudo /etc/init.d/apache2 start
     * Starting web server apache2                                                                                                                                          apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1 for ServerName
    [Wed Mar 20 15:08:24 2013] [error] VirtualHost *:80 -- mixing * ports and non-* ports with a NameVirtualHost address is not supported, proceeding with undefined results
    [Wed Mar 20 15:08:24 2013] [error] VirtualHost *:80 -- mixing * ports and non-* ports with a NameVirtualHost address is not supported, proceeding with undefined results
    [Wed Mar 20 15:08:24 2013] [warn] NameVirtualHost *:80 has no VirtualHosts
    Action 'start' failed.
    The Apache error log may have more information.
                                                                                                                                                                     [fail]
    If you need to see any more configs, let me know, I appreciate all help!

    EDIT: Crap, I just realized I misspelled apache2, can a mod rename the thread please?
    Last edited by sandyd; March 20th, 2013 at 04:08 PM.

  2. #2
    Join Date
    Nov 2008
    Location
    Storybrooke
    Beans
    Hidden!
    Distro
    Ubuntu Development Release

    Re: Can't figure out apache2 VirtualHosts, webserver won't even start, help!

    You have a ServerAlias line that is not needed.

    Can you also make sure that you are specifying your ip address in your virtualhosts (don't post the ips here!), so that it looks like

    Code:
    <VirtualHost ip-address-here:80>
    You likely have a
    Code:
    <NameVirtualHost ip-address-here:80>
    which can't be mixed with
    Code:
    <VirtualHost *:80>
    Last edited by sandyd; March 20th, 2013 at 04:13 PM.
    Ubuntu Forums Moderation Staff
    Don't waste your energy trying to change opinions ... Do your thing, and don't care if they like it.

  3. #3
    Join Date
    Oct 2012
    Location
    Sweden
    Beans
    21
    Distro
    Ubuntu 13.10 Saucy Salamander

    Re: Can't figure out apache2 VirtualHosts, webserver won't even start, help!

    Thanks for the reply, while typing this I just figured out one of the problems, I simply had forgot to type in :80 in my virtual.conf (in conf.d)
    Sadly the problem with the server not wanting to start, is remaining.

    Code:
    derpishcat@DerpNet:/etc/apache2$ sudo /etc/init.d/apache2 start
     * Starting web server apache2                                                                                                                                          apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1 for ServerName
    [Wed Mar 20 16:34:04 2013] [warn] NameVirtualHost *:80 has no VirtualHosts
    Action 'start' failed.
    The Apache error log may have more information.
                                                                                                                                                                     [fail]
    I have no idea what to do, I'm just doing trial and error on this, and failed quite hard :/ (The webserver has "just worked" until now, so this is pretty much the first time I actually try do something advanced)

    EDIT: After fighting with this for hours, and finding out that it isn't even working if I copy over the entire default config, I just give up.
    I've had enough of this, and I'll just go back to what I had before, so I can get my website working.
    Last edited by DerpishCat; March 20th, 2013 at 09:48 PM.

  4. #4
    Join Date
    Nov 2006
    Location
    Belgium
    Beans
    3,023
    Distro
    Ubuntu 10.04 Lucid Lynx

    Re: Can't figure out apache2 VirtualHosts, webserver won't even start, help!

    just a couple of hours and you're ready to give up ?

    it's fairly easy.

    the basic config is this :
    Code:
    NameVirtualHost *:80
    
    <VirtualHost *:80>
    ServerName www.domain.tld
    DocumentRoot /www/domain
    </VirtualHost>
    
    <VirtualHost *:80>
    ServerName www.otherdomain.tld
    DocumentRoot /www/otherdomain
    </VirtualHost>
    (straight from http://httpd.apache.org/docs/2.2/vhosts/name-based.html - 0.18 sec google search no need for hours of blind trial and error )

    try and see if you can get the above (adapted for your paths and names) to work. If it doesn't, then give up.

  5. #5
    Join Date
    Mar 2006
    Location
    Williams Lake
    Beans
    Hidden!
    Distro
    Ubuntu Development Release

    Re: Can't figure out apache2 VirtualHosts, webserver won't even start

    I'd suggest you check the logs, as the error message said, they are located in /var/log/apache2

  6. #6
    Join Date
    Oct 2012
    Location
    Sweden
    Beans
    21
    Distro
    Ubuntu 13.10 Saucy Salamander

    Re: Can't figure out apache2 VirtualHosts, webserver won't even start

    Quote Originally Posted by koenn View Post
    just a couple of hours and you're ready to give up ?

    it's fairly easy.

    the basic config is this :
    Code:
    NameVirtualHost *:80
    
    <VirtualHost *:80>
    ServerName www.domain.tld
    DocumentRoot /www/domain
    </VirtualHost>
    
    <VirtualHost *:80>
    ServerName www.otherdomain.tld
    DocumentRoot /www/otherdomain
    </VirtualHost>
    (straight from http://httpd.apache.org/docs/2.2/vhosts/name-based.html - 0.18 sec google search no need for hours of blind trial and error )

    try and see if you can get the above (adapted for your paths and names) to work. If it doesn't, then give up.
    Oh crap, was I supposed to add stuff into httpd.conf? I thought I were supposed to make files in sites-available and then link them...
    Urgh, I'll try this and then return...

    EDIT:
    I edited httpd.conf, the stuff marked with bold is the newly added stuff.
    Code:
    NameVirtualHost *:80
    
    <VirtualHost *:80>
    ServerName www.derpnet.nu
    DocumentRoot /var/www
    </VirtualHost>
    
    <VirtualHost *:80>
    ServerName map.derpnet.nu
    DocumentRoot /home/derpishcat/test
    </VirtualHost>
    
    <FilesMatch "\.(gif|jpg|png)$">
    ErrorDocument 404 /stuff/404.png
    </FilesMatch>
    (Thought it'd be better if I just paste it all, seeing how I seem to fail with much else )

    It still tells me "NameVirtualHost *:80 has no VirtualHosts", but at least starts up with "OK".
    But it does work, should I just remove NameVirtualHost?
    Last edited by DerpishCat; March 21st, 2013 at 11:24 AM.

  7. #7
    Join Date
    Nov 2008
    Location
    Metro Boston
    Beans
    10,247
    Distro
    Kubuntu 14.04 Trusty Tahr

    Re: Can't figure out apache2 VirtualHosts, webserver won't even start

    The NameVirtualHost directive is included in /etc/apache2/ports.conf by default, and httpd.conf is deprecated. The correct method as you describe is to create the sites in /etc/apache2/sites-available and use a2ensite to create the appropriate symlinks in /etc/apache2/sites-enabled.

    Do you see any more detailed error information in /var/log/apache2/error.log?
    If you ask for help, please have the courtesy to check for responses and thank the people who helped you.

    Blog · Linode System Administration Guides · Android Apps for Ubuntu Users

  8. #8
    Join Date
    Oct 2012
    Location
    Sweden
    Beans
    21
    Distro
    Ubuntu 13.10 Saucy Salamander

    Re: Can't figure out apache2 VirtualHosts, webserver won't even start

    Quote Originally Posted by SeijiSensei View Post
    The NameVirtualHost directive is included in /etc/apache2/ports.conf by default, and httpd.conf is deprecated. The correct method as you describe is to create the sites in /etc/apache2/sites-available and use a2ensite to create the appropriate symlinks in /etc/apache2/sites-enabled.

    Do you see any more detailed error information in /var/log/apache2/error.log?
    As everything (except that error on startup, but I'll deal with it later) seems to be working, and I'm currently working on adding more virtualhosts (which seems to work just fine), I'll just be using this method instead.
    And no, I could only find 404 errors for stuff that I had linked and then removed from the site.

    Thanks for all the help guys, I'll mark this as solved now.

    EDIT: It seems I cannot mark this as solved, I guess I'll have to ask a mod to do that...
    Last edited by DerpishCat; March 21st, 2013 at 12:26 PM.

Bookmarks

Posting Permissions

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