Odoo.png

This tutorial will show you how to install the ERP and CRM platform Odoo. You can find what changes you need to make to your account, how to install Odoo automatically, how to install Odoo manually, how to force Odoo to always work over HTTPS, and how to use the odoo-bin CLI management tool to manage your Odoo installation.

Note: This guide has been tested with Odoo version 16.0.

Prerequisites

Before you install Odoo, there are a few settings to check and configure on your hosting account.

  • There must be a WebApps section in your hosting Control Panel. If you do not see a WebApps section, then this tutorial is not suitable for your particular hosting environment. You can contact us via our ticketing system for further assistance.

  • SSH access, Network tools, and Compiling tools must be enabled for your account via the hosting Control Panel > SSH Access section.

Quick (automatic) installation

To install and configure Odoo, you can upload this Odoo installation script to your account, set 755 permissions for it, and execute it via SSH. This can be easily achieved by connecting to your account via SSH and running the following command:

wget https://tickets.suresupport.com/faq_img/4620.sh -q -P /home/$USER/private && chmod 755 /home/$USER/private/4620.sh && /home/$USER/private/4620.sh && rm /home/$USER/private/4620.sh

The output of the Odoo installation script should look like this:
 Automatic installation output
The script will perform the following actions:

  • Set up PostgreSQL as per our Running a PostgreSQL Instance article if it is not already running.
  • Create a new PostgreSQL database and user for Odoo.
  • Download the latest version of Odoo from GIT to the ~/private/odoo1 directory.
  • Install dependencies in a Python virtual environment in the ~/private/odoo1/venv directory.
  • Create a web application with name "odoo1".
  • Install Odoo.
  • Configure the web application to run Odoo using the default server hostname for your account.
  • Start the web application.
  • Print Odoo URL and login credentials.

Important: To get Odoo working with a domain/subdomain of your account, you need to edit the "odoo1" web application and configure its Domain, Subdomain, and Web access path settings through the hosting Control Panel > WebApps section.

Manual installation

To install Odoo manually, you will need to connect to your account via SSH and follow the steps listed below.

Install PostgreSQL

Odoo uses PostgreSQL as database backend, so you need to have PostgreSQL installed on your account. If PostgreSQL is already installed and running on your account, you can skip this step. Otherwise, you can install PostgreSQL as a separate web application by running this command via SSH:

wget https://tickets.suresupport.com/faq_img/4166.sh -q -P /home/$USER/private && chmod 755 /home/$USER/private/4166.sh && /home/$USER/private/4166.sh postgres1 && rm /home/$USER/private/4166.sh && . "/home/$USER/.bashrc"


More details about the process of installing PostgreSQL on your account can be found in our Running a PostgreSQL Instance article.

Create a PostgreSQL database and user

After PostgreSQL is configured and running on your account, you will need to create a new database and user for Odoo. You can create a randomly generated user, password, and database by running these commands:

odoodbuser="$(pwgen -A 24 1)" && createuser -DRS $odoodbuser && echo -e "DB user: "$odoodbuser
odoodbpass="$(pwgen 24 1)" && psql postgres -c "alter user "$odoodbuser" with password '"$odoodbpass"';" && echo -e "DB pass: "$odoodbpass
odoodbname="$(pwgen -A 24 1)" && createdb -O $odoodbuser $odoodbname && echo -e "DB name: "$odoodbname

If you would like to use specific PostgreSQL user, password, and database, run these commands:

read -p 'Enter PostgreSQL user for Odoo: ' odoodbuser && createuser -e -DRS $odoodbuser
read -s -p 'Enter password for user '$odoodbuser': ' odoodbpass && echo && psql postgres -c "alter user "$odoodbuser" with password '"$odoodbpass"';"
read -p 'Enter PostgreSQL database name for Odoo: ' odoodbname && createdb -O $odoodbuser $odoodbname

 

Download Odoo

Next, you will need to download Odoo to your account. The easiest way to do this is to download the files from the Odoo GIT page to the directory where Odoo will be deployed (e.g. ~/private/odoo1). If the directory does not exist yet, you can create it by running this command:

mkdir /home/$USER/private/odoo1

You can clone the files of the latest version of Odoo to the desired deployment directory on your account (e.g. ~/private/odoo1) by running this command:

git clone --depth 1 https://github.com/odoo/odoo.git /home/$USER/private/odoo1

 

Set up a Python virtual environment

Since Odoo runs on Python, it is advisable to set up an isolated environment where you can install Python dependencies only for this application. You can achieve this by setting up a Python virtual environment with virtualenv in a "venv" folder within the Odoo deployment directory (e.g. ~/private/odoo1/venv) by running these commands:

mkdir -p "/home/$USER/.local/bin"
grep -q '^PATH=.*/.local/bin' "/home/$USER/.bashrc" || printf '\nPATH="/home/%s/.local/bin:$PATH"\nexport PATH\n' "$USER" >> "/home/$USER/.bashrc"
PATH="/home/$USER/.local/bin:$PATH"
export PATH
pip3 install virtualenv
virtualenv -p python3 "/home/$USER/private/odoo1/venv"
. "/home/$USER/private/odoo1/venv/bin/activate"

The last command activates the virtual environment.

Install dependencies

After the Python virtual environment is activated, you can proceed with upgrading Python and installing all the required packages for Odoo by executing these commands:

pip3 install -U pip
pip3 install -r /home/$USER/private/odoo1/requirements.txt

The commands may take a while to finish.

Create the web application

Use the sureapp CLI tool to create a web application named "odoo1" by running this command:

sureapp project create --engine custom --engine-version - --release-dir /home/$USER/private/odoo1 --start-cmd '. "/home/'$USER'/private/odoo1/venv/bin/activate" && python3 /home/'$USER'/private/odoo1/odoo-bin --config /home/'$USER'/private/odoo1/odoo.conf' odoo1

 

Configure Odoo

You will need to obtain the port of the web application as it required for the installation of Odoo. You can do this with the following command:

while [ -z "$odooappport" ]; do sleep 5; odooappport="$(sureapp project list | grep -E "odoo1.*/home/$USER/private/odoo1" | awk '{print $NF}')"; ((odoocounter++)) && ((odoocounter==12)) && echo 'Could not retrieve port...' && break; done; echo $odooappport

Alternatively, you can get the port from the Port column next to the "odoo1" web application inside the hosting Control Panel > WebApps section. If you do this, you will need to replace the $odooappport string with that port number in the installation command.

Run the following command to install and configure Odoo on your account:

python3 /home/$USER/private/odoo1/odoo-bin  --db_host /home/$USER/private/postgres1/run --db_user $odoodbuser --database $odoodbname --db_password $odoodbpass --http-port $odooappport -i base --stop-after-init --save --config /home/$USER/private/odoo1/odoo.conf

Please allow some time for the command to finish as the Odoo database initialization process is lengthy.

Configure the Odoo URL

Navigate to the hosting Control Panel > WebApps section and edit the web application by clicking on the edit.gif button (pencil icon) next to it. On the edit page, select the domain, subdomain, and directory where you would like Odoo to run, and click on the Update button.

Edit web application

Start the web application

Click on the Enable (Enable app) button to enable the web application.

Enable web application

Refresh the list until the web application State changes to OK and Status to Up.

Enabled web application

Access Odoo

To access Odoo, visit the URL you specified in the previous step. It will be listed in the URL tab for the web application and should lead you to the Odoo login page (e.g. http://www.example.com/web/login):

Odoo login page

You can log in using the default username and password for Odoo - "admin".

Force HTTPS

Odoo transmits authentication information in plain text, so forcing HTTPS for Odoo is strongly recommended. To do this, you need to install an SSL certificate on the server for your domain or subdomain. Once an SSL certificate is installed, click on the Enable button next to your domain/subdomain in the hosting Control Panel > SSL/HTTPS section > Force HTTPS subsection.

Manage Odoo via odoo-bin

If you need to run any commands with odoo-bin (the Odoo CLI tool), we would strongly recommend that you create the following simple wrapper script.

cat <<MANAGE_SH > "/home/$USER/private/odoo1/venv.sh"
#!/bin/sh
. "/home/$USER/private/odoo1/venv/bin/activate"
exec python3 "/home/$USER/private/odoo1/odoo-bin" "\$*"
MANAGE_SH
chmod 0700 "/home/$USER/private/odoo1/venv.sh"
ln -s "/home/$USER/private/odoo1/venv.sh" "/home/$USER/.local/bin/manage-odoo"

The script will allow you to use the manage-odoo command which will execute the odoo-bin CLI tool directly in the Python virtual environment configured for Odoo.