# portas.cfg
NameVirtualHost *:80
ServerName example.ru # Без этой стоки выдает ошибку
Listen 80
# ...
# httpd.conf
# пустой ...
# apache2.conf
# ...
# sites-available/default
<VirtualHost *:80>
ServerAdmin webmaster@localhost
ServerName test.example.ru # Можно не писать, все равно обращение по ип будет приходить сюда.
DocumentRoot /var/www
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
ErrorLog /var/log/apache2/error.log
# Possible values include: debug, info, notice, warn, error, crit, alert, emerg.
LogLevel warn
CustomLog /var/log/apache2/access.log combined
</VirtualHost>
# sites-available/stribog
<VirtualHost *:80>
ServerAdmin stribog@example.ru
ServerName stribog.example.ru
DocumentRoot /home/stribog
<Directory />
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
ErrorLog /home/stribog/error.log
# Possible values include: debug, info, notice, warn, error, crit, alert, emerg.
LogLevel debug
CustomLog /home/stribog/access.log combined
</VirtualHost>
Итак. Что у нас получилось? При любом обращении к нашему хосту, будут задействованы конфиги из default. За исключением адреса stribog.examlpe.com, при обращении к нему будут задействованы конфиги stribog.
Как ни странно, но в интернете не нашел нормальной инструкции. Подбирал конфиги методом проб и ошибок. Фактически дописывал строчку ... перезагружал апач ... видел ошибку ... наугад дописывал ... перезагружал ...
Да, главное не забывайте включить виртуальные хосты.
a2ensite stribog