首页 > 解决方案 > Apache2 虚拟主机失败,名称或服务未知

问题描述

从 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

这是我用于 Vhosts 的标准配置文件

<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 -键入 d -exec chmod g+s {} \;
5) sudo setfacl -R -d -mu::rwX,g::rwX,o::- PATH_TO_DIR

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

标签: apachevirtualhost

解决方案


我已经通过修改“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 没有必要的条目!


推荐阅读