6

I'm trying to set up multiple domains with virtual hosts in Apache2. I'm currently getting a "Could not connect" error when I try to browse to my site, and whenever I try to restart Apache2, I get an error about "no listening sockets available, shutting down Unable to open logs".

Originally, after configuring apache2.conf and my /apache2/sites-enabled/domain1.com, I was getting a 500 server error and a warn from apache2 that "NameVirtualHost *:80 has no VirtualHosts". Then I commented out an extra (I think) NameVirtualHost *:80 in the ports.conf file, and now the cannot connect and no sockets error.

Here's what's at the bottom of my apache2.conf:

 NameVirtualHost *:80
#<VirtualHost *:80>                                                            

<IfModule mod_ssl.c>
    NameVirtualHost *:443
</IfModule>

And my /apache2/sites-enabled/domain1.com:

          # domain: domain1.com
          # public: /home/demo/public_html/domain1.com/

<VirtualHost *:80>

 # Admin email, Server Name (domain name) and any aliases
 ServerAdmin admin@domain1.com
 ServerName  domain1.com
 ServerAlias domain1.com


 # Index file and Document Root (where the public files are located)
 DirectoryIndex index.html
 DocumentRoot /home/demo/public_html/domain1.com/public


 # Custom log file locations
 LogLevel warn
 ErrorLog  /home/demo/public_html/domain1.com/log/error.log
 CustomLog /home/demo/public_html/domain1.com/log/access.log combined

</VirtualHost>

And finally, my ports.conf:

#NameVirtualHost *:80                                                            
#Listen 80                                                                     

<IfModule mod_ssl.c>
    # If you add NameVirtualHost *:443 here, you will also have to change      
    # the VirtualHost statement in /etc/apache2/sites-available/default-ssl    
    # to <VirtualHost *:443>                                                   
    # Server Name Indication for SSL named virtual hosts is currently not      
    # supported by MSIE on Windows XP.                                         
        Listen 443
</IfModule>

<IfModule mod_gnutls.c>
    Listen 443
</IfModule>

I appreciate any insight that can be offered.

Ana
  • 63
  • 1
  • 1
  • 3

1 Answers1

11

It looks like you've commented out the Listen 80 line, so Apache isn't listening on the normal http port.

You're other Listen directives are inside IfModule blocks, so if those modules aren't present, you have effectively configured Apache to not listen on any ports, which may be the source of your error.

Try uncommenting the line:

Listen 80

In your ports.conf.

larsks
  • 41,276
  • 13
  • 117
  • 170
  • Awesome, thank you! Now I'm getting a 500 server error, and not just that terrifying no connection. I'll go bang on it a bit more, try and fix that. Again, thanks. – Ana Oct 27 '11 at 03:50
  • ...and up and fixed entirely. – Ana Oct 27 '11 at 04:03