Apache AH00558:httpd:在创建VirtualHost后无法可靠地确定服务器的完全限定servername错误

Apache AH00558:httpd:在创建VirtualHost后无法可靠地确定服务器的完全限定servername错误,apache,httpd.conf,centos8,Apache,Httpd.conf,Centos8,我在CentOS 8中安装了一台Apache服务器,它正确地服务于http和https页面,也就是说,当从浏览器连接到服务器时,我可以查看Apache测试页面 我使用本教程启用https: 这很有效。但是,当我尝试启用服务器为默认测试页以外的网页提供服务时,我遇到了错误AH00558:httpd:在尝试使用重新启动apache服务器时创建VirtualHost之后,无法可靠地确定服务器的完全限定servername错误 sudo systemctl restart httpd 下面是my/

我在CentOS 8中安装了一台Apache服务器,它正确地服务于http和https页面,也就是说,当从浏览器连接到服务器时,我可以查看Apache测试页面

我使用本教程启用https:

这很有效。但是,当我尝试启用服务器为默认测试页以外的网页提供服务时,我遇到了错误AH00558:httpd:在尝试使用重新启动apache服务器时创建VirtualHost之后,无法可靠地确定服务器的完全限定servername错误

sudo systemctl restart httpd  
下面是my/etc/https/conf/http.conf的内容,删除了一些注释

ServerRoot "/etc/httpd"
Listen 80

Include conf.modules.d/*.conf

User apache
Group apache

ServerAdmin root@localhost

#
# ServerName gives the name and port that the server uses to identify itself.
# This can often be determined automatically, but we recommend you specify
# it explicitly to prevent problems during startup.
#
# If your host doesn't have a registered DNS name, enter its IP address here.
#
#ServerName www.example.com:80

<Directory />
    AllowOverride none
    Require all denied
</Directory>

DocumentRoot "/var/www/html"

<Directory "/var/www">
    AllowOverride None
    # Allow open access:
    Require all granted
</Directory>

<Directory "/var/www/html">
    Options Indexes FollowSymLinks
    AllowOverride None
    Require all granted
</Directory>

<IfModule dir_module>
    DirectoryIndex index.html
</IfModule>

<Files ".ht*">
    Require all denied
</Files>

ErrorLog "logs/error_log"

LogLevel warn

<IfModule log_config_module>
    LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
    LogFormat "%h %l %u %t \"%r\" %>s %b" common

    <IfModule logio_module>
      # You need to enable mod_logio.c to use %I and %O
      LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %I %O" combinedio
    </IfModule>

    CustomLog "logs/access_log" combined
</IfModule>

<IfModule alias_module>

    ScriptAlias /cgi-bin/ "/var/www/cgi-bin/"

</IfModule>

<Directory "/var/www/cgi-bin">
    AllowOverride None
    Options None
    Require all granted
</Directory>

<IfModule mime_module>
    TypesConfig /etc/mime.types

    AddType application/x-compress .Z
    AddType application/x-gzip .gz .tgz

    AddType text/html .shtml
    AddOutputFilter INCLUDES .shtml
</IfModule>

AddDefaultCharset UTF-8

<IfModule mime_magic_module>
    MIMEMagicFile conf/magic
</IfModule>

EnableSendfile on

IncludeOptional conf.d/*.conf

IncludeOptional sites-enabled/*.conf
如何在此处重新启动httpd服务

更新:上面链接的教程说,我们需要在httpd.conf的末尾添加以下行

IncludeOptional sites-enabled/*.conf  
这是我对默认httpd.conf文件所做的唯一更改,如果我对这行进行注释,我可以正常重新启动httpd。因此,问题出在我的/etc/httpd/sites available/adorkable.conf版本中的某个地方,在我的例子中,该文件重命名为username1.conf。我在站点中启用了指向此文件的符号链接,使用命令创建

sudo ln -s /etc/httpd/sites-available/adorkable.conf /etc/httpd/sites-enabled/adorkable.conf  

按照链接教程中的说明。

从virtualhost中删除错误日志。试试看。As/var/www/html/username1/error.log不存在。只有在删除ErrorLog指令后apache重新启动成功时,才尝试运行chown apache:apache/var/www/html/username1-R。运行该命令后,请尝试重新添加ErrorLog指令,我相信它应该会起作用。

我问如何在此处重新启动httpd服务?Apache没有重新启动。我没有httpd.conf/apache2.conf,我有/etc/httpd/conf/httpd.confOk。将其添加到httpd.conf谢谢您的更新,但即使在执行chown之后,如果我添加回ErrorLog指令,我也会收到相同的错误。让我们在下面的评论中进行讨论。让我们不要在上面的评论中继续。它太长,进入username1,运行cat>error.log并按Ctrl+D。然后尝试重新启动。确保error.log归apacheTry所有从中删除ServerNamevirtualhost@Chi.C.J.RajeevaLochana不起作用,我尝试删除ServerName、ServerAlias、ServerAdmin;同样的错误除了sudo ln-s/etc/httpd/sites available/adrokable.conf/etc/httpd/sites enabled/adrokable.conf之外,您还可以尝试只使用命令a2ensite adrokable。但我不认为这有什么意义difference@Chi.C.J.RajeevaLochana我没有戒律哦,好的。我以为你在用Ubuntu,对不起
IncludeOptional sites-enabled/*.conf  
sudo ln -s /etc/httpd/sites-available/adorkable.conf /etc/httpd/sites-enabled/adorkable.conf