【问题标题】:Virtualhost: AH00558: apache2: Could not reliably determine the server's fully qualified domain name虚拟主机:AH00558:apache2:无法可靠地确定服务器的完全限定域名
【发布时间】:2021-08-14 15:14:59
【问题描述】:

每当我尝试在 Debian 10 上使用 apache 设置虚拟主机时都会遇到问题。

我正在尝试在地址 products.crud 上设置虚拟主机。所以目录结构是var/www/products.crub/web

所以,我在 /etc/apache2/sites-available 目录中创建了 Apache 虚拟主机配置文件,我也可以在 /etc/apache2/sites-enabled 目录中启用它。 products.crud.conf 文件的内容是:

<VirtualHost *:80>
ServerName products.crud
DocumentRoot /var/www/products.crud/web
<Directory /var/www/products.crud/web>
    RewriteEngine On
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteCond %{REQUEST_FILENAME} !-d
        RewriteRule . index.php [L]
</Directory>

所以,我使用以下方式启用了域:

$ sudo a2ensite products.crud

然后我使用

测试了语法

$ sudo apachectl 配置测试

问题是我收到这个错误:

AH00558:apache2:无法可靠地确定服务器的完全限定域名,使用 fe80::2ff5:a177:ff45:30b3。全局设置“ServerName”指令以禁止显示此消息 语法OK

我试图解决的问题

我尝试在 /etc/hosts 中添加域

127.0.0.1   localhost
#127.0.1.1  terminale
#127.0.0.1  products.test
127.0.0.5   products.crud

我也尝试在apache2.conf中添加:

# Global configuration                                                          
#                                                                               
ServerName products.crud
#                                                                               
# ServerRoot: The top of the directory tree under which the server's            
# configuration, error, and log files are kept.                                 
#   

每当我尝试连接到 products.crud 时,我都会看到 apache 的 localhost 主页,而不是我的 index.php。我该如何解决这个问题?

【问题讨论】:

    标签: php apache debian apache2 virtualhost


    【解决方案1】:

    如果您在 products.crud.conf 文件中将 ServerName products.test 更改为 ServerName products.crud 会怎样,如下所示:

      <VirtualHost *:80>
        ServerName products.crud
        DocumentRoot /var/www/products.crud/web
        <Directory /var/www/products.crud/web>
            RewriteEngine On
                RewriteCond %{REQUEST_FILENAME} !-f
                RewriteCond %{REQUEST_FILENAME} !-d
                RewriteRule . index.php [L]
        </Directory>
     </VirtualHost>
    

    【讨论】:

    • 对不起,我没看到!无论如何,我仍然得到完全相同的错误:AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using fe80::2ff5:a177:ff45:30b3. Set the 'ServerName' directive globally to suppress this message Syntax OK EDIT:formatting
    • 你重启了apache吗?
    • 是的,我重新启动了它!在 apache2.conf 我取消注释 ServerName products.crud 现在我没有收到任何错误。问题是现在 products.crud 将我重定向到本地主机主页...@Siebe Jongebloed
    • 所以它解决了一个问题。现在你有另一个问题。您是否使用可负责重定向的 .htaccess 文件?也许在你的主机文件中删除这一行:127.0.0.5 products.crud。
    • 实际上我通过添加 products.crud.conf &lt;VirtualHost products.crud:80&gt; 解决了这个问题。现在主要的问题是 php 没有被解析,并且代码被读取为 html
    猜你喜欢
    • 2022-07-18
    • 2021-05-29
    • 2011-08-16
    • 2013-08-19
    • 1970-01-01
    • 2020-08-30
    • 2018-05-19
    • 2015-10-15
    • 1970-01-01
    相关资源
    最近更新 更多