Question on the training task. It is necessary to give examples of Apache server configuration file fragments for test.ru, test2.ru, www.test2.ru domains.
Test.ru and test2.ru domains refer to different (any) folders, www.test2.ru and test2.ru domains for one folder.
For all domains, the mod_headers module should be enabled, and for the test2.ru and www.test2.ru domains, add the mod_deflate filter for html files.

Tell me if my decision is correct and point out the errors, if any.

ServerName test.ru DocumentRoot “/home/www/test/” # Подключение модуля mod_headers LoadModule headers_module modules/mod_headers.so ServerName test2.ru DocumentRoot “/home/www/test2/” <VirtualHost *> ServerName www.test2.ru DocumentRoot “/home/www/test2/” </VirtualHost> # Подключение модуля mod_headers LoadModule headers_module modules/mod_headers.so # Подключение модуля mod_headers LoadModule deflate_module modules/mod_deflate.so AddOutputFilterByType DEFLATE text/html 

    2 answers 2

    This is done like this:

     LoadModule headers_module modules/mod_headers.so LoadModule deflate_module modules/mod_deflate.so AddOutputFilterByType DEFLATE text/html <VirtualHost *:80> DocumentRoot "/home/test1/www" ServerName test.ru </VirtualHost> <VirtualHost *:80> DocumentRoot "/home/test2/www" ServerName test2.ru ServerAlias www.test2.ru </VirtualHost> 
    • not, I have the first domain, test.ru, but there are no aliases # test ServerName test.ru DocumentRoot “/ home / www / test /” # Connecting the mod_headers module LoadModule headers_module modules / mod_headers.so # test2 <VirtualHost *: 80> DocumentRoot "/ home / test2 / www" ServerName test2.ru ServerAlias ​​www.test2.ru </ VirtualHost> # Connection of the mod_headers module LoadModule headers_module modules / mod_headers.so # Connection of the module deflate_module LoadModule deflate_module modules / mod_deflate.so AddOutputFilterByTyte manual - Heidel 2:07 pm
    • so it will be right? - Heidel pm
    • The absence of an alias from the first host does not deprive it of the status of a host, that is, VirtualHost is also needed for it. Just remove "ServerAlias ​​www.test1.ru". And take the LoadModule to one place (for example, at the beginning), for convenient search in the future. - gidman 2:38 pm

    For convenience, we divide into tasks 1) Domains test.ru and test2.ru refer to different (any) folders,

     <VirtualHost *:80> DocumentRoot "/var/html/test1/www/" ServerName test1.ru </VirtualHost> <VirtualHost *:80> DocumentRoot "/var/html/test2/www/" ServerName test2.ru </VirtualHost> 

    2) Domain www.test2.ru and test2.ru on one folder. Option 1.

     <VirtualHost *:80> DocumentRoot "/var/html/test1/www/" ServerName test1.ru </VirtualHost> <VirtualHost *:80> DocumentRoot "/var/html/test1/www/" ServerName test2.ru </VirtualHost> 

    Option 2

     <VirtualHost *:80> DocumentRoot "/var/html/test1/www/" ServerName test1.ru ServerAlias test2.ru </VirtualHost> 

    Modules are connected in the section Dynamic Shared Support

    By default they are enabled.

     # # Dynamic Shared Object (DSO) Support # LoadModule deflate_module modules/mod_deflate.so LoadModule headers_module modules/mod_headers.so