Views: 4446
Last Modified: 10.10.2012

Mode 2. Individual web server for each site.

The second mode requires that you make special adjustments to both web server and the installed software.

We shall consider configuration of the two sites:

  • www.site1.com - a company corporate web site;
  • www.site2.com - a company on-line store.

Each of the sites needs a separate Apache web server to be configured. The sites are placed in the appropriate directories:

  • /home/www/site1/
  • /home/www/site2/

The Apache web server configuration file httpd.conf should contain the following two records, each of which describes its own virtual web server (in terms of Apache):

<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 record DocumentRoot points to an individual directory each site will reside in.

Lines <VirtualHost *:80> denote that the web server will respond to any domain name and IP address. But the variable ServerAlias tells the web server to respond to a specific domain name only.

That is, requests to www.site1.com are processed by the Apache web server instance working with the directory /home/www/site1/, but www.site2.com is managed by the web server that is responsible for the directory /home/www/site2/.

You can configure your web servers to serve specific IP addresses. Example below shows how to configure an Apache web server to support different IP addresses:

<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>

Having the DNS server properly configured for different domain names, each virtual web server will run on a separate IP address and respond to a specific IP address or domain name.

The next step is to install Bitrix Site Manager for this configuration. The console commands illustrate how to install it on UNIX-based systems.

  1. install the Bitrix Site Manager 5.x to the directory of the first site /home/www/site1/;
  2. create the /home/www/shared/ folder. It will contain files common to all sites:
    mkdir /home/www/shared;
  3. move the entire directory /home/www/site1/bitrix/ to /home/www/shared/bitrix/:
    mv /home/www/site1/bitrix /home/www/shared/bitrix;
  4. move the entire directory /home/www/site1/upload/ to /home/www/shared/upload/: mv /home/www/site1/upload /home/www/shared/upload;
  5. create the symbolic link to the directory /bitrix/ for each site:
    1. ln -s /home/www/shared/bitrix /home/www/site1/
    2. ln -s /home/www/shared/upload /home/www/site1/
    3. ln -s /home/www/shared/bitrix /home/www/site2/
    4. ln -s /home/www/shared/upload /home/www/site2/
  6. ensure that the directory /home/www/shared/ of a web server (Apache, IIS) has write permissions. This is essential for the update system and image uploads;
  7. copy the public pages of the second site to the directory /home/www/site2/.
Windows based web servers require third-party tools for the symbolic link creation. For example, Far Manager or Sysinternals Junction.

When configuring a multisite system under UNIX, you can create symbolic link programmatically:

<?
symlink("/virt/homes/forinsured/bitrix", "/virt/homes/forinsured/htdocs/bitrix");
symlink("/virt/homes/forinsured/upload", "/virt/homes/forinsured/htdocs/upload");
?>

Next step is to properly configure sites in the installed Bitrix software.

You can configure sites in the Control Panel; select System settings -> Sites.

Click Modify on the site #1 (www.site1.com) and specify the following parameters:

  • Name: site1
  • Domain: www.site1.com
  • Site folder: /
  • Server URL: www.site1.com
  • Site name: Web site of our company
  • Path to web server root folder of this site: /home/www/site1/

If DNS is configured in such way that your site is available at http://site1.com address, it is always a good idea to specify the Domain field without www. You can specify as many as needed domain names that users can indicate in their browsers to access your site; each domain name in the list should start from the new line.

Please bear in mind that the values you specify in the Domain field are used by the system to deliver the user information to these domains through the UserMultiSiteTransfer technology. It is also recommended to specify a full list of registered domain names by which your site can be accessed.

Do not include in this list sites not running on the current instance of the Bitrix Site Manager. Invalid domains will slow down the system response to users; user information will not be transferred to sites running on other instances of the software.

Use the following settings for the second site (www.site2.com):

  • Name: site2
  • Domain: site2.com
  • Site folder: /
  • Server URL: www.site2.com
  • Site name: Our e-Store
  • Path to web server root folder of this site: /home/www/site2/

Please note that both sites have the same Site folder : "/". This is possible due to the fact that the sites run on separate web servers with different physical files location.

Note that the parameter Path to web server root folder of this site contains individual values for each site. It follows the value of the DocumentRoot parameter of the corresponding virtual server (see the example of the httpd.cnf file above).

Please bear in mind that this multisiting method allows to use virtual servers of a single Apache instance as well as different Apache instances. The same is for other web servers: IIS, EServ etc.

The configuration is now ready to run.

Unlike the first configuration mode, this mode does not require any special site selection algorithm on the index page of the portal, as a site is defined by the domain name.

Bitrix Site Manager does not give preference to any of the versions. The first mode is generally used if you use the virtual hosting or feel uncertain at configuring web servers. The second variant can be recommended if you use a dedicated server or the shared hosting allows several web server instances. This mode allows to exclude catalogs like /s1/ or /s2/ from URL's and start addresses from the root directory "/".


Courses developed by Bitrix24