Проблема с виртуальными хостами для поддоменов в Apache?

Структура каталогов такая:
/var/www/test.ru
/var/www/test.ru/httpd
/var/www/test.ru/forum
/var/www/test.ru/media

В папке "httpd" находится сам сайт домена, а в папке "forum" соответственно сам поддомен "forum.test.ru".
Файл hosts:
127.0.0.1       localhost
127.0.1.1       WS01
127.0.0.1       test.ru
127.0.0.1       forum.test.ru
127.0.0.1       media.test.ru


Ну и файл /etc/apache2/sites-available/test.ru.conf

<VirtualHost *:80>

        ServerAdmin test@bk.ru
        DocumentRoot /var/www/test.ru/httpd
        ServerName test.ru
        ServerAlias www.test.ru

        <Directory /var/www/test.ru/httpd>
           Options Indexes FollowSymlinks
           AllowOverride All
           Require all granted
        </Directory>

        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined

</VirtualHost>

<VirtualHost *:80>

        ServerAdmin test@bk.ru
        DocumentRoot /var/www/test.ru/forum
        ServerName forum.test.ru
        ServerAlias www.forum.test.ru

        <Directory /var/www/test.ru/forum>
           Options Indexes FollowSymlinks
           AllowOverride All
           Require all granted
        </Directory>

        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined

</VirtualHost>
<VirtualHost *:80>

        ServerAdmin test@bk.ru
        DocumentRoot /var/www/test.ru/media
        ServerName media.test.ru
        ServerAlias www.media.test.ru

        <Directory /var/www/test.ru/media>
           Options Indexes FollowSymlinks
           AllowOverride All
           Require all granted
        </Directory>

        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined

</VirtualHost>


При попытке добавить для "media" еще одну секцию и добавлении 127.0.0.1 с параметром "media.test.ru" в файл hosts, апач ругается на то, что ему не нравится VirtualHost. Подскажите где я накосячил?
  • Вопрос задан
  • 639 просмотров
Пригласить эксперта
Ответы на вопрос 1
<VirtualHost 127.0.0.1:80>
        ServerName  test.ru
        ServerAlias www.test.ru
        ServerAdmin test@bk.ru
        DocumentRoot  /var/www/test.ru/httpd
        ErrorLog logs/test_ru_error_log
        LogLevel warn
        CustomLog logs/test_ru_assest_log combined

       <Directory /var/www/test.ru/httpd>
                Options Indexes FollowSymLinks MultiViews
                AllowOverride All
                DirectoryIndex index.php index.html index.htm
                Order allow,deny
                allow from all
       </Directory>
</VirtualHost>


<VirtualHost 127.0.0.1:80>
        ServerName  forum.test.ru
        ServerAlias www.forum.test.ru
        ServerAdmin test@bk.ru
        DocumentRoot  /var/www/forum.test.ru/httpd
        ErrorLog logs/forum_test_ru_error_log
        LogLevel warn
        CustomLog logs/forum_test_ru_assest_log combined

       <Directory /var/www/forum.test.ru/httpd>
                Options Indexes FollowSymLinks MultiViews
                AllowOverride All
                DirectoryIndex index.php index.html index.htm
                Order allow,deny
                allow from all
       </Directory>
</VirtualHost>

<VirtualHost 127.0.0.1:80>
        ServerName  media.test.ru
        ServerAlias www.media.test.ru
        ServerAdmin test@bk.ru
        DocumentRoot  /var/www/media.test.ru/httpd
        ErrorLog logs/media_test_ru_error_log
        LogLevel warn
        CustomLog logs/media_test_ru_assest_log combined

       <Directory /var/www/media.test.ru/httpd>
                Options Indexes FollowSymLinks MultiViews
                AllowOverride All
                DirectoryIndex index.php index.html index.htm
                Order allow,deny
                allow from all
       </Directory>
</VirtualHost>
Ответ написан
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы