【问题标题】:Apache2 Virtual Host fails with Name or service not knownApache2 虚拟主机失败,名称或服务未知
【发布时间】:2018-11-11 01:52:54
【问题描述】:

从 Ubuntu 17.10 迁移到 Mint 18.3 并迁移虚拟主机配置文件失败

[core:error] [pid 3012] (EAI 2)Name or service not known: AH00547: Could not resolve host name

在我新安装的 Mint 上,我首先完成了此操作
1) sudo a2dissite 000-default.conf

这是我用于虚拟主机的标准配置文件

<VirtualHost *.domain.localhost:80>
    ServerName domain.localhost
    ServerAlias www.domain.localhost api.domain.localhost
    ServerAdmin webmaster@localhost
    DocumentRoot /home/dev/projects/domain/web/html/
    <Directory /home/dev/projects/domain/web/html/>
        Options -Indexes +FollowSymLinks +MultiViews
        AllowOverride All
        Require all granted
    </Directory>
    ErrorLog /var/log/apache2/error.log
    LogLevel warn
    CustomLog /var/log/apache2/access.log combined
    ServerSignature Off
</VirtualHost>

顺便说一句:我正在为每个项目执行此步骤
1) sudo chown -R www-data:www-data PATH_TO_DIR
2) sudo chmod 660 -R PATH_TO_DIR
3) sudo chmod -R -x+X PATH_TO_DIR
4) sudo find PATH_TO_DIR -type d -exec chmod g+s {} \;
5) sudo setfacl -R -d -m u::rwX,g::rwX,o::- PATH_TO_DIR

更新: 将域添加到 /etc/hosts,重新加载服务器会再次导致默认

【问题讨论】:

  • domain.localhost 在您的 /etc/hosts 文件中吗?
  • @ivanivan 不,不是。我从来不用向主机添加虚拟主机域

标签: apache virtualhost


【解决方案1】:

我已经通过修改“000-default.conf”DocumentRoot Path,然后通过添加这些行来修改“/etc/apache2/apache2.conf”来解决它

<Directory /home/mdev/_projects/>
    Options Indexes FollowSymLinks
    AllowOverride None
    Require all granted
</Directory>

这也必须改变

<VirtualHost *.domain.localhost:80>

<VirtualHost *:80>

/etc/hosts 没有必要的条目!

【讨论】:

    猜你喜欢
    • 2021-08-18
    • 2017-02-21
    • 2013-12-02
    • 2016-02-07
    • 1970-01-01
    • 1970-01-01
    • 2013-03-14
    • 1970-01-01
    相关资源
    最近更新 更多