Answer the question
In order to leave comments, you need to log in
Problem with virtual hosts for subdomains in Apache?
The directory structure is as follows:
/var/www/test.ru
/var/www/test.ru/httpd
/var/www/test.ru/forum
/var/www/test.ru/media
The site itself is located in the "httpd" folder domain, and in the "forum" folder, respectively, the subdomain "forum.test.ru" itself.
hosts file:
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
<VirtualHost *:80>
ServerAdmin [email protected]
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 [email protected]
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 [email protected]
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>
Answer the question
In order to leave comments, you need to log in
<VirtualHost 127.0.0.1:80>
ServerName test.ru
ServerAlias www.test.ru
ServerAdmin [email protected]
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 [email protected]
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 [email protected]
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>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question