This guide will walk you through the steps to install and configure Odoo on CentOS 7| RHEL 7. Odoo is a popular business software with a range of business applications such as CRM, POS, Website builder, Warehouse Management, Project Management, eCommerce, Marketing, Billing & Accounting, Manufacturing among many others. All these applications are seamlessly integrated and are managed from one web console.
As of this article writing, the latest release of Odoo available for download and use is Odoo v16. In the rest of this article, we will install and configure Odoo on CentOS 7 / RHEL 7. We’ll use PostgreSQL database and Nginx as frontend proxy to Odoo running on CentOS 7.
Step 1: Add EPEL Repository
Add EPEL repository to CentOS 7 by running the command.
sudo yum -y install epel-release vim bash-completion
Put SELinux in permissive mode.
sudo setenforce 0
sudo sed -i 's/^SELINUX=.*/SELINUX=permissive/g' /etc/selinux/config
After adding EPEL repository, I recommend you update your system.
sudo yum -y update
Step 2: Install PostgreSQL Database Server
After adding EPEL repository, install PostgreSQL database server on CentOS 7. As of this writing, the latest release of PostgreSQL is version 14. Install it using our guide.
Step 3: Install Python 3 and wkhtmltopdf
In this step we shall perform installation of Python 3.9 and wkhtmltopdf package.
Install Python 3.9 on CentOS 7 / RHEL 7
Follow our guide in the link below to installPython 3.9 on CentOS 7 / RHEL 7:
After installation, check version of Python 3 installed:
$ python3.9 --version
Python 3.9.9
$ pip3.9 --version
pip 21.2.4 from /usr/local/lib/python3.9/site-packages/pip (python 3.9)
Set Python 3 symlink
$ sudo ln -fs /usr/local/bin/python3.9 /usr/bin/python3
$ python3 -V
Python 3.9.17
Odoo uses wkhtmltopdf to generate reports in PDF format. The recommended version of wkhtmltopdf to install is 0.12.5 and is available on the wkhtmltopdf download page, in the archive section.
sudo yum -y install https://github.com/wkhtmltopdf/wkhtmltopdf/releases/download/0.12.5/wkhtmltox-0.12.5-1.centos7.x86_64.rpm
Confirm installed version.
$ wkhtmltopdf --version
wkhtmltopdf 0.12.5 (with patched qt)
Step 4: Install Odoo on CentOS 7 | RHEL 7
Install all development tools required:
sudo yum -y install gcc git wget nodejs libxslt-devel bzip2-devel openldap-devel freetype-devel libjpeg-devel
Install PosgtreSQL Devel package
sudo yum -y install centos-release-scl
sudo yum -y install postgresql13-devel
Create odoo PostgreSQL user:
sudo su - postgres -c "createuser -s odoo"
Create OS user used by odoo
sudo useradd -m -U -r -d /opt/odoo -s /bin/bash odoo
Switch to odoo user:
sudo su - odoo
Download Odoo into the /opt/odoo directory from the Github repository
git clone https://www.github.com/odoo/odoo --depth 1 --branch 16.0 /opt/odoo/odoo
Create the Python virtual environment for Odoo using the following commands:
cd /opt/odoo
python3.9 -m venv odoo-venv
Activate the Virtual environment
source odoo-venv/bin/activate
Update PATH:
echo 'PATH=$PATH:/usr/pgsql-13/bin/'|tee -a ~/.bashrc
source ~/.bashrc
echo $PATH
Install required modules in requirements file
pip3.9 install --upgrade pip
pip3.9 install -r odoo/requirements.txt
Fixingpsycopg2 installation error
If you encounter an error message like this:
Collecting psycopg2==2.8.6
Using cached psycopg2-2.8.6.tar.gz (383 kB)
Preparing metadata (setup.py) ... error
ERROR: Command errored out with exit status 1:
command: /opt/odoo/odoo-venv/bin/python3 -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-f56d763j/psycopg2_b01a674969b842af93ecce0951e28bcb/setup.py'"'"'; __file__='"'"'/tmp/pip-install-f56d763j/psycopg2_b01a674969b842af93ecce0951e28bcb/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-pip-egg-info-j47tvfky
Uncomment
$ vim odoo/requirements.txt
#psycopg2==2.7.7; sys_platform != 'win32' and python_version < '3.8'
#psycopg2==2.8.6; sys_platform == 'win32' or python_version >= '3.8'
Then install psycopg2-binary module and other requirements:
pip3.9 install psycopg2-binary===2.8.6
pip3.9 install -r odoo/requirements.txt
After installations deactivate and exit the virtual environment:
(odoo-venv) [odoo@centos ~]$ deactivate
[odoo@centos ~]$ exit
logout
Step 5: Configure Odoo instance on CentOS 7 | RHEL 7
Create a folder for custom addons:
sudo mkdir /opt/odoo/odoo-custom-addons
Give odoo user permissions to the directory created
sudo chown odoo:odoo /opt/odoo/odoo-custom-addons
Create a directory for storing odoo logs:
sudo mkdir /var/log/odoo
sudo touch /var/log/odoo/odoo.log
sudo chown -R odoo:odoo /var/log/odoo
Create Odoo configuration file
$ sudo vim /etc/odoo.conf
[options]
; This is the password that allows database operations:
admin_passwd = OdooAdminPassw0rd
db_host = False
db_port = False
db_user = odoo
db_password = False
xmlrpc_port = 8069
; longpolling_port = 8072
logfile = /var/log/odoo/odoo.log
logrotate = True
addons_path = /opt/odoo/odoo/addons,/opt/odoo/odoo-custom-addons
Set file permission
sudo chown odoo:odoo /etc/odoo.conf
sudo chmod 640 /etc/odoo.conf
Step 6: Create systemd unit file
Create a systemd file in the for the odoo service
sudo tee /etc/systemd/system/odoo.service<<EOF
[Unit]
Description=Odoo Service Unit
[Service]
Type=simple
User=odoo
Group=odoo
SyslogIdentifier=odoo
PermissionsStartOnly=true
ExecStart=/opt/odoo/odoo-venv/bin/python3 /opt/odoo/odoo/odoo-bin -c /etc/odoo.conf
StandardOutput=journal+console
[Install]
WantedBy=multi-user.target
EOF
Reload systemd daemon
sudo systemctl daemon-reload
Start odoo service
sudo systemctl start odoo.service
sudo systemctl enable odoo.service
Confirm port 8069 is bound.
$ sudo ss -tunelp | grep 8069
tcp LISTEN 0 128 *:8069 *:* users:(("python3",pid=20896,fd=4)) uid:996 ino:59302 sk:ffff88d9b5ee1f00 <->
You can now access the Odoo web console on its home page:
http://{hostname_or_ip_address}:8069
Step 7: Configure Nginx Proxy (Without SSL) – Not recommended
Install Nginx on CentOS 7
sudo yum -y install nginx
sudo systemctl enable --now nginx
Create a new configuration file for odoo.
sudo vim /etc/nginx/conf.d/odoo.conf
Modify this configuration snippet to fit your setup.
# Odoo Upstreams
upstream odooserver {
server 127.0.0.1:8069;
}
server {
listen 80;
server_name erp.geeksforgeeks.org;
access_log /var/log/nginx/odoo_access.log;
error_log /var/log/nginx/odoo_error.log;
# Proxy settings
proxy_read_timeout 720s;
proxy_connect_timeout 720s;
proxy_send_timeout 720s;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Real-IP $remote_addr;
# Request for root domain
location / {
proxy_redirect off;
proxy_pass http://odooserver;
}
# Cache static files
location ~* /web/static/ {
proxy_cache_valid 200 90m;
proxy_buffering on;
expires 864000;
proxy_pass http://odooserver;
}
# Gzip
gzip_types text/css text/less text/plain text/xml application/xml application/json application/javascript;
gzip on;
}
Replace erp.neveropen with your domain name, then validate Nginx configuration file.
$ sudo nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
If all looks good, restart Nginx.
sudo systemctl restart nginx
Step 6: Configure Nginx Proxy (With SSL Certificate) – Recommended
If your server has a public IP, you can create a DNS A record for your domain to point to Odoo Server and request for free Let’s Encrypt SSL certificate.
Install Nginx on CentOS 7
sudo yum -y install nginx
sudo systemctl enable --now nginx
Install certbot-auto tool.
sudo yum -y install epel-release
sudo yum -y install certbot python2-certbot-nginx
Stop Nginx service.
sudo systemctl stop nginx
Get Let’s Encrypt SSL certificates for your domain.
export DOMAIN="erp.geeksforgeeks.org"
export EMAIL="[email protected]"
sudo /usr/bin/certbot certonly --standalone -d ${DOMAIN} --preferred-challenges http --agree-tos -n -m ${EMAIL} --keep-until-expiring
The path to certificate files is shown in the “IMPORTANT NOTES” section.
IMPORTANT NOTES:
- Congratulations! Your certificate and chain have been saved at:
/etc/letsencrypt/live/erp.geeksforgeeks.org/fullchain.pem
Your key file has been saved at:
/etc/letsencrypt/live/erp.geeksforgeeks.org/privkey.pem
Your cert will expire on 2020-01-19. To obtain a new or tweaked
version of this certificate in the future, simply run certbot-auto
again. To non-interactively renew *all* of your certificates, run
"certbot-auto renew"
- If you like Certbot, please consider supporting our work by:
Donating to ISRG / Let's Encrypt: https://letsencrypt.org/donate
Donating to EFF: https://eff.org/donate-le
Create cron to renew certificate.
$ sudo crontab -e
15 3 * * * /usr/bin/certbot renew --pre-hook "systemctl stop nginx" --post-hook "systemctl start nginx"
Create Nginx configuration file.
sudo vim /etc/nginx/conf.d/odoo.conf
Paste below into the file and modify it to suit your environment.
# Odoo Upstreams
upstream odooserver {
server 127.0.0.1:8069;
}
# http to https redirection
server {
listen 80;
server_name erp.geeksforgeeks.org;
return 301 https://erp.geeksforgeeks.org$request_uri;
}
server {
listen 443 ssl;
server_name erp.geeksforgeeks.org;
access_log /var/log/nginx/odoo_access.log;
error_log /var/log/nginx/odoo_error.log;
# SSL
ssl_certificate /etc/letsencrypt/live/erp.geeksforgeeks.org/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/erp.geeksforgeeks.org/privkey.pem;
ssl_trusted_certificate /etc/letsencrypt/live/erp.geeksforgeeks.org/chain.pem;
# Proxy settings
proxy_read_timeout 720s;
proxy_connect_timeout 720s;
proxy_send_timeout 720s;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Real-IP $remote_addr;
# Request for root domain
location / {
proxy_redirect off;
proxy_pass http://odooserver;
}
# Cache static files
location ~* /web/static/ {
proxy_cache_valid 200 90m;
proxy_buffering on;
expires 864000;
proxy_pass http://odooserver;
}
# Gzip Compression
gzip_types text/css text/less text/plain text/xml application/xml application/json application/javascript;
gzip on;
}
Validate your Nginx configurations.
$ sudo nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
Restart Nginx.
sudo systemctl restart nginx
Step 7: Access Odoo on Debian 10 Linux
Access Odoo Web page on your domain name from a web – https://DNShostname.
On the first page, set database name, admin user email address and password for the admin user.
Use the Apps menu to install other Odoo applications.
Example:
There you have it. Odoo has been installed on CentOS 7 Linux server. Explore more Odoo features and Applications available for installation. The next page to visit is official Odoo Documentation.
For Debian family, check: