1C-Bitrix website
1C-Bitrix: Site Management
In this tutorial, you will deploy and configure a website using the 1C-Bitrix information portal template. As part of the configuration, you will create a VM in Yandex Cloud, deploy the 1C-Bitrix image on it, and launch the necessary services. As a database, you will deploy a managed MySQL database cluster and ensure its fault tolerance.
Resources required for 1C-Bitrix to run correctly:
- A VM running Ubuntu 22.04 LTS with access to an external network and hosting 1C-Bitrix.
- A MySQL cluster that serves as a database for the 1C-Bitrix website.
To deploy and configure 1C-Bitrix:
- Prepare your cloud.
- Create and set up a cloud network.
- Create a VM in the cloud.
- Create a MySQL database cluster.
- Configure a server to work with 1C-Bitrix.
- Configure 1C-Bitrix.
If you no longer need the website, delete all its resources.
You can also deploy the infrastructure for hosting a website in Bitrix via Terraform using a ready-made configuration file.
Prepare your cloud
Sign up for Yandex Cloud and create a billing account:
- Go to the management console
and log in to Yandex Cloud or create an account if you do not have one yet. - On the Billing
page, make sure you have a billing account linked and it has theACTIVE
orTRIAL_ACTIVE
status. If you do not have a billing account, create one.
If you have an active billing account, you can go to the cloud page
Learn more about clouds and folders.
Required paid resources
The cost for maintaining the 1C-Bitrix server includes:
- Fee for Yandex Compute Cloud disks and continuously running VMs (see Yandex Compute Cloud pricing).
- Fee for using a dynamic or a static external IP address (see Yandex Virtual Private Cloud pricing).
- Fee for using a managed database (see pricing for Managed Service for MySQL).
The current scenario uses the trial version of 1C-Bitrix with a 30-day trial period. You can check the cost of the product software versions on the 1C-Bitrix
Create and set up a cloud network
-
Create a network named
network-1
. When creating your network, disable the Create subnets option. -
In
network-1
, create two subnets in different availability zones with the following parameters:-
Subnet in the
ru-central1-a
availability zone:- Name:
subnet-a
. - Zone:
ru-central1-a
. - CIDR:
192.168.0.0/24
.
- Name:
-
Subnet in the
ru-central1-b
availability zone:- Name:
subnet-b
. - Zone:
ru-central1-b
. - CIDR:
192.168.1.0/24
.
- Name:
-
-
In
network-1
, create security groups:-
Named
bitrix-sg-vm
for your VM in the cloud. Set rules for the security group based on the following table:Traffic
directionDescription Port range Protocol Source /
Destination nameCIDR blocks Outgoing ANY
All
Any
CIDR
0.0.0.0/0
Incoming HTTP
80
TCP
CIDR
0.0.0.0/0
Incoming EXT-HTTPS
443
TCP
CIDR
0.0.0.0/0
Incoming SSH
22
TCP
CIDR
0.0.0.0/0
-
Named
bitrix-sg
for a MySQL database cluster. Set rules for the security group based on the following table:Traffic
directionDescription Port range Protocol Source /
Destination nameCIDR blocks Outgoing ANY
All
Any
CIDR
0.0.0.0/0
Incoming EXT-HTTPS
3306
TCP
CIDR
0.0.0.0/0
-
Create a VM in the cloud
To create a VM:
-
In the management console
, select the folder to create the virtual machine in. -
In the list of services, select Compute Cloud.
-
Click Create VM.
-
In the Name field, enter a name for the VM, such as
bitrixwebsite
. -
In the Availability zone field, select
ru-central1-a
. -
Under Cloud Marketplace, select the Ubuntu 22.04 lts image.
-
Under Disks, select an
SSD
with24 GB
. -
Under Computing resources:
-
Choose a VM platform.
-
For 1C-Bitrix to run properly, specify the following configuration:
- Platform:
Intel Ice Lake
- Guaranteed vCPU share:
20%
- vCPU:
2
- RAM:
4 GB
- Platform:
-
-
Under Network settings:
- In the Subnet field, select the
subnet-a
subnet you created earlier. - Under Public address, keep Auto to assign your VM a random external IP address from the Yandex Cloud pool, or select a static address from the list if you reserved one in advance.
- In the Security group field, select the
bitrix-sg-vm
security group.
- In the Subnet field, select the
-
Under Access, specify the information required to access the VM:
- In the Login field, enter your preferred username to be created on the VM, for example,
ubuntu
. - In the SSH key field, paste your public SSH key. You need to create a key pair for the SSH connection yourself.
- In the Login field, enter your preferred username to be created on the VM, for example,
-
Click Create VM.
You may need to save disk snapshots of the VM. They contain a copy of the VM file system from when the snapshot was created.
You can use disk snapshots for various purposes, such as:
- Migrating data from one disk to another, for example, to a disk in a different availability zone.
- Creating a disk backup before performing operations that may cause damage to your data.
- Performing disk versioning by creating snapshots on a regular basis.
Create a MySQL database cluster
To create a MySQL database cluster:
-
On the folder page in the management console
, select Managed Service for MySQL. -
Click Create resource and select MySQL cluster.
-
In the Name field, enter the cluster name, for example,
BitrixMySQL
. -
Under Host class, select
s2.micro
. These characteristics are enough for 1C-Bitrix to run. -
Under Storage size, select the type of storage: 10 GB
network-ssd
. -
Under Database, enter:
- DB name. Leave the default value,
db1
. - Username to connect to the database. Leave the default value,
user1
. - Password for 1C-Bitrix to access the MySQL database, for example,
p@s$woRd!
.
- DB name. Leave the default value,
-
Under Network settings:
- In the Network field, select the
network-1
network you created earlier. - In the Security group field, select the
bitrix-sg
security group.
- In the Network field, select the
-
Under Hosts, change the Availability zone for the database. To do this, click
We recommend selecting the same availability zone as when you created the VM. This reduces latency between the VM and database.
-
To make your database fault-tolerant, you can add more hosts for it. To do this, select Add host and specify the availability zone to place it in.
-
Leave the other fields as they are.
-
Click Create cluster.
Creating a DB cluster may take a few minutes. To check that the new cluster is available, select Managed Service for MySQL in the Yandex Cloud management console. On the Clusters tab, the cluster status should be Running and its state should be Alive.
Configure a server to work with 1C-Bitrix
To configure the server to work with 1C-Bitrix:
-
Log in to the created server using SSH.
ssh ubuntu@<VM_public_IP_address>
Where
ubuntu
is the username in the Login field that you set when creating the VM.To find out the public IP address of your VM, on the folder page in the management console
:- Select the Compute Cloud section.
- Click the name of your VM ( bitrixwebsite in the example).
- A window will open with general information about your VM. You can find the public IP address in the Public IPv4 field under Network.
-
Install the required software:
sudo apt-get update sudo apt-get install -y apache2 libapache2-mod-php php-gd php-mbstring php-mysql
-
Go to the project's working folder and download the
1C-Bitrix: Site Management
distribution:cd /var/www/html/ sudo wget https://www.1c-bitrix.ru/download/standard_encode.tar.gz
-
Unpack the downloaded archive and delete unnecessary files:
sudo tar -zxf standard_encode.tar.gz sudo rm -f index.html standard_encode.tar.gz
-
Assign the
www-data
user as the owner of the working directory of the project:sudo chown -R www-data:www-data /var/www/html
Check the permissions and owners of the working folder:
ls -l
Result:
total 76 drwxrwxr-x 6 www-data www-data 4096 May 15 13:50 bitrix -rwxrwxr-x 1 www-data www-data 1378 May 15 13:50 index.php -rwxrwxr-x 1 www-data www-data 150 Mar 11 2013 install.config -rwxrwxr-x 1 www-data www-data 30741 Apr 10 14:36 license.html -rwxrwxr-x 1 www-data www-data 113 Nov 20 2012 license.php -rwxrwxr-x 1 www-data www-data 14054 Feb 6 2017 readme.html -rwxrwxr-x 1 www-data www-data 112 Mar 27 2013 readme.php drwxrwxr-x 2 www-data www-data 4096 May 15 13:50 upload -rwxrwxr-x 1 www-data www-data 691 Oct 27 2009 web.config
-
For proper operation of 1C, configure the PHP settings. To do this, use the built-in
nano
editor and modify the following variables in thephp.ini
configuration file:sudo nano /etc/php/8.1/apache2/php.ini
Previously Now short_open_tag = Off
short_open_tag = On
memory_limit = 128M
memory_limit = 256M
;date.timezone =
date.timezone = Europe/Moscow
;opcache.revalidate_freq =2
opcache.revalidate_freq =0
;session.save_path = "/var/lib/php/sessions"
session.save_path = "/var/lib/php/sessions"
The
php.ini
file path depends on the PHP version installed. The example shows the path for version8.1
. For version8.0
, enter/etc/php/8.0/apache2/php.ini
, for version8.2
, enter/etc/php/8.2/apache2/php.ini
, and so on.Tip
To find the parameter you need in the
nano
editor, press Ctrl + W. Look for the required parameter in the table above and save the changes using Ctrl + O. To exit the editor, press Ctrl + X. -
Configure the Apache web server. To do this, edit the
/etc/apache2/sites-enabled/000-default.conf
configuration file.-
Open the file in the text editor:
sudo nano /etc/apache2/sites-enabled/000-default.conf
-
Add the following block after the
DocumentRoot /var/www/html
line:<Directory /var/www/html> Options Indexes FollowSymLinks AllowOverride All Require all granted </Directory>
-
Restart the web server to apply all the new settings.
sudo service apache2 restart
-
After you run these commands, the server side is configured for proper operation of 1C-Bitrix.
Configure 1C-Bitrix
Install and configure 1C-Bitrix:
-
Open the 1C-Bitrix: Site Management web interface at:
http://<VM_public_IP_address>/
. A page should open asking you to install 1C-Bitrix. -
Click Next.
-
Read the license agreement and select I accept the license agreement. Then click Next.
-
Since registration is optional, uncheck the corresponding checkbox. Leave Install in UTF-8 encoding and click Next.
-
1C-Bitrix will check if the server is configured correctly. View all the parameters on this page and click Next.
-
Specify the parameters of the created database:
- In the Server field, enter the fully qualified domain name of the created database. To find it:
- In the management console
, open the folder page in a new browser tab. - Choose Managed Service for MySQL.
- Select the
BitrixMySQL
cluster you created in the table. - Select the Hosts tab in the left menu.
- Hover over the Hostname (such as
rc1c-cfazv1db********
) and copy the fully qualified domain name of the database by clickingrc1c-cfazv1db********.mdb.yandexcloud.net
.
- In the management console
- In the Username and Password fields, enter the data that you specified when creating the database in Create MySQL database cluster.
- In the Database name field, specify the name of the created database (
db1
). - Click Next.
- In the Server field, enter the fully qualified domain name of the created database. To find it:
-
Wait for the MySQL database to initialize.
-
Create an administrator account authorized to make changes to your system. Fill in all the fields and click Next.
-
Select the Information portal template and click Next.
-
Confirm the selection of the only layout template and click Next.
-
Select a color and click Next.
-
Fill in all the fields according to your website requirements and click Install. This will begin the installation and configuration of all system components. Wait for them to be completed.
-
After a while, a notification page will inform you that the system is installed and configured. To start working with the website, click Go to site.
-
The system is now ready to use. You are in the content editing mode of its web interface.
-
To view the website home page as a user, click Exit in the top-right corner of the page to exit from your website admin panel and go to
http://<VM_public_IP_address>/
. To return to edit mode, log in to the website using the 1C-Bitrix administrator credentials.
How to delete the resources you created
To stop paying for the deployed servers:
-
Delete the VM
bitrixwebsite
.If you reserved a static public IP address specifically for this VM:
- Select VPC in your folder.
- Go to the IP addresses tab.
- Find the required address, click
-
Delete the database cluster
BitrixMySQL
.
How to create an infrastructure using Terraform
With Terraform
For more information about the provider resources, see the documentation on the Terraform
If you change the configuration files, Terraform automatically determines which part of your configuration is already deployed and what should be added or removed.
To host your site in Bitrix via Terraform:
-
Install Terraform, get the authentication credentials, and specify the source for installing the Yandex Cloud provider (see Configure a provider, step 1).
-
Prepare files with the infrastructure description:
Ready-made archiveCreating files manually- Create a directory for files:
- Download the archive
(1 KB). - Unpack the archive to the directory. The
bitrix.tf
file should be added to the directory.
-
Create a directory for files:
-
Create the
bitrix.tf
configuration file in the directory:bitrix.tfvariable "folder_id" { type = string } variable "vm_user" { type = string } variable "ssh_key_path" { type = string } variable "mysql_user" { type = string } variable "mysql_password" { type = string sensitive = true } terraform { required_providers { yandex = { source = "yandex-cloud/yandex" version = ">= 0.47.0" } } } provider "yandex" { zone = var.folder_id } resource "yandex_vpc_network" "network-1" { name = "network1" } resource "yandex_vpc_subnet" "subnet-1" { name = "subnet1" zone = "ru-central1-a" network_id = yandex_vpc_network.network-1.id v4_cidr_blocks = ["192.168.1.0/24"] } resource "yandex_vpc_subnet" "subnet-2" { name = "subnet2" zone = "ru-central1-b" network_id = yandex_vpc_network.network-1.id v4_cidr_blocks = ["192.168.2.0/24"] } resource "yandex_vpc_subnet" "subnet-3" { name = "subnet3" zone = "ru-central1-d" network_id = yandex_vpc_network.network-1.id v4_cidr_blocks = ["192.168.3.0/24"] } resource "yandex_vpc_security_group" "sg-vm" { name = "bitrix-sg-vm" description = "Description for security group" network_id = yandex_vpc_network.network-1.id egress { protocol = "ANY" description = "ANY" v4_cidr_blocks = ["0.0.0.0/0"] from_port = 0 to_port = 65535 } ingress { protocol = "TCP" description = "EXT-HTTP" v4_cidr_blocks = ["0.0.0.0/0"] port = 80 } ingress { protocol = "TCP" description = "EXT-SSH" v4_cidr_blocks = ["0.0.0.0/0"] port = 22 } ingress { protocol = "TCP" description = "EXT-HTTPS" v4_cidr_blocks = ["0.0.0.0/0"] port = 443 } } resource "yandex_vpc_security_group" "sg-mysql" { name = "bitrix-sg" description = "Security group for mysql" network_id = yandex_vpc_network.network-1.id egress { protocol = "ANY" description = "any" v4_cidr_blocks = ["0.0.0.0/0"] from_port = 0 to_port = 65535 } ingress { protocol = "TCP" description = "ext-msql" v4_cidr_blocks = ["0.0.0.0/0"] port = 3306 } } data "yandex_compute_image" "ubuntu-image" { family = "ubuntu-2204-lts" } resource "yandex_compute_disk" "boot-disk" { name = "bootdisk" type = "network-ssd" zone = "ru-central1-a" size = "24" image_id = yandex_compute_image.ubuntu-image.id } resource "yandex_compute_instance" "vm-bitrix" { name = "bitrixwebsite" platform_id = "standard-v3" zone = "ru-central1-a" resources { core_fraction = 20 cores = 2 memory = 4 } boot_disk { disk_id = yandex_compute_disk.boot-disk.id } network_interface { subnet_id = yandex_vpc_subnet.subnet-1.id security_group_ids = ["${yandex_vpc_security_group.sg-vm.id}"] nat = true } metadata = { user-data = "#cloud-config\nusers:\n - name: ${var.vm_user}\n groups: sudo\n shell: /bin/bash\n sudo: 'ALL=(ALL) NOPASSWD:ALL'\n ssh-authorized-keys:\n - ${file("${var.ssh_key_path}")}" } } resource "yandex_mdb_mysql_cluster" "bitrix-cluster" { name = "BitrixMySQL" environment = "PRESTABLE" network_id = yandex_vpc_network.network-1.id version = "8.0" security_group_ids = ["${yandex_vpc_security_group.sg-mysql.id}"] resources { resource_preset_id = "s2.micro" disk_type_id = "network-hdd" disk_size = "10" } host { zone = "ru-central1-a" subnet_id = yandex_vpc_subnet.subnet-1.id assign_public_ip = false } host { zone = "ru-central1-b" subnet_id = yandex_vpc_subnet.subnet-2.id assign_public_ip = false } } resource "yandex_mdb_mysql_database" "bitrix-db" { cluster_id = yandex_mdb_mysql_cluster.bitrix-cluster.id name = "db1" } resource "yandex_mdb_mysql_user" "bitrix-user" { cluster_id = yandex_mdb_mysql_cluster.bitrix-cluster.id name = var.mysql_user password = var.mysql_password permission { database_name = yandex_mdb_mysql_database.bitrix-db.name roles = ["ALL"] } }
For more information about the parameters of resources used in Terraform, see the provider documentation:
-
Under
metadata
, enter your username and the contents of your SSH key. For more information, see VM metadata. -
Create resources:
-
In the terminal, change to the folder where you edited the configuration file.
-
Make sure the configuration file is correct using the command:
terraform validate
If the configuration is correct, the following message is returned:
Success! The configuration is valid.
-
Run the command:
terraform plan
The terminal will display a list of resources with parameters. No changes are made at this step. If the configuration contains errors, Terraform will point them out.
-
Apply the configuration changes:
terraform apply
-
Confirm the changes: type
yes
in the terminal and press Enter.
-