Help

Improving the Efficiency of Bitrix Content Management System

If you're considering enhancing the efficiency of your website on the Bitrix CMS, the first step is to contemplate transferring the site to a server with Bitrix7. Creating a server with Bitrix7 is available through your control panel.

You can perform the transfer independently or seek assistance from our experts. All the details can be found in the article about Transferring a Site to the Server.

Configuring the CMS

After the site transfer, you can begin configuring the content management system.

  1. Under the "System Check" section, there should be no entries with errors.
  2. In the "Performance Panel" section, under the "Bitrix" tab, the value should be "Bitrix (optimal)".
  3. Change the database table type to InnoDB and optimize the database. It's recommended to create a backup beforehand.

Server Configuration

Next, you can proceed to configure the server.

1. Connect to the server via SSH using the root user's credentials.

2. Launch the Bitrix virtual environment menu using the command:

~/menu.sh

3. Choose option 4, "Configure memcached servers."

4. The installation of memcached will begin. During the installation process, the system will prompt you to enter your server's hostname. You need to specify the ServerName value from the table displayed on the screen.

5. After installation is complete, configure the /etc/sysconfig/memcached configuration file.

Open the configuration file in a text editor, such as nano:

nano /etc/sysconfig/memcached

If nano is not available, you can install it using the command yum install nano or use another available editor like vim.

Set the following parameters:

# Number of concurrent connections (default is 1024)
MAXCONN="1024"

# Allocated memory size for cache (default is 64MB)
CACHESIZE="1024"

# Number of memcached threads
OPTIONS="-t 4"

Save the changes you've made.

6. Restart the service using the command:

systemctl restart memcached.service

7. Connect memcached in the /bitrix/php_interface/dbconn.php file. To do this, open the file:

nano /path_to_site_directory/bitrix/php_interface/dbconn.php

Replace path_to_site_directory with the actual path to your site's directory.

Specify the following parameters in the file:

Open the /bitrix/php_interface/dbconn.php file and add the following lines:

define("BX_CACHE_TYPE", "memcache");
define("BX_CACHE_SID", $_SERVER["DOCUMENT_ROOT"]."#01");
define("BX_MEMCACHE_HOST", "127.0.0.1");
define("BX_MEMCACHE_PORT", "11211");

Save the changes you've made.

8. Open the /bitrix/.settings_extra.php file (if the file doesn't exist yet, it will be created as needed) using the command:

nano /path_to_site_directory/bitrix/.settings_extra.php

Insert the following code into the file:

<?php
return array(
  'cache' => array(
    'value' => array(
      'type' => 'memcache',
      'memcache' => array(
        'host' => '127.0.0.1',
        'port' => '11211',
      ),
      'sid' => $_SERVER["DOCUMENT_ROOT"]."#01"
    ),
  ),
);
?>

Save the changes.

Please note that incorrect memcached configuration can negatively impact performance. If you notice a decrease in performance, you can experiment with the values in the configuration file /etc/sysconfig/memcached, which was configured in the previous steps.

9. In addition to enabling memcached, you can enhance site performance by moving the directory for MySQL temporary files to a RAM disk. Follow these steps to do so:

9.1. Create a folder to store MySQL temporary files, such as /var/lib/mysql/tmp:

mkdir /var/lib/mysql/tmp

9.2. Change the folder's owner and group to mysql:

chown mysql:mysql /var/lib/mysql/tmp

9.3. Obtain the mysql user's identifier (uid) and group identifier (gid):

id mysql

9.4. Edit the /etc/fstab file:

nano /etc/fstab

Add a line to the end of the file using the obtained values:

tmpfs /var/lib/mysql/tmp tmpfs rw,gid=27,uid=27,size=1G,nr_inodes=10k,mode=0700 0 0

Adjust the size parameter depending on the available RAM.

9.5. Mount the new tmpfs partition:

mount /var/lib/mysql/tmp

9.6. In the MySQL configuration file /etc/mysql/my.cnf, add the line:

tmpdir=/var/lib/mysql/tmp

9.7. Restart the MySQL service:

systemctl restart mysqld

10. In the file /etc/mysql/conf.d/z_bx_custom.cnf, add the parameter:

innodb_flush_log_at_trx_commit = 0

This parameter enables the use of delayed transactions.

Have more questions about Hosting?