Apache2 没有侦听套接字,尝试配置虚拟主机时无法打开日志

Ana*_*Ana 6 socket namevirtualhost apache-2.2

我正在尝试在 Apache2 中使用虚拟主机设置多个域。当我尝试浏览我的网站时,我目前收到“无法连接”错误,每当我尝试重新启动 Apache2 时,我都会收到关于“没有可用的侦听套接字,关闭无法打开日志”的错误。

最初,在配置 apache2.conf 和我的 /apache2/sites-enabled/domain1.com 后,我收到了 500 服务器错误和来自 apache2 的警告,即“NameVirtualHost *:80 has no VirtualHosts”。然后我在ports.conf文件中注释掉了一个额外的(我认为)NameVirtualHost *:80,现在无法连接和没有套接字错误。

这是我的 apache2.conf 底部的内容:

 NameVirtualHost *:80
#<VirtualHost *:80>                                                            

<IfModule mod_ssl.c>
    NameVirtualHost *:443
</IfModule>
Run Code Online (Sandbox Code Playgroud)

而我的/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>
Run Code Online (Sandbox Code Playgroud)

最后,我的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>
Run Code Online (Sandbox Code Playgroud)

我很欣赏可以提供的任何见解。

lar*_*sks 11

看起来您已注释掉该Listen 80行,因此 Apache 未在正常http端口上侦听。

你的其他Listen指令在IfModule块内,所以如果这些模块不存在,你已经有效地将 Apache 配置为不侦听任何端口,这可能是错误的根源。

尝试取消注释该行:

Listen 80
Run Code Online (Sandbox Code Playgroud)

在你的ports.conf 中。