Install Odoo 12 on CentOS 7

By 

Published on

5 min read

Install Odoo 11 in virtual environment on CentOS 7

Odoo is the most popular all-in-one business software in the world. It offers a range of business applications including CRM, website, e-Commerce, billing, accounting, manufacturing, warehouse, project management, inventory and much more, all seamlessly integrated.

In this tutorial, we’ll show you how to install Odoo 12 from source inside a Python virtual environment on a CentOS 7 machine.

Prerequisites

Make sure you are logged in as a user with sudo privileges before proceeding with the tutorial.

Install Python 3.6 and Odoo Dependencies

We will install Python 3.6 packages from the Software Collections (SCL) repository.

By enabling SCL you will gain access to the newer versions of programming languages and services which are not available in the core repositories.

Enable the EPEL and SCL repositories with the following command:

Terminal
sudo yum install epel-release centos-release-scl

Once the repositories are enabled, install Python 3.6 all the tools required to build Odoo dependencies:

Terminal
sudo yum install rh-python36 git gcc wget nodejs-less libxslt-devel bzip2-devel openldap-devel libjpeg-devel freetype-devel

During the installation you will be prompted to accept the GPG keys.

Create Odoo User

Create a new system user and group with home directory /opt/odoo that will run the Odoo service:

Terminal
sudo useradd -m -U -r -d /opt/odoo12 -s /bin/bash odoo12
Tip
You can name the user whatever you like, just make sure you create a PostgreSQL user with the same name.

Install and configure PostgreSQL

At the time of writing this article, the latest version of PostgreSQL available from the CentOS repositories is PostgreSQL version 9.2 which is not officially supported by Odoo.

We’ll install PostgreSQL 10 from the official PostgreSQL repositories.

Start by enabling the PostgreSQL repository:

Terminal
sudo yum install https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm

Install the PostgreSQL server and create a new PostgreSQL database cluster:

Terminal
sudo yum install postgresql10-server postgresql10-devel
sudo /usr/pgsql-10/bin/postgresql-10-setup initdb

Once the installation is completed, enable and start the PostgreSQL service:

Terminal
sudo systemctl enable postgresql-10
sudo systemctl start postgresql-10

Create a PostgreSQL user with the same name as the previously created system user, in our case odoo12:

Terminal
sudo su - postgres -c "createuser -s odoo12"

Install Wkhtmltopdf

The wkhtmltox package provides a set of open-source command line tools which can render HTML into PDF and various image formats. In order to print PDF reports, you will need the wkhtmltopdf tool. The recommended version for Odoo is 0.12.1 which is not available in the official CentOS 7 repositories.

Download the recommended version with the following wget command :

Terminal
wget https://github.com/wkhtmltopdf/wkhtmltopdf/releases/download/0.12.1/wkhtmltox-0.12.1_linux-centos7-amd64.rpm

Once the download is complete, install the rpm package by typing:

Terminal
sudo yum localinstall wkhtmltox-0.12.1_linux-centos7-amd64.rpm

Install and Configure Odoo 12

Before starting with the installation process, make sure you switch to user “odoo12”:

Terminal
sudo su - odoo12

Start by cloning the Odoo 12 source code from the Odoo GitHub repository:

Terminal
git clone https://www.github.com/odoo/odoo --depth 1 --branch 12.0 /opt/odoo12/odoo

Enable software collections so we can access the python 3.6 binaries:

Terminal
scl enable rh-python36 bash

Create a new Python virtual environment for the Odoo installation with:

Terminal
cd /opt/odoo12
python3 -m venv venv

Activate the environment:

Terminal
source venv/bin/activate

Install all required Python modules:

Terminal
pip3 install -r odoo/requirements.txt
Info
If you encounter any compilation errors during the installation, make sure that you installed all of the required dependencies listed in the Install Python 3.6 and Odoo Dependencies section.

Once the installation is completed deactivate the environment using the following command:

Terminal
deactivate

Create a new directory for the custom addons:

Terminal
mkdir /opt/odoo12/odoo-custom-addons

Switch back to your sudo user:

Terminal
exit

Next, open your text editor and create the following configuration file:

Terminal
sudo nano /etc/odoo12.conf
/etc/odoo12.confini
[options]
; This is the password that allows database operations:
admin_passwd = superadmin_passwd
db_host = False
db_port = False
db_user = odoo12
db_password = False
addons_path = /opt/odoo12/odoo/addons, /opt/odoo12/odoo-custom-addons

Save and close the file.

Info
Do not forget to change the superadmin_passwd to something more secure.

Create a systemd unit file

To run Odoo as a service we will create a unit file.

Open your text editor and create a file named odoo12.service inside the /etc/systemd/system/ directory:

Terminal
sudo nano /etc/systemd/system/odoo12.service

Paste the following content:

/etc/systemd/system/odoo12.serviceini
[Unit]
Description=Odoo12
Requires=postgresql-10.service
After=network.target postgresql-10.service

[Service]
Type=simple
SyslogIdentifier=odoo12
PermissionsStartOnly=true
User=odoo12
Group=odoo12
ExecStart=/usr/bin/scl enable rh-python36 -- /opt/odoo12/venv/bin/python3 /opt/odoo12/odoo/odoo-bin -c /etc/odoo12.conf
StandardOutput=journal+console

[Install]
WantedBy=multi-user.target

Save the file and close the editor.

Notify Systemd that we created a new unit file:

Terminal
sudo systemctl daemon-reload

Start and enable the Odoo service by executing:

Terminal
sudo systemctl enable odoo12
sudo systemctl start odoo12

You can check the service status with the following command:

Terminal
sudo systemctl status odoo12
output
● odoo12.service - Odoo12
   Loaded: loaded (/etc/systemd/system/odoo12.service; disabled; vendor preset: disabled)
   Active: active (running) since Tue 2018-10-30 16:35:09 UTC; 6s ago
 Main PID: 24649 (scl)
   CGroup: /system.slice/odoo12.service
           ├─24649 /usr/bin/scl enable rh-python36 -- /opt/odoo12/venv/bin/python3 /opt/odoo12/odoo/odoo-bin -c /etc/odoo12.conf
           ├─24650 /bin/bash /var/tmp/scldyaa9h
           └─24653 /opt/odoo12/venv/bin/python3 /opt/odoo12/odoo/odoo-bin -c /etc/odoo12.conf

If you want to see the messages logged by the Odoo service, you can use journalctl :

Terminal
sudo journalctl -u odoo12

Test the Installation

Open your browser and type: http://<your_domain_or_IP_address>:8069

Assuming the installation is successful, a screen similar to the following will appear:

Odoo 12 CentOS

If you can’t access the page then probably your firewall is blocking port 8069.

Use the following commands to open the necessary port:

Terminal
sudo firewall-cmd --permanent --zone=public --add-port=8069/tcp
sudo firewall-cmd --reload

Conclusion

This tutorial walked you through the installation of Odoo 12 on CentOS 7 in a Python virtual environment.

You may also want to check our tutorial about how to create automatic daily backups of your Odoo databases .

If you hit any problems, leave a comment below.

Linuxize Weekly Newsletter

A quick weekly roundup of new tutorials, news, and tips.

About the authors

Dejan Panovski

Dejan Panovski

Dejan Panovski is the founder of Linuxize, an RHCSA-certified Linux system administrator and DevOps engineer based in Skopje, Macedonia. Author of 800+ Linux tutorials with 20+ years of experience turning complex Linux tasks into clear, reliable guides.

View author page