Linux Instructions

Linux Instructions

NodeJS Installation (Ubuntu)

Check if nodejs is installed with the command
node -v

If nodejs isn't installed, then:
sudo apt-get install curl (if curl isn't installed)
curl -sL https://deb.nodesource.com/setup_20.x | sudo -E bash -
sudo apt-get install -y nodejs

If it is installed, the version should be 20.x. If a different version is installed, check if the n version manager is installed and use it to install the 20 LTS version.

If n is not installed, then
a) check for nvm and, if so, remove it.
rm -rf ~/.nvm
remove any nvm lines from ~/.bash_profile (and/or ~/.profile)

b) install n
sudo npm i n -g

Check where the node file is located:
which node
If it's in /usr/local/bin, then everything is fine. If it's just in /bin, something is wrong.

Check the paths in ~/.profile or ~/.bash_profile

Configuring Automatic Application Startup

1. Copy start_mysales.sh and stop_mysales.sh to the mysales_dist application installation folder - Change attributes: chmod ug+x start_mysales.sh stop_mysales.sh 2. Copy mysales.service to the home folder of the user under which MySales is installed ~ 3. Edit the mysales.service file: - Insert the full path to the ExecStart, ExecStop, and WorkingDirectory scripts - Change the User and Group parameters according to the settings of the user under which MySales is installed - Specify the correct database service After= (mysql) if the database runs alongside the application 4. Set the service to autostart at startup by running it from the home directory (correcting the paths): sudo systemctl set-default multi-user sudo systemd-analyze verify /home/mysales/mysales.service sudo systemctl enable /home/mysales/mysales.service sudo systemctl daemon-reload sudo systemctl status mysales sudo systemctl start mysales sudo systemctl status mysales 5. You can start the service immediately to test it: systemctl restart mysales 7. Managing the service - Getting the service's status: sudo systemctl status mysales - Disable the service's autostart sudo systemctl disable mysales - View a list of all services sudo systemctl list-unit-files --type service -all - Analyze the configuration file sudo systemd-analyze verify /home/mysales/mysales.service - - Update the list of services sudo systemctl daemon-reload - When changing settings in the mysales.service file, you must reinstall it (enable/disable) to create the correct dependency links done Now the mysales server will automatically start upon restart and before user login, + restart on crash, error crash, or shutdown. View startup logs in /var/log/syslog || /var/log//messages

приклад файлу mysales.service

[Unit] Description=MySales application as service # mysql.service or appropriate db service # After=network.target mysql.service After=network.target [Service] ExecStart=/bin/bash /home/mysales/mysales_dist/start_mysales.sh ExecStop=/bin/bash /home/mysales/mysales_dist/stop_mysales.sh # Restart=on-failure User=mysales Group=mysales Environment=NODE_ENV=production WorkingDirectory=/home/mysales/mysales_dist/ RestartSec=10 Restart=always [Install] WantedBy=multi-user.target Alias=mysales.service

Installing PostgreSQL (Ubuntu)

# Create the file repository configuration: sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list' # Import the repository signing key: wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add - # Update the package lists: sudo apt-get update # Install the latest version of PostgreSQL. # If you want a specific version, use 'postgresql-12' or similar instead of 'postgresql': sudo apt-get -y install postgresql

sudo systemctl start postgresql

sudo nano /etc/postgresql/14/main/pg_hba.conf:

host       all   mysales  0.0.0.0/0  md5 #host       all   mysales  10.100.0.0/16 md5 #host       all   mysales  192.168.44.0/24 md5

sudo nano /etc/postgresql/14/main/postgresql.conf

listen_addresses = '*' # what IP address(es) to listen on;

sudo -u postgres psql -c "CREATE USER mysales WITH PASSWORD 'password'"

sudo -u postgres psql -c "ALTER USER mysales WITH PASSWORD 'password'"

sudo -u postgres psql

CREATE DATABASE mysales;

grant all privileges on database mysales to mysales;

sudo systemctl restart postgresql

 

Installing MySql (Ubuntu)

sudo apt update sudo apt upgrade sudo apt install mysql-server sudo mysql_secure_installation

Дивимось ще на інструкцію: https://stackoverflow.com/questions/51803216/lower-case-table-names-settings-in-mysql-8-0-12

Заходимо в MySql:

sudo mysql

SET GLOBAL validate_password.policy=LOW;

alter user 'root'@'localhost' identified by '7qaskfhb&#!823DD';

create database demo;

CREATE USER 'mystorage'@'localhost' identified by 'mystorage';

GRANT ALL PRIVILEGES ON demo.* To 'mystorage'@'localhost';

exit

mysql -u root -p demo < demo_dump.sql