<\/span><\/h2>\nTo begin, you will need to install the Python package and a few other Flectra dependencies in your system. You can install all of them using the following command:<\/p>\n
apt-get install gcc python3-venv build-essential python3-pillow python3-wheel python3-lxml python3-dev python3-pip python3-setuptools npm nodejs git gdebi libldap2-dev libsasl2-dev libxml2-dev libxslt1-dev libjpeg-dev libpq-dev -y<\/pre>\nOnce all the dependencies are installed, you will need to install wkhtmltopdf<\/code> tool in your system.<\/p>\nYou can download and install it with the following command:<\/p>\n
wget https:\/\/github.com\/wkhtmltopdf\/wkhtmltopdf\/releases\/download\/0.12.5\/wkhtmltox_0.12.5-1.bionic_amd64.deb\napt install .\/wkhtmltox_0.12.5-1.bionic_amd64.deb<\/pre>\nOnce installed, you can proceed to the next step.<\/p>\n
<\/span>Step 3 – Install PostgreSQL<\/span><\/h2>\nFlectra requires PostgreSQL in order to store its data in a database. You can install it with the following command:<\/p>\n
apt-get install postgresql -y<\/pre>\nOnce the installation is completed, use the PostgreSQL utility and create a user for Flectra with the following command. We named our user 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>\nFirst, create a separate user for Flectra with the following command. The name of this user should be the same as your PostgreSQL user:<\/p>\n
useradd -m -U -r -d \/opt\/flectra -s \/bin\/bash flectra<\/pre>\nOnce the user is made, log in with your Flectra user and download the Flectra source from the official Git repository:<\/p>\n
su - flectra\ngit clone --depth=1 --branch=1.0 https:\/\/gitlab.com\/flectra-hq\/flectra.git flectra<\/pre>\nAfter that, create a Flectra virtual environment with the following command:<\/p>\n
python3 -m venv flectra-venv<\/pre>\nNext, activate the virtual environment with the following command:<\/p>\n
source flectra-venv\/bin\/activate<\/pre>\nBy default, Ubuntu 20.04 comes with Python version 3.8.2. So you will need to update the requirements.txt<\/code> file to prevent the psucopg2<\/code> error when installing Flectra 1.7.<\/p>\nYou can prevent this error by modifying default requirements.txt<\/code> file:<\/p>\nnano flectra\/requirements.txt<\/pre>\nFind the following lines:<\/p>\n
psycopg2==2.7.3.1; sys_platform != 'win32'\npsycopg2==2.8.3; sys_platform == 'win32'\n<\/pre>\nAnd, update them with the following lines:<\/p>\n
psycopg2==2.8.5; sys_platform != 'win32'\npsycopg2==2.8.5; sys_platform == 'win32'\n<\/pre>\nSave and close the file then install the wheel<\/code> module with the following command:<\/p>\npip3 install wheel<\/pre>\nNext, install all required Python modules with the following command:<\/p>\n
pip3 install -r flectra\/requirements.txt<\/pre>\nOnce all the modules are installed, deactivate from the virtual environment with the following command:<\/p>\n
deactivate<\/pre>\nNext, exit from the Flectra user using the following command:<\/p>\n
exit<\/pre>\n<\/span>Step 5 – Configure Flectra<\/span><\/h2>\nNext, you will need to create a directory structure for Flectra to store addons, configuration files and logs.<\/p>\n
You can create it with the following command:<\/p>\n
mkdir \/opt\/flectra\/flectra-custom-addons\nmkdir \/var\/log\/flectra\ntouch \/var\/log\/flectra\/flectra.log\nmkdir \/etc\/flectra\n<\/pre>\nNext, change the ownership of the above directories to Flectra as shown below:<\/p>\n
chown -R flectra:flectra \/opt\/flectra\/flectra-custom-addons\nchown -R flectra:flectra \/var\/log\/flectra\/\nchown -R flectra:flectra \/etc\/flectra<\/pre>\nNext, create a Flectra configuration file with the following command:<\/p>\n
nano \/etc\/flectra\/flectra.conf<\/pre>\nAdd the following lines:<\/p>\n
[options]\nadmin_passwd = your-password<\/span>\ndb_host = False\ndb_port = False\ndb_user = flectra\ndb_password = False\nlogfile = \/var\/log\/flectra\/flectra.log\nlogrotate = True\nproxy_mode = True\naddons_path = \/opt\/flectra\/flectra\/addons, \/opt\/flectra\/flectra-custom-addons\n<\/pre>\nMake sure you set your-password<\/code> to a good and strong password. Save and close the file when you are finished.<\/p>\n<\/span>Step 6 – Create a Systemd Service File for Flectra<\/span><\/h2>\nFlectra is more or less set up, however we have no way to manage it as a service currently. To fix this, we will create a systemd service file to manage the Flectra service. Create a new service file using this command:<\/p>\n
nano \/etc\/systemd\/system\/flectra.service<\/pre>\nThen add the following lines:<\/p>\n
[Unit]\nDescription=flectra\n#Requires=postgresql-10.6.service\n#After=network.target postgresql-10.6.service\n\n[Service]\nType=simple\nSyslogIdentifier=flectra\nPermissionsStartOnly=true\nUser=flectra\nGroup=flectra\nExecStart=\/opt\/flectra\/flectra-venv\/bin\/python3 \/opt\/flectra\/flectra\/flectra-bin -c \/etc\/flectra\/flectra.conf\nStandardOutput=journal+console\n\n[Install]\nWantedBy=multi-user.target\n<\/pre>\nSave and close the file. Then, reload the systemd daemon list with the following command:<\/p>\n
systemctl daemon-reload<\/pre>\nNext, start the Flectra service and enable it to start at boot using the following command:<\/p>\n
systemctl start flectra\nsystemctl enable flectra<\/pre>\nNow you can verify the port that Flectra is listening on using the following command:<\/p>\n
netstat -plntu | grep 7073<\/pre>\nYou should get the following output:<\/p>\n
tcp 0 0 0.0.0.0:7073 0.0.0.0:* LISTEN 110833\/python3<\/pre>\nFlectra is now set up and running.<\/p>\n