Apache2 No Listening Sockets, unable to open logs while trying to configure virtual hosts

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 [email protected]
 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.


Solution 1:

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.