red<\/span> to the correct values for your VPS.<\/p>\nNext, run the following command to upgrade all installed packages on your VPS:<\/p>\n
dnf update -y<\/pre>\nOnce all the packages are updated, it is necessary to disable SELinux on your system. You can disable it by editing the config file found at \/etc\/selinux\/config<\/code> :<\/p>\nnano \/etc\/selinux\/config<\/pre>\nChange the following line:<\/p>\n
SELINUX=disabled\r\n<\/pre>\nSave and close the file, then restart your server to apply the changes.<\/p>\n
<\/span>Step 2: Install Required Dependencies<\/span><\/h2>\nNext, you will need to install Python and other Flectra dependencies onto your system. You can install all of them in one go by running the following command:<\/p>\n
dnf install python36 python36-devel git gcc wget nodejs libxslt-devel bzip2-devel openldap-devel libjpeg-devel freetype-devel -y<\/pre>\nOnce all of the packages are installed, run the following command to install the Node.js<\/code> module:<\/p>\nnpm install -g less<\/pre>\nNext, you will also need to install the\u00a0wkhtmltopdf<\/code> package in your system (it renders html documents as PDFs) You can download it with the following command:<\/p>\nwget https:\/\/downloads.wkhtmltopdf.org\/0.12\/0.12.5\/wkhtmltox-0.12.5-1.centos7.x86_64.rpm<\/pre>\nNext, install the downloaded file with the following command:<\/p>\n
dnf localinstall wkhtmltox-0.12.5-1.centos7.x86_64.rpm<\/pre>\nOnce you are done, you can proceed to the next step.<\/p>\n
<\/span>Step 3: Install PostgreSQL<\/span><\/h2>\nNext, you will need to install PostgreSQL to serve as the database back-end. You can install it with the following command:<\/p>\n
dnf install -y postgresql-server<\/pre>\nOnce installed, initialize the database with the following command:<\/p>\n
postgresql-setup --initdb --unit postgresql<\/pre>\nYou should get the following output:<\/p>\n
* Initializing database in '\/var\/lib\/pgsql\/data'\r\n * Initialized, logs are in \/var\/lib\/pgsql\/initdb_postgresql.log\r\n<\/pre>\nNext, start the PostgreSQL service and enable it to start at boot with the following commands:<\/p>\n
systemctl start postgresql\r\nsystemctl enable postgresql<\/pre>\nNext, login to the PostgreSQL shell and create a new PostgreSQL user with the following command. We’re using the name flectra<\/code>, but you can use any name you like:<\/p>\nsu - postgres -c \"createuser -s flectra\"<\/pre>\n<\/span>Step 4: Install Flectra<\/span><\/h2>\nFinally, after setting up all of the required software, we can now install Flectra on our system. Create a separate user for Flectra using the following command. We’re using the name flectra<\/code>\u00a0because the names between this and PostgreSQL have to match. Make sure that the username you choose is the same as the PostgreSQL user that you created earlier:<\/p>\nuseradd -m -U -r -d \/opt\/flectra -s \/bin\/bash flectra<\/pre>\nThen login with the Flectra user and download Flectra from the Git repository:<\/p>\n
su - flectra\r\ngit clone --depth=1 --branch=1.0 https:\/\/gitlab.com\/flectra-hq\/flectra.git flectra<\/pre>\nAfter that, create a virtual environment for Flectra, we’re naming it flectra-venv<\/code>, but you can use any name you like:<\/p>\npython3 -m venv flectra-venv<\/pre>\nNow, activate the virtual environment with the following command:<\/p>\n
source flectra-venv\/bin\/activate<\/pre>\nAfterwards, install all Python modules with the following command. Python will read from the file and install everything that Flectra needs:<\/p>\n
pip3 install -r flectra\/requirements.txt<\/pre>\nOnce all modules are installed, deactivate the virtual environment with the following command:<\/p>\n
deactivate<\/pre>\nFinally, exit from the Flectra user using the following command:<\/p>\n
exit<\/pre>\n<\/span>Step 5: Configure Flectra<\/span><\/h2>\nFlectra is now installed, but we still need to configure it. First, you will need to create several directories for Flectra addons, configuration files, and logs. You can create them with the following command. We chose these common locations, but you can create these folders and files anywhere you like:<\/p>\n
mkdir \/opt\/flectra\/flectra-custom-addons\r\nmkdir \/var\/log\/flectra\r\nmkdir \/etc\/flectra\r\ntouch \/var\/log\/flectra\/flectra.log<\/pre>\nNext, change the ownership of the above directories to flectra:<\/p>\n
chown -R flectra:flectra \/opt\/flectra\/flectra-custom-addons\r\nchown -R flectra:flectra \/var\/log\/flectra\/\r\nchown -R flectra:flectra \/etc\/flectra<\/pre>\nOnce that’s done, create a Flectra configuration file with the following command:<\/p>\n
nano \/etc\/flectra\/flectra.conf<\/pre>\nAdd the following lines – change the admin_passwd<\/code> field to contain the password you wish to use for the admin account. Additionally, change the paths for the files\/folders if you chose different locations from the ones in this tutorial:<\/p>\n[options]\r\nadmin_passwd = your-password\r\ndb_host = False\r\ndb_port = False\r\ndb_user = flectra\r\ndb_password = False\r\nlogfile = \/var\/log\/flectra\/flectra.log\r\nlogrotate = True\r\nproxy_mode = True\r\naddons_path = \/opt\/flectra\/flectra\/addons, \/opt\/flectra\/flectra-custom-addons\r\n<\/pre>\nSave and close the file when you are finished.<\/p>\n
<\/span>Step 6: Create a Systemd File for Flectra<\/span><\/h2>\nNext, create a systemd service file for Flectra to manage the Flectra service.<\/p>\n
nano \/etc\/systemd\/system\/flectra.service<\/pre>\nAdd the following lines:<\/p>\n
[Unit]\r\nDescription=flectra\r\n#Requires=postgresql-10.6.service\r\n#After=network.target postgresql-10.6.service\r\n\r\n[Service]\r\nType=simple\r\nSyslogIdentifier=flectra\r\nPermissionsStartOnly=true\r\nUser=flectra\r\nGroup=flectra\r\nExecStart=\/opt\/flectra\/flectra-venv\/bin\/python3 \/opt\/flectra\/flectra\/flectra-bin -c \/etc\/flectra\/flectra.conf\r\nStandardOutput=journal+console\r\n\r\n[Install]\r\nWantedBy=multi-user.target\r\n<\/pre>\nSave and close the file once you are finished. Then, reload the systemd daemon with the following command. This is needed so that systemd can recognize and acknowledge the newly added service:<\/p>\n
systemctl daemon-reload<\/pre>\nNext, start the Flectra service and enable it to start at system reboot with the following command:<\/p>\n
systemctl start flectra\r\nsystemctl enable flectra<\/pre>\nYou can also verify the status of your Flectra service with the following command:<\/p>\n
systemctl status flectra<\/pre>\nYou should get the following output:<\/p>\n
\u25cf flectra.service - flectra\r\n Loaded: loaded (\/etc\/systemd\/system\/flectra.service; disabled; vendor preset: disabled)\r\n Active: active (running) since Sun 2020-06-28 03:23:58 EDT; 7s ago\r\n Main PID: 25512 (python3)\r\n Tasks: 4 (limit: 12537)\r\n Memory: 90.8M\r\n CGroup: \/system.slice\/flectra.service\r\n \u2514\u250025512 \/opt\/flectra\/flectra-venv\/bin\/python3 \/opt\/flectra\/flectra\/flectra-bin -c \/etc\/flectra\/flectra.conf\r\n\r\nJun 28 03:23:58 centos8 systemd[1]: Started flectra.\r\nJun 28 03:24:00 centos8 flectra[25512]: 2020-06-28 07:24:00,365 25512 INFO ? flectra: Flectra version 1.7\r\nJun 28 03:24:00 centos8 flectra[25512]: 2020-06-28 07:24:00,368 25512 INFO ? flectra: Using configuration file at \/etc\/flectra\/flectra.conf\r\nJun 28 03:24:00 centos8 flectra[25512]: 2020-06-28 07:24:00,368 25512 INFO ? flectra: addons paths: ['\/opt\/flectra\/.local\/share\/Flectra\/addons>\r\nJun 28 03:24:00 centos8 flectra[25512]: 2020-06-28 07:24:00,369 25512 INFO ? flectra: database: flectra@default:default\r\nJun 28 03:24:00 centos8 flectra[25512]: 2020-06-28 07:24:00,495 25512 INFO ? flectra.service.server: HTTP service (werkzeug) running on centos>\r\nJun 28 03:24:00 centos8 flectra[25512]: 2020-06-28 07:24:00,719 25512 INFO ? flectra.addons.base.ir.ir_actions_report: Will use the Wkhtmltopd>\r\n<\/pre>\nNow Flectra is running and listening on port 7073. You can verify it with the following command:<\/p>\n
netstat -plntu | grep 7073<\/pre>\nYou should see the following output:<\/p>\n
tcp 0 0 0.0.0.0:7073 0.0.0.0:* LISTEN 25967\/python3 \r\n<\/pre>\n