Sometimes, it is useful to replicate online site in a local machine for development purposes. In this article , we will see how to configure apache to serve clones of online sites.
In this step we will create
contains the config options for all the sites you want develop in
your local machine.
First, we should find
[apache], and decide what will be the location
[apache] is the location where the apache server is installed.
for example :
[sites] is the location where
sites.conf, the content and
the logs of your sites are located. for example :
Now, follow those steps:
[apache]/conf/httpd.conf config file and add following line in its end:
Create the newly included file
In this step we will add new site.
First, you should know
[site-domain] and generate a unique
[site-domain] is the domain where the site is located.
for example :
[site-name] is a unique name which identify the site. A simple strategy to generate this name:
Now , follow those steps:
Create a new
[sites]/[site-name] directory, and create the following sub directories inside:
www- this directory will contians the actual content of the site the should be served by apache.
log- this directory will contians the logs related the site
Add the following config snippet to
<VirtualHost 127.0.0.1:80> ServerName [site-domain] ErrorLog "[sites]/[site-name]/log/error.log" DocumentRoot "[sites]/[site-name]/www" <Directory "[sites]/[site-name]/www"> Options Indexes FollowSymLinks Includes ExecCGI AllowOverride All Require all granted </Directory> </VirtualHost>
Add a new mappings of IP addresses to
hosts file. This file is usually located in
4 Start/Restart apache
In the next part, we will see an example how to Clone online site