Improving the Efficiency of the Bitrix Content Management System
If you're considering improving your website's efficiency on the Bitrix CMS, the first step is to consider migrating the site to a Bitrix7 server. You can create a Bitrix7 server through your control panel.
You can either perform the migration yourself or seek help from our experts. All the details can be found in the article on Site Migration to the Server.
CMS Configuration
After migrating the site, you can begin configuring the content management system.
- Under the "System Check" section, there should be no error entries.
- In the "Performance Panel" section, under the "Bitrix" tab, the value should be "Bitrix (optimal)."
- 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 with configuring the server.
1. Connect to the server via SSH using the root user credentials.
2. Launch the Bitrix virtual environment menu using the command:
~/menu.sh
3. Select option 4, "Configure memcached servers."
4. This will initiate the memcached installation. During the installation, the system will prompt you to enter your server's hostname. You need to provide the ServerName value from the table displayed on the screen.
5. After installation, configure the configuration file /etc/sysconfig/memcached.
Open the configuration file in a text editor, such as nano:
nano /etc/sysconfig/memcached
If you don't have nano, you can install it using the command yum install nano or use any other available editor (e.g., vim).
Set the following parameters:
# number of simultaneous connections (default 1024)
MAXCONN="1024"
# amount of memory allocated for caching (default 64MB)
CACHESIZE="1024"
# number of memcached threads
OPTIONS="-t 4"
Save the changes.
6. Restart the service using the command:
systemctl restart memcached.service
7. Connect memcached in the file /bitrix/php_interface/dbconn.php. To do this, open the file:
nano /site_path/bitrix/php_interface/dbconn.php
Replace site_path with the actual path to your site's directory.
Specify the following parameters in the file:
Open the file /bitrix/php_interface/dbconn.php 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.
8. Open the file /bitrix/.settings_extra.php (if the file doesn't exist yet, it will be created if necessary) using the command:
nano /site_path/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.
Note that an improper memcached configuration might negatively impact performance. In case 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 step.
9. Besides enabling memcached, improving site performance can be achieved by moving the directory for MySQL temporary files to a RAM disk. Follow these steps:
9.1. Create a folder to store MySQL temporary files, for example, /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. Get the mysql user's (uid) and group's (gid) identifier:
id mysql
9.4. Edit the /etc/fstab file:
nano /etc/fstab
Append a line at 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 according to 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 allows using delayed transactions.