Clone online site apache - part 2

Example for

Suppose, we want to develop www.demo.com , s1.demo.com , s2.demo.com on our local machine.

1 we decide that our sites directory will be C:/sites.

2 we create the following directory structure:

sites directory structure
 C:/sites                     ├ sites.conf
 ├────────────demo            ├
 │           ├────────────www ├ index.html ...
 │           └────────────log ├ error.log , transfer.log
 ├────────────demo_s1         ├
 │           ├────────────www ├ index.html ...
 │           └────────────log ├ error.log , transfer.log
 └────────────demo_s2         ├
             ├────────────www ├ index.html ...
             └────────────log ├ error.log , transfer.log

3 We edit sites.conf:

[sites]/sites.conf
 <VirtualHost 127.0.0.1:80>
     ServerName   www.demo.com
     DocumentRoot "C:/sites/demo/www"
     ErrorLog     "C:/sites/demo/log/error.log"
     TransferLog  "C:/sites/demo/log/transfer.log"
     <Directory "C:/sites/demo/www">
         Options Indexes FollowSymLinks Includes ExecCGI
         AllowOverride All
         Require all granted
     </Directory>
 </VirtualHost>

 <VirtualHost 127.0.0.1:80>
     ServerName   s1.demo.com
     DocumentRoot "C:/sites/demo_s1/www"
     ErrorLog     "C:/sites/demo_s1/log/error.log"
     TransferLog  "C:/sites/demo_s1/log/transfer.log"
     <Directory "C:/sites/demo_s1/www">
         Options Indexes FollowSymLinks Includes ExecCGI
         AllowOverride All
         Require all granted
     </Directory>
 </VirtualHost>

 <VirtualHost 127.0.0.1:80>
     ServerName   s2.demo.com
     DocumentRoot "C:/sites/demo_s2/www"
     ErrorLog     "C:/sites/demo_s2/log/error.log"
     TransferLog  "C:/sites/demo_s2/log/transfer.log"
     <Directory "C:/sites/demo_s2/www">
         Options Indexes FollowSymLinks Includes ExecCGI
         AllowOverride All
         Require all granted
     </Directory>
 </VirtualHost>

4 We include it in [apache]/conf/httpd.conf

[apache]/conf/httpd.conf
 ...
 Include "C:/sites/sites.conf"

5 We edit hosts file:

hosts
 127.0.0.1               www.demo.com
 127.0.0.1               s1.demo.com
 127.0.0.1               s2.demo.com

6 We start/restart apache.

Now, when we access :

  • http://www.demo.com , index.html under C:/sites/demo/www will be served
  • http://s1.demo.com , index.html under C:/sites/demo_s1/www will be served
  • http://s2.demo.com , index.html under C:/sites/demo_s2/www will be served