Views: 12298
Last Modified: 15.09.2014
Apache web server is normally set up by the host’s technical support service. Examples of Apache server’s settings provided below are intended for reference and understanding the setup mechanism.
Multiple Site in One Domain
The configuration file httpd.conf of the Apache web server must contain an entry similar to the following:
<VirtualHost *:80>
ServerAdmin admin@site1.com
DocumentRoot "/home/www/allsites/"
ServerName www.site1.com
ErrorLog logs/allsite.log
CustomLog logs/allsite.log common
</VirtualHost>
Please note that the DocumentRoot parameter has the value /home/www/allsites/
and directly indicates the catalog where the product is installed. The DocumentRoot parameter will have the same value for both websites.
The line <VirtualHost *:80> indicates that the web server will respond to any domain name at any IP address. I.e. if the DNS server is set up properly, the web server will respond to either name – www.site1.com or www.site2.com.
Multiple Site in Different Domains
The configuration file httpd.conf of the Apache web server must contain two entries. Each one of these entries must describe its "virtual server" (in Apache terms):
<VirtualHost *:80>
ServerAdmin admin@site1.com
DocumentRoot "/home/www/site1/"
ServerName site1.com
ServerAlias *.site1.com
ErrorLog logs/site1.log
CustomLog logs/site1.log common
</VirtualHost>
<VirtualHost *:80>
ServerAdmin admin@site2.com
DocumentRoot "/home/www/site2/"
ServerName site2.com
ServerAlias *.site2.com
ErrorLog logs/site2.log
CustomLog logs/site2.log common
</VirtualHost>
Please note that the DocumentRoot parameter for each website indicates a different catalog on the disk where the relevant website must be located.
The lines <VirtualHost *:80> indicate that the web server will respond at any IP address, but the variable ServerAlias indicates that each website will respond only to a specific domain name.
I.e. the domain name www.site1.com will be processed by one web server Apache which works with the catalog /home/www/site1/
and www.site2.com by another web server that works with the catalog /home/www/site2/
.
Also a configuration option is available for different IP addresses. A sample Apache configuration for two different IP addresses is provided below:
<VirtualHost 192.168.0.1:80>
ServerAdmin admin@site1.com
DocumentRoot "/home/www/site1/"
ServerName site1.com
ErrorLog logs/site1.log
CustomLog logs/site1.log common
Options +FollowSymLinks
</VirtualHost>
<VirtualHost 192.168.0.2:80>
ServerAdmin admin@site2.com
DocumentRoot "/home/www/site2/"
ServerName site2.com
ErrorLog logs/site2.log
CustomLog logs/site2.log common
Options +FollowSymLinks
</VirtualHost>
In this case, if DNS is set up properly for different domain names each "virtual server" (in Apache terms) will work at a separate IP address and respond only to a specific domain name.
Note:Sometimes website administrators have no access to the file httpd.conf due to certain reasons, for example hosting limitations. In this case, website information can be separated as follows:
- Create the folder
/bitrix_personal
in the root of the second website
- In this folder create two symbolic links to
/bitrix/php_interface/
and /bitrix/templates/
of the first website.
- Type the following in the very beginning of the file .htaccess located in the root of each website:
SetEnv "/bitrix/bitrix_personal"