System requirements

Minimal system requirements for running server with BGERP + MySQL:

  • OS Linux, preferably RPM based: CentOS or RHEL, because the samples below;

  • CPU core equal Intel x86 500 MHz, recommended - 1 GHz;

  • 512 MB RAM, recommended - 1 GB.

Docker image

Installation from Docker image.

The Docker image is approximately 1 GB and contains the latest published build will all the required components: MySQL, Java. The actual Demo is also applied during first run.

This variant perfectly fits for following purposes:

  • having first look and playing with program;

  • running on Windows machines;

  • running in different environment, e.g. already installed MySQL with not appropriate version.

For removing container, also before update.

docker rm -f bgerp

The running container is available via Web-interface. Use NGINX for restricting access from outside network.

Data volumes inside (Win and *NIX)

In this case all the data volumes are hidden inside Docker.

All the related data is removed together with container.
docker pull bgerp/bgerp && docker run -d --name bgerp --restart unless-stopped -p 9088:9088 bgerp/bgerp && docker logs --follow bgerp

Data volumes outside (*NIX only)

docker pull bgerp/bgerp && docker run -d --name bgerp --restart unless-stopped \
    -v /srv/bgerp/data/mysql:/var/lib/mysql \
    -v /srv/bgerp/data/filestorage:/opt/bgerp/filestorage \
    -v /srv/bgerp/data/backup:/opt/bgerp/backup \
    -v /srv/bgerp/conf:/opt/bgerp/conf \
    -v /srv/bgerp/log:/opt/bgerp/log \
    -p 9088:9088 \
    bgerp/bgerp && docker logs --follow bgerp
Completely remove all the related data.
rm -rf /srv/bgerp

Deployment Script

A Bash script that runs on Debian/CentOS and performs:

  • deployment a Docker container with running BGERP;

  • configuration of NGINX with SSL access.

Prerequisites;

  • You need to be installed next packages: docker-ce, nginx, certbot, curl.

  • Run script with sudo or root

Switch to a working directory, e.g:

cd /tmp

Download the script using curl:

curl https://github.com/Pingvin235/bgerp/blob/master/srcx/deploy/deploy.sh --output bgerp_deploy.sh

Running:

sudo bash bgerp_deploy.sh <NAME> <PORT>

Where:

  • <NAME> - DNS server name used for the instance;

  • <PORT> - HTTP port exposed on localhost.

Example:

sudo bash bgerp_deploy.sh test.bgerp.org 9001

Linux server

Installation on Linux server.

MySQL

The Original MySQL DB Server version 8.0 or newer has to be used.

Different forks of MySQL (Maria, Percona) do not fit because of missing fulltext index support. Here is the test query to verify it:

// PzdcDoc snippet of: 'src/ru/bgcrm/plugin/fulltext/db.sql', lines: 1 - 9

CREATE TABLE IF NOT EXISTS fulltext_data (
        object_type VARCHAR(100) NOT NULL,
        object_id INT NOT NULL,
        scheduled_dt DATETIME,
        data TEXT NOT NULL,
        FULLTEXT (data) WITH PARSER ngram,
        KEY scheduled_dt (scheduled_dt),
        UNIQUE KEY type_id (object_type, object_id)
);

You can use the instruction for converting existing MySQL-like DB to the right version.

Install

Check the required options below in [mysqld] section in file my.cnf:

[mysqld]
sql-mode=
sql-mode must be set exactly to empty string, as shown in the example. If sql-mode is not defined - add it, if missing - make value DB creation script contains correctness of it any case.

Add missing sql-mode command:

sed -i '/\[mysqld\]/a sql-mode= ' /etc/mysql/my.cnf

You will also need a root access to the MySQL Server one time.

Java

Required version OpenJDK 17 or OpenJDK 11, may be installed so:

sudo yum update
sudo yum install -y java-17-openjdk-devel
Check, what commands java and javac are available after installation.

Application

All the operations require root user.

Check and install if needed script dependencies:

sudo yum update
sudo yum install -y epel-release
sudo yum install -y zip pwgen wget mysql-community-client unzip

Download archive and unpack it:

wget https://bgerp.org/download/3.0/bgerp.zip -O /tmp/bgerp.zip &&
unzip /tmp/bgerp.zip -d /opt &&
chmod 744 /opt/bgerp/*.sh

Generate DB password ant put it in files:

ERP_DB_PWD=`pwgen -y -c 20` && export EPR_DB_PWD &&
echo "Setting DB password: '$ERP_DB_PWD'" &&
sed -i "s/GENERATED_PASSWORD/$ERP_DB_PWD/" /opt/bgerp/bgerp.properties &&
sed -i "s/GENERATED_PASSWORD/'$ERP_DB_PWD'/" /opt/bgerp/db_create.sql

Run DB user and structure creation:

mysql --default-character-set=utf8 -h127.0.0.1 -uroot -p < /opt/bgerp/db_create.sql
mysql --default-character-set=utf8 -h127.0.0.1 -ubgerp -p$ERP_DB_PWD < /opt/bgerp/db_init.sql

Apply data from the Demo:

wget https://demo.bgerp.org/bgerp.sql -O /opt/bgerp/bgerp.sql
mysql --default-character-set=utf8 -h127.0.0.1 -uroot -p bgerp < /opt/bgerp/bgerp.sql

Change if needed in bgerp.properties DB server host, HTTP and management ports, in setenv.sh JAVA_HOME:

JAVA_HOME=/usr
if [ -z "$JAVA_HOME" ]; then
  echo "The JAVA_HOME environment variable is not defined"
  echo "This environment variable is needed to run this program"
  exit 1
fi

java and javac are looked in $JAVA_HOME/bin/

For starting/stopping use erp_start.sh/erp_stop.sh. erp_status.sh - shows current status of the application. After starting check log/bgerp.log and log/bgerp.out on errors.

The running application is available via Web-interface.

Systemd

Скрипт сервиса Systemd расположен в scripts/bgerp.service, переместите его в каталог /etc/systemd/system/. Затем выполните команды:

systemctl daemon-reload
systemctl enable bgerp

Для автозапуска приложения при загрузке системы.

Demo System

The Demo System is running on https://demo.bgerp.org with the latest published builds of software and resets to initial state any 3rd hour CET time. Both, software and data for the demo system are provided from master branch. DB content of the system is identical to Docker Container that should be preferred in case of you going to do changes.

Обновление

Изучите лог обновлений, там могут содержаться важные сведения либо инструкции.

Интерфейс

В оснастке Администрирование / Приложение / Статус приложения доступен просмотр текущей версии приложения, списка с логами обновлений. Для всех операций неявно используется консольная утилита, описанная далее.

i0128

Раздел Update - обновление на текущую версию системы и набора библиотек. Выполняемая команда:

./backup.sh && ./installer.sh update(f) && ./erp_restart.sh

Раздел Update on change - загрузка пакетов обновления изменения по коду процесса. Выполняемая команда:

./backup.sh && ./installer.sh install update_3.0_xxxx.zip && ./erp_restart.sh
Повторное Обновление после Обновления на изменение позволит сбросить сервер в состояние последнего релиза.

Консольные утилиты

Перед установкой обновления всегда делайте резервную копию программы при помощи скрипта backup.sh

  • При указании параметра db скрипт создаст резервную копию БД, данные для подключения к серверу MySQL берутся из файла bgerp.properties

  • Резервные копии сохраняются в папке backup в файлах с форматом имени год-месяц-дата-время(.db).zip, наличие подстроки db означает, что в архиве есть дамп БД

Для обновления вызовите команду:

./installer.sh update

Для обновления системы на иную версию (не 3.0) вызовите команду:

./installer.sh update <version>

например:

./installer.sh update 3.0

Running without arguments prints the help.

Commands for installer:
         update            - update to the actual builds if they differ from currents.
         updatef           - update to the actual builds without comparison.
         update <version>  - switch to another version (not build) of the program.
         killhash          - clear executed queries history.
         install <zip>     - install a module from the zip file.
         installc <change> - download update files from <change> and install them.

Recommended command for updating (argument 'db' can be excluded for speeding up and used only periodically):

./backup.sh db && ./installer.sh update && ./erp_restart.sh

Update files are taken from version-containing URL, for example for version 3.0: https://bgerp.org/download/3.0/

Хранимые процедуры обновления

Для изменений структуры БД в скриптах внутри пакетов обновлении используются хранимые процедуры. Например:

CALL add_column_if_not_exists('task', 'config', 'TEXT NOT NULL');

При восстановлении БД из резервной копии они могут пропасть. Процедура обновления происходит с ошибками. В этом случае необходимо выполнить следующие команды:

./installer.sh killhash
./installer.sh updatef

Первая удаляет из БД информацию о уже применённых обновлениях структуры, вторая - производит повторное выполнение всех скриптов.

NGINX

Typically the application is running in Intranet, access to restricted interfaces from outside as well as SSL may be organized using NGINX.

Example

The application is runnun on internal host erp.int.bitel.ru. Outside on host erp.bitel.ru is available only open interface http://erp.bitel.ru/open The configuration may be typically placed in file /etc/nginx/conf.d/erp.bitel.ru

server {
    server_name             erp.bitel.ru;

    access_log              /var/log/nginx/erp.bitel.ru.access.log;
    client_max_body_size    50m;

    # optionally close access without interface
    #location / {
    #    return 404;
    #}

    # for opening user interface - add admin|login.do|user
    # for opening user mobile interface - add usermob
    location ~ ^/(open|img|images|css|lib|js)(.*)$ {
        if ($args = '') {
            proxy_pass  http://erp.int.bitel.ru/$1$2;
        }
        if ($args != '') {
            proxy_pass  http://erp.int.bitel.ru/$1$2?$args;
        }
        proxy_set_header        Host $host;
        proxy_set_header        Connection close;
        proxy_set_header        X-Real-IP $remote_addr;
        proxy_read_timeout      300;
        gzip_proxied            any;
    }

    # this part has to be generated first by CertBot:
    # certbot --nginx -d bgerp.ru -d www.bgerp.ru -d bgerp.de -d www.bgerp.de -d bgerp.org -d www.bgerp.org
    listen 443 ssl; # managed by Certbot
    listen [::]:443 ssl; # managed by Certbot
    ssl_certificate /etc/letsencrypt/live/erp.bitel.ru/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/erp.bitel.ru/privkey.pem; # managed by Certbot
    include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
}

# redirect HTTP to HTTPS
server {
    listen      80;
    listen      [::]:80;
    server_name crm.bitel.ru;
    server_name team.bgerp.org;
    return 301  https://$host$request_uri;
}