Views: 11594
Last Modified: 22.09.2014

In order to make multiple site work in different domains we will have to set up the software. Apache web server shall be configured by a hosting company; the same is true for multiple site in one domain.

Let us take a two site configuration as an example:

  • www.site1.com - company’s corporate site
  • www.site2.com - company’s e-store

Setup of Multiple Site in Different Domains

Each website should be located in the relevant catalog, e.g.:

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

Installing Software and Setup of Symbolic Links

The software is set in one of the sites. To make the kernel work for both sites you have to create symbolic links for the site where the kernel is not installed. The links will be required for the folders /bitrix and /upload.

Note:

It is possible to simply copy the said folders from the first site to the second. Such copying will result in two copies of the kernel working with the same database. This option will work, but it has two disadvantages: technical and legal. The technical problem is that after updating one of the kernels the database will be updated, and the second website will fail. The legal problem is that kernel copying contradicts the product license.


Note:

Copying of the said folders to an external folder to which symbolic links are configured for all websites is technically possible (but not recommended).


Symbolic Link:

A special file for which no information is stored in the file system except one text line. This line is interpreted as a path to the file which must be opened upon an attempt to access such link.

In practice, symbolic links are used for the more convenient organization of the file structure on the computer because they make it possible for one file or catalog to have several names and are free from certain limits common for hard links (which operate only within one section and cannot refer to catalogs).

There are to options to set the links. The first option is a classic option recommended by the company from the very beginning. The second option is a later addition and is considered more "beautiful and sophisticated". It omits the step of the creation of a separate folder and transfer of the system kernel into it.

First option (examples of installation on UNIX systems are marked in green):

  1. Install "Bitrix Site Manager" first to the catalog of the first site /home/www/site1/
  2. Create the catalog /home/www/shared/ where the files that are common for all the websites will be located:
    mkdir /home/www/shared
  3. Move the entire catalogг /home/www/site1/bitrix/ to /home/www/shared/bitrix/:
    mv /home/www/site1/bitrix /home/www/shared/bitrix
  4. Move the entire catalog /home/www/site1/upload/ to /home/www/shared/upload/:
    mv /home/www/site1/upload /home/www/shared/upload
  5. Create symbolic link for the catalog /bitrix/ in every website:
    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. Make sure webserver (Apache, IIS) has the right to write into the catalog /home/www/shared/ (it will be necessary for the operation of the update system and loading image files)
  7. Place the public part of the second website into the catalog /home/www/site2/
Note:

Additional software should be used in order to create symbolic links in Windows, e.g. Far Manager or Junction from Sysinternals.


Important!

FAT32 file system does not support the creation of symbolic links.

The following program method can be used to create symbolic links when creating a multiple site configuration at UNIX:

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

Note:

Sometimes, for example when web server works in chroot, relative links shall be created.

Example:
/var/www/s1 - first website
/var/www/s2 - second website
/var/www/shared - folder containing system kernel

Go to /var/www/s1 and create links:
ln -s ../shared/bitrix bitrix
ln -s ../shared/upload upload

Go to /var/www/s2 and run the same commands.

Second option. Symbolic links are created directly in the folder of the second website.

  1. Install Bitrix Site Manager first in the catalog of the first website /home/www/site1/
  2. Create a script in the root folder of the second website (/home/www/site2/); name it, for example, symlink.php:
  3. <html>
    <head><title>Create links to the folders bitrix and upload</title></head>
    <body>
    <?
    error_reporting(E_ALL & ~E_NOTICE);
    @ini_set("display_errors",1);
    if ($_POST['path'])
    $path = rtrim($_POST['path'],"/\\");
    else
    $path = '../site2/www';
    if ($_POST['create'])
    {
    if (preg_match("#^/#",$path))
    $full_path = $path;
    else
    $full_path = realpath($_SERVER['DOCUMENT_ROOT'].'/'.$path);
    if (file_exists($_SERVER['DOCUMENT_ROOT']."/bitrix"))
    $strError = "The current folder already contains the folder bitrix";
    elseif (is_dir($full_path))
    {
    if (is_dir($full_path."/bitrix"))
    {
    if (symlink($path."/bitrix",$_SERVER['DOCUMENT_ROOT']."/bitrix"))
    {
    if(symlink($path."/upload",$_SERVER['DOCUMENT_ROOT']."/upload"))
    echo "<font color=green>Symbolic links are created successfully</font>";
    else
    $strError = 'Cannot create the link to the folder upload, please contact the server administrator';
    }
    else
    $strError = 'Cannot create the link to the folder bitrix, please contact the server administrator';
    }
    else
    $strError = 'The indicated path does not contain the folder bitrix';
    }
    else
    $strError = 'Wrong path or access rights error';
    if ($strError)
    echo '<font color=red>'.$strError.'</font><br>Source path: '.$full_path;
    }
    ?>
    <form method=post>
    Path to the folder containing folders bitrix and upload: <input name=path value="<?=htmlspecialchars($path)?>"><br>
    <input type=submit value='Create' name=create>
    </form>
    </body>
    </html>
  4. Run the script and indicate the path to the root folder of the first website, in our case /home/www/site1/.
  5. Once symbolic links are created, type in the browser’s address bar site1/bitrix/admin. The authorization panel opens.
  6. Type the administrator’s data indicated when installing the product to the first website, and you will be redirected to the administrative panel of Bitrix Site Manager.

When script operation is completed, the symbolic links to the folders /bitrix and /upload n the folder of the second website become available. Their availability can be easily verified because the folders with the same names appear.

The following problems may arise at the creation stage:

  • Absence of rights to write in the current folder;
  • Security restriction (open_basedir) which prohibits users of a shared hosting from addressing other websites.

Contact your host should any problems arise with this script.

Website Configuration

Website are configured in the administrative section of the system on the page Control Panel > Settings > System settings > Websites > Websites.

Let us set up the first site (www.site1.com):

  • Name: site1
  • Domain: www.site1.com
  • Site folder: /
  • Website name: Corporate Website of "Company Name"
  • Server URL: www.site1.com
  • Path to the web server root folder of this site: /home/www/site1/

If DNS is configured so that your website responds to the address http://site1.com, it is better to omit www in the field Domain. You can enumerate any number of domain names you wish your website to respond to (or which your website already responds) using a new line in this field.

It is important to keep in mind that the product uses the values indicated in the field Domain to submit to the indicated domains the information about visitors using the technique of transfer of visitors. That is why it is strongly recommended that a complete list of domains which the website can respond to should be indicated.

It is very important not to indicate websites which do not work on this product copy in the list of domains. Incorrectly indicated or inexistent domain may slow down users’ experience as well as actually prevent transferring data to the websites not working on the shared product copy.

Set up the parameters of the second website following the same pattern (www.site2.com/):

  • Name: site2
  • Name: site2.com
  • Site folder: /
  • Website name: E-Store of "Company Name"
  • Server URL: www.site2.com
  • Path to the web server root folder of this site: /home/www/site2/

Please note that the same value "/" is indicated in the parameter Site folder for both websites. This is because the sites are serviced by different "virtual servers" (using Apache terms) which have different catalogs for the layout of files.

Also pay attention to the parameter Path to the web server root folder of this site. It has a different value for different websites taken from the parameter DocumentRoot of settings of the relevant "virtual server" (see an example of a part of the file httpd.conf of the Apache settings below).

Note:

When it comes to organizing multisiting using this option, you can use both virtual servers of one Apache unit and different Apache units. This is also true for other web servers: IIS, EServ, etc.

Important: When creating the second website you have to copy from the main website or create anew the files /.htaccess and /404.php.

File .access.php

Create the file .access.php with the following contents in the root of the second website:

<? $PERM["/"]["*"]="R"; ?>
Note:

Unlike Pseudomultisiting, for this option of multisiting setting website selection algorithm on the index page is not required because the website will be unambiguously defined according to the Domain field.

Configuration is ready for operation.

Logging In

  • Type in the browser address bar http://site1/bitrix/admin (or http://site2/bitrix/admin). The authorization panel will open.
  • Enter administrator’s data which you have indicated when installing product on the first site, and then you will access the administrative panel of Bitrix Site Manager

Since the kernel and the base are the same, the administrative panel for both websites will be the same.

Technically, the system permits creating any number of websites working pursuant to this principle. For each new website, a web server must be set up and a symbolic link must be created. Legally, an additional coupon must be acquired in order to create each new website (except for the first two websites).

Note: HTML cache is not supported with multisiting organized according to the second option.





Courses developed by Bitrix24

 Start the course