1 Verifique o NameVirtualHost ativo. Abra o arquivo /etc/apache2/ports.conf:
NameVirtualHost *:80
2 Verifique o DNS
# ping app.local
PING localhost.localdomain (127.0.0.1) 56(84) bytes of data.
# ping john.app.local
PING localhost.localdomain (127.0.0.1) 56(84) bytes of data.
3 Verifique a configuração do Apache (/ etc / apache2 / sites-enabled / 000-default):
<VirtualHost *:80>
ServerName app.local
DocumentRoot /var/www
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
</VirtualHost>
<VirtualHost *:80>
ServerName john.app.local
DocumentRoot /var/www/john
</VirtualHost>
$ sudo apache2ctl configtest
Syntax OK
$ sudo apache2 -S
VirtualHost configuration:
wildcard NameVirtualHosts and _default_ servers:
*:80 is a NameVirtualHost
default server app.local (/etc/apache2/sites-enabled/000-default:1)
port 80 namevhost app.local (/etc/apache2/sites-enabled/000-default:1)
port 80 namevhost john.app.local (/etc/apache2/sites-enabled/000-default:12)
4 Teste o Apache:
$ curl http://john.app.local
john
$ curl http://app.local
<html><body><h1>It works!</h1>
<p>This is the default web page for this server.</p>
<p>The web server software is running but no content has been added, yet.</p>
</body></html>