RockstarTom

Create a new system user for the new Odoo installation.

sudo adduser --system --home=/home/odoo17-NAME --group odoo17-NAME

Odoo 17 requires Python 3.10 – Check it’s installed and the right version:

Check Python 3 .10 is installed.

Check pip3 is installed.

Check Postgre is installed. If not > sudo apt install postgresql postgresql-client

Create new user for Postgre database.

sudo -u postgres createuser -s $USER

createdb $USER

Setup and install the database

sudo su - postgres
createuser --createdb --username postgres --no-createrole --no-superuser --pwprompt odoo17-NAME

#Create a database user
psql
ALTER USER odoo17-NAME WITH SUPERUSER;
\q
exit

(any special chars in usernames needs to be in "" double quotes!)

# Change to users directory
sudo su - odoo17-NAME -s /bin/bash
The operator dot(.) at the end of the command is used to clone the files to the current user’s home directory, which is /opt/odoo and was specified at the time of user creation. The following command will clone the source directory.
git clone https://www.github.com/odoo/odoo --depth 1 --branch 17.0 --single-branch .
Proceed with the installation after logging out of the user now.
exit

Install Required Python Packages

sudo pip3 install -r /opt/odoo/requirements.txt

Setup Conf file

Odoo requires certain information in order to function, such as the database user, password, locations of add-ons, etc. The configuration file will also have these available. Thus, the first thing we should do is create an Odoo configuration file. You can also find an example configuration file in the Odoo folder, which you can copy to the desired location. Configuration files are typically kept in /etc.
But that is just a pain in the ass so we’ll put our conf file in the instances directory for ease.
sudo cp /home/odoo17-NAME/debian/odoo.conf /home/odoo17-NAME/odoo17.conf
sudo nano /home/odoo17-NAME/odoo17.conf
Update the conf file same as shown in the code below. (log file is also in instance directory for ease!)
[options]
   ; This is the password that allows database operations:
   admin_passwd = admin
   db_host = False
   db_port = False
   db_user = odoo17
   db_password = False
   addons_path = /home/odoo17-NAME/addons, /home/odoo17-NAME/custom-modules
   logfile = /home/odoo17-NAME/odoo17.log

Use the custom-modules directory (you’ll need to create it) or don’t. It makes life much easier when adding new modules (add to this directory to test first).

Install dependencies

sudo apt install python3-pip libldap2-dev libpq-dev libsasl2-dev

Use virtual environment for python if required. https://pypi.org/project/virtualenv/

cd /CommunityPath
$ pip install -r requirements.txt

Apache config will need a VALID CA SLL Certificate (Not server self signed) in Virtualmin can do this on the panel (make sure dns control is setup correctly and auto renew is on).

Modify the relevant Apache conf file to proxy forward to the correct port for the relevant Odoo installation on the correct port. (You will need to have different ports for main and websockets so not 8069 and 8072 if already used.)

Run odoo-bin directly or create a service to run this instance of Odoo i.e. Odoo17-Name1 Odoo17-Name2 etc.

Addons path can have multiple arguments and should have! Leave the base modules in the Addons folder and use extra-modules for additional ones. (It’s much easier to manage then!)

open server on the main port at localhost or external IP (or if modified apache conf and setup dns to point to server ip the relevant domain name).

Create service:

Create a file called odoo17-NAME in the folder /etc/systemd/system

[Unit]
Description=Odoo17-NAME
Requires=postgresql.service
After=network.target postgresql.service

[Service]
Type=simple
SyslogIdentifier=odoo17-NAME
PermissionsStartOnly=true
User=odoo17-NAME
Group=odoo17-NAME
ExecStart=/home/odoo17-NAME/venv/bin/python3 /home/odoo17-NAME/odoo-bin -c /etc/odoo17.conf –logfile /home/odoo17-NAME/odoo17.log –log-handler :ERROR –log-handler werkzeug:CRITICAL –email-from EMAILADDRESS –smtp 127.0.0.1 –smtp-port 25 –smtp-user EMAILADDRESS –smtp-password PASSWORD

;SEE > https://www.odoo.com/documentation/14.0/developer/reference/cli.html

StandardOutput=journal+console

[Install]
WantedBy=multi-user.target

Finally, set the root user’s permissions for this service file.
sudo chmod 755 /etc/systemd/system/odoo17.service
sudo chown root: /etc/systemd/system/odoo17.service

sudo systemctl start odoo17-NAME.service

sudo systemctl status odoo17-NAME.service
sudo systemctl enable odoo17-NAME.service

To check the logs sudo journalctl -u odoo17-cd -e > /home/odoo17-cd/odoo.txt 



BACKUP DATABASE
cd /home/backups/odoo17/
sudo -u postgres pg_dump odoo17cd > odoo17cd_backup.sql

BACKUP DIRECTORY
tar -czvf odoo17cd_home_backup.tar.gz /home/odoo17cd/