odoo tricks

Tips and tricks for Odoo (OpenERP)

Installing Odoo 8 on CentOS 7 with virtual Python install

This tutorial will walk you through the process of installing the latest version of Odoo on CentOS 7. It is intended for those who might not be experienced Linux administrators but who want to run their own Odoo server. You can simply copy-paste the commands into your terminal or SSH window.

Please note this tutorial is only for CentOS 7. For CentOS 6.x please see my other tutorial.

First we will install the PostgreSQL database server, then install the necessary package dependencies. Next we will create a virtual Python environment (so we don’t interfere with the CentOS version) and install all the modules Odoo requires. Then it’s time to pull the latest Odoo code from GitHub and create a CentOS 7 compatible init script. Finally we will add the necessary firewall rules and connect to the server.

This tutorial assumes you have already performed a minimal install of the latest version of CentOS 7 on a server dedicated to just running Odoo. It also assumes you will be running Odoo on the same server as the PostgreSQL database. You also need at least 1GB of RAM, although this can include SWAP space.

Odoo is a complicated installation with many dependencies and can be quite resource intensive. I highly recommend you install on a server (or real or virtual) that is dedicated to Odoo. Co-locating Odoo with existing websites/applications is likely to cause problems at some point.

Make sure you enter these commands as the root user, and make sure you change any sections highlighted in red – they will be specific to your environment.

1: Generate Odoo Passwords

Before starting installation we will generate two passwords. The first line generates a strong random password for the odoo server to access the PostgreSQL database that we will install. The second line is the master password you will use to create the Odoo database after the installation is complete. Don’t worry about these for now. After the installation is complete you will find both these passwords in the Odoo configuration file (/etc/odoo-server.conf).

ODOO_POSTGRES_PASSWORD=`< /dev/urandom tr -dc _A-Z-a-z-0-9 | head -c${1:-20};echo;`
ODOO_DB_ADMIN_PASSWORD=`< /dev/urandom tr -dc _A-Z-a-z-0-9 | head -c${1:-20};echo;`

2: Install and configure PostgreSQL

First will install the PostgreSQL version from the official CentOS respository. This makes it easier to keep up to date with important security and maintenance updated. Then we initialise the database and add PostgreSQL to the list of applications which will be enabled when the server is restarted.

yum -y install postgresql-server postgresql-devel
postgresql-setup initdb
systemctl enable postgresql.service

Next we need to configure PostgreSQL so it will accept connections using MD5 hashed passwords for extra security.

cp /var/lib/pgsql/data/pg_hba.conf /var/lib/pgsql/data/pg_hba.conf.orig
sed -i "/^host/s/ident/md5/g" /var/lib/pgsql/data/pg_hba.conf

Finally let’s start the PostgreSQL server and add the Odoo user with the password we generated in step 1.

systemctl start postgresql.service
echo -e "$ODOO_POSTGRES_PASSWORD\n$ODOO_POSTGRES_PASSWORD\n" | su - postgres -c "createuser --createdb --username postgres --no-createrole --no-superuser --pwprompt odoo"

3: Installing Python libraries in a virtual environment

Odoo requires a lot of Python libraries. Potentially these could conflict with the Python libraries supplied in CentOS 7 and relied upon by the built in administration tools. So to avoid this risk we will create a virtual environment under the odoo system user account which will be used solely by the Odoo server.

First lets install some packages we will need before we can install the Python modules.

yum -y install wget gcc zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libffi-devel libxslt libxslt-devel libxml2 libxml2-devel openldap-devel libjpeg-turbo-devel openjpeg-devel libtiff-devel libyaml-devel python-virtualenv git libpng12 libXext xorg-x11-fonts-Type1

We also need the wkhtmltopdf package in order to generate PDF reports in Odoo. This link is for the 64bit version of CentOS. For 32bit change ‘amd64’ to ‘i386’ in the filename below. Also note that on CentOS 7 you must install the “libpng12” package (included above) otherwise it won’t run.

rpm -ivh http://sourceforge.net/projects/wkhtmltopdf/files/0.12.2/wkhtmltox-0.12.2_linux-centos7-amd64.rpm/download
ln -s /usr/local/bin/wkhtmltopdf /usr/bin/

Optional: You may wish to install Microsoft’s Core Fonts so they are available when you generate reports in Odoo. First we need to install some dependencies, then the msttcore-fonts-installer rpm downloads the fonts from sourceforge, installs them and activates them on your CentOS server.

rpm -ivh http://dl.fedoraproject.org/pub/epel/7/x86_64/l/libmspack-0.4-0.2.alpha.el7.x86_64.rpm
rpm -ivh http://dl.fedoraproject.org/pub/epel/7/x86_64/c/cabextract-1.4-4.el7.x86_64.rpm
rpm -ivh https://downloads.sourceforge.net/project/mscorefonts2/rpms/msttcore-fonts-installer-2.6-1.noarch.rpm

Next let’s create an Odoo user and setup the virtual environment.

adduser odoo

DIR="/var/run/odoo /var/log/odoo /opt/odoo"
for NAME in $DIR
if [ ! -d $NAME ]; then
 mkdir $NAME
 chown odoo.odoo $NAME

su - odoo

/bin/virtualenv odoo
source odoo/bin/activate

Now let’s install all the Python modules.Note we are replacing PIL with pillow – it’s a better supporting fork of PIL and it plays nicely with the location of the CentOS development libraries.

pip install http://download.gna.org/pychart/PyChart-1.39.tar.gz
pip install babel
pip install docutils
pip install feedparser
pip install gdata
pip install Jinja2
pip install mako
pip install mock
pip install psutil
pip install psycopg2
pip install pydot
pip install python-dateutil
pip install python-openid
pip install pytz
pip install pywebdav
pip install pyyaml
pip install reportlab
pip install simplejson
pip install unittest2
pip install vatnumber
pip install vobject
pip install werkzeug
pip install xlwt
pip install pyopenssl
pip install lxml
pip install python-ldap
pip install pillow
pip install decorator
pip install requests
pip install pyPdf
pip install wkhtmltopdf
pip install passlib

4: Installing Odoo 8 from GitHub

Now it’s finally time to install Odoo itself. We are going to download the latest version of Odoo 8 from the GitHub repository. Note that we are installing into the /opt directory so we can easily manage the installation in a single location and keep it separate from the rest of the operating system.

cd /opt
git clone https://github.com/odoo/odoo.git --branch 8.0
chown -R odoo.odoo odoo

Once Odoo has been downloaded we need to apply some configuration settings. These will get you up and running, although you might want to edit them in the future to be more relevant to your specific requirements.

cat > /etc/odoo-server.conf << EOF
; This is the password that allows database operations:
admin_passwd = $ODOO_DB_ADMIN_PASSWORD
db_host = localhost
db_port = 5432
db_user = odoo
addons_path = /opt/odoo/addons
no-xmlrpc = True
no-xmlrpcs = True
no-netrpc = True
logfile = /var/log/odoo/odoo-server.log
log_handler = werkzeug:WARNING
log_level = warn
no-logrotate = True


I also like to enable logrotation using the built in CentOS tools so the logs are managed in the same way as all the other applications.

cat > /etc/logrotate.d/odoo-server << EOF
/var/log/odoo/*.log {

Next we create a script to easily start and stop the Odoo server. Note that in CentOS 7 the format of the init scripts was completely changed so the old ones won’t work. The init script provided below also plays nicely with the virtual Python environment we created earlier.

cat > /usr/lib/systemd/system/odoo.service << EOF
Description=Odoo Open Source ERP and CRM
After=network.target postgresql.service

ExecStart=/bin/bash -c "cd /home/odoo; /bin/virtualenv -q odoo; source odoo/bin/activate; /usr/bin/odoo-server --config=/etc/odoo-server.conf &"



ln -s /opt/odoo/openerp-server /usr/bin/odoo-server
systemctl enable odoo

The final step in this section is to add the necessary firewall rules and start the OpenERP server. I’ve assumed the server is using the default eth0 interface for external connectivity and it’s in the public zone.

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

systemctl start odoo

You should be able to open a browser and connect to OpenERP: http://odoo.yourdomain.com:8069

You can check the logfiles in /var/log/messages and /var/log/odoo/odoo-server.log to make sure everything started correctly. Note you can also use “systemctl restart odoo” and “systemctl stop odoo” to restart and stop Odoo as required.

tail -50f /var/log/odoo/odoo-server.log

5: Updating Odoo

If you want to update the Odoo code to the latest version you can easily do that by stopping the server then performing a “git pull”. Note that you must only do the git pull as the odoo user.

systemctl stop odoo
su - odoo
cd /opt/odoo
git pull
systemctl start odoo

I hope this guide helps you get Odoo 8 up and running on CentOS 7. Let me know how you get on in the comment section, and also check out my other tutorials.


30 responses to “Installing Odoo 8 on CentOS 7 with virtual Python install

  1. Thomas Klosinsky June 7, 2017 at 5:54 pm

    Can’t get multiple workers up and running with this installation and newest 8.0 build…

    Error is:
    openerp.service.server: Worker (1330) Exception occurred, exiting…
    Traceback (most recent call last):
    File “/opt/odoo/openerp/service/server.py”, line 761, in run
    File “/opt/odoo/openerp/service/server.py”, line 806, in start
    self.server = BaseWSGIServerNoBind(self.multi.app)
    File “/opt/odoo/openerp/service/server.py”, line 69, in __init__
    werkzeug.serving.BaseWSGIServer.__init__(self, “1”, “1”, app)
    File “/home/odoo/odoo/lib/python2.7/site-packages/werkzeug/serving.py”, line 509, in __init__
    self.port = self.socket.getsockname()[1]
    File “/usr/lib64/python2.7/socket.py”, line 224, in meth
    return getattr(self._sock,name)(*args)
    File “/usr/lib64/python2.7/socket.py”, line 170, in _dummy
    raise error(EBADF, ‘Bad file descriptor’)
    error: [Errno 9] Bad file descriptor


  2. Thomas Klosinsky October 10, 2015 at 10:55 pm

    This also works for OdooV9!!!


  3. Ajeeb Kp September 15, 2015 at 3:58 am

    Why dont use,in step 3: Installing Python libraries in a virtual environment, pip install -r requirements.txt? You can add those package names into requirement.txt. Then use command pip install -r file.txt


  4. Maheswara June 9, 2015 at 5:46 pm

    newer version
    rpm -ivh http://sourceforge.net/projects/wkhtmltopdf/files/

    also if it errors back a missing dependency of font, run this:
    yum install xorg-x11-fonts-75dpi


  5. Thomas Klosinsky March 31, 2015 at 8:43 am

    You shoud update the rpm links, since there are newer versions available and the old links don’t work anymore… 😉


  6. Angel March 16, 2015 at 4:14 pm

    Thank you very much Serbian me well 🙂


  7. Talway March 10, 2015 at 2:49 pm

    Traceback (most recent call last):
    File “/opt/odoo/openerp/http.py”, line 530, in _handle_exception
    return super(JsonRequest, self)._handle_exception(exception)
    File “/opt/odoo/openerp/http.py”, line 567, in dispatch
    result = self._call_function(**self.params)
    File “/opt/odoo/openerp/http.py”, line 304, in _call_function
    return self.endpoint(*args, **kwargs)
    File “/opt/odoo/openerp/http.py”, line 796, in __call__
    return self.method(*args, **kw)
    File “/opt/odoo/openerp/http.py”, line 396, in response_wrap
    response = f(*args, **kw)
    File “/opt/odoo/addons/web/controllers/main.py”, line 694, in create
    File “/opt/odoo/openerp/http.py”, line 872, in proxy_method
    result = dispatch_rpc(self.service_name, method, args)
    File “/opt/odoo/openerp/http.py”, line 114, in dispatch_rpc
    result = dispatch(method, params)
    File “/opt/odoo/openerp/service/db.py”, line 73, in dispatch
    return fn(*params)
    File “/opt/odoo/openerp/service/db.py”, line 90, in exp_create_database
    File “/opt/odoo/openerp/service/db.py”, line 85, in _create_empty_database
    cr.execute(“””CREATE DATABASE “%s” ENCODING ‘unicode’ TEMPLATE “%s” “”” % (name, chosen_template))
    File “/opt/odoo/openerp/sql_db.py”, line 158, in wrapper
    return f(self, *args, **kwargs)
    File “/opt/odoo/openerp/sql_db.py”, line 234, in execute
    res = self._obj.execute(query, params)
    DataError: new encoding (UTF8) is incompatible with the encoding of the template database (SQL_ASCII)
    HINT: Use the same encoding as in the template database, or use template0 as template.

    this is my wrong ??


    • Allenzee April 20, 2015 at 2:15 pm

      su – postgres
      postgres=# \l

      update pg_database set datallowconn = TRUE where datname = ‘template0’;
      \c template0
      update pg_database set datistemplate = FALSE where datname = ‘template1’;
      drop database template1;
      create database template1 with template = template0 encoding = ‘UTF8’;
      update pg_database set datistemplate = TRUE where datname = ‘template1’;
      \c template1
      update pg_database set datallowconn = FALSE where datname = ‘template0’;


  8. Talway March 10, 2015 at 2:40 pm

    1、rpm -ivh http://sourceforge.net/projects/wkhtmltopdf/files/0.12.2/wkhtmltox-0.12.2_linux-centos7-amd64.rpm/download ,——————————-Can not download the update, please, thank you!

    pip install–Install more, whether can improve batch installation, the speed quickly;

    This is another script, you reference for improving
    /bin/virtualenv odoo
    source odoo/bin/activate
    pip install -r /opt/odoo/requirements.txt


  9. Manoj February 22, 2015 at 9:47 am

    Starting Odoo Server Daemon (odoo-server): [ OK ]
    [root@erp ~]# Traceback (most recent call last):
    File “/opt/odoo/openerp-server”, line 2, in
    import openerp
    File “/opt/odoo/openerp/__init__.py”, line 72, in
    import modules
    File “/opt/odoo/openerp/modules/__init__.py”, line 27, in
    from . import db, graph, loading, migration, module, registry
    File “/opt/odoo/openerp/modules/graph.py”, line 32, in
    import openerp.osv as osv
    File “/opt/odoo/openerp/osv/__init__.py”, line 22, in
    import osv
    File “/opt/odoo/openerp/osv/osv.py”, line 23, in
    from .orm import Model, TransientModel, AbstractModel
    File “/opt/odoo/openerp/osv/orm.py”, line 2, in
    from lxml import etree
    ImportError: No module named lxml

    Please give me a solution. when i try to install lxml

    running build_ext

    building ‘lxml.etree’ extension

    creating build/temp.linux-x86_64-2.7

    creating build/temp.linux-x86_64-2.7/src

    creating build/temp.linux-x86_64-2.7/src/lxml

    gcc -pthread -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/usr/include/libxml2 -I/tmp/pip-build-q1ig70/lxml/src/lxml/includes -I/usr/local/include/python2.7 -c src/lxml/lxml.etree.c -o build/temp.linux-x86_64-2.7/src/lxml/lxml.etree.o -w

    gcc: Internal error: Killed (program cc1)

    Please submit a full bug report.

    See for instructions.

    error: command ‘gcc’ failed with exit status 1

    Command “/usr/local/bin/python2.7 -c “import setuptools, tokenize;__file__=’/tmp/pip-build-q1ig70/lxml/setup.py’;exec(compile(getattr(tokenize, ‘open’, open)(__file__).read().replace(‘\r\n’, ‘\n’), __file__, ‘exec’))” install –record /tmp/pip-JW6HnG-record/install-record.txt –single-version-externally-managed –compile” failed with error code 1 in /tmp/pip-build-q1ig70/lxml


  10. Pingback: Installing Odoo 8 in CentOS-7 | engamratta

  11. Byron Juarez February 1, 2015 at 6:59 pm

    hello im having this issue :

    2015-02-01 18:57:18,775 22753 ERROR None werkzeug: Error on request:
    Traceback (most recent call last):
    File “/home/odoo/odoo/lib/python2.7/site-packages/werkzeug/serving.py”, line 180, in run_wsgi
    File “/home/odoo/odoo/lib/python2.7/site-packages/werkzeug/serving.py”, line 168, in execute
    application_iter = app(environ, start_response)
    File “/opt/odoo/openerp/service/server.py”, line 281, in app
    return self.app(e, s)
    File “/opt/odoo/openerp/service/wsgi_server.py”, line 216, in application
    return application_unproxied(environ, start_response)
    File “/opt/odoo/openerp/service/wsgi_server.py”, line 202, in application_unproxied
    result = handler(environ, start_response)
    File “/opt/odoo/openerp/http.py”, line 1280, in __call__
    return self.dispatch(environ, start_response)
    File “/opt/odoo/openerp/http.py”, line 1254, in __call__
    return self.app(environ, start_wrapped)
    File “/home/odoo/odoo/lib/python2.7/site-packages/werkzeug/wsgi.py”, line 591, in __call__
    return self.app(environ, start_response)
    File “/opt/odoo/openerp/http.py”, line 1392, in dispatch
    File “/opt/odoo/openerp/http.py”, line 1338, in setup_db
    httprequest.session.db = db_monodb(httprequest)
    File “/opt/odoo/openerp/http.py”, line 1464, in db_monodb
    dbs = db_list(True, httprequest)
    File “/opt/odoo/openerp/http.py”, line 1438, in db_list
    dbs = dispatch_rpc(“db”, “list”, [force])
    File “/opt/odoo/openerp/http.py”, line 114, in dispatch_rpc
    result = dispatch(method, params)
    File “/opt/odoo/openerp/service/db.py”, line 73, in dispatch
    return fn(*params)
    File “/opt/odoo/openerp/service/db.py”, line 313, in exp_list
    with closing(db.cursor()) as cr:
    File “/opt/odoo/openerp/sql_db.py”, line 571, in cursor
    return Cursor(self.__pool, self.dbname, self.dsn, serialized=serialized)
    File “/opt/odoo/openerp/sql_db.py”, line 181, in __init__
    self._cnx = pool.borrow(dsn)
    File “/opt/odoo/openerp/sql_db.py”, line 460, in _locked
    return fun(self, *args, **kwargs)
    File “/opt/odoo/openerp/sql_db.py”, line 522, in borrow
    result = psycopg2.connect(dsn=dsn, connection_factory=PsycoConnection)
    File “/home/odoo/odoo/lib/python2.7/site-packages/psycopg2/__init__.py”, line 164, in connect
    conn = _connect(dsn, connection_factory=connection_factory, async=async)
    OperationalError: FATAL: Ident authentication failed for user “odoo”

    could you please advise?


    • Byron Juarez February 1, 2015 at 7:00 pm

      my config file
      ===========(odoo)[root@pacolep ~]# cat /etc/odoo-server.conf
      ; This is the password that allows database operations:
      admin_passwd = $ODOO_DB_ADMIN_PASSWORD
      db_host = localhost
      db_port = 5432
      db_user = odoo
      db_password = $ODOO_POSTGRES_PASSWORD
      addons_path = /opt/odoo/addons
      no-xmlrpc = True
      no-xmlrpcs = True
      no-netrpc = True
      logfile = /var/log/odoo/odoo-server.log
      log_handler = werkzeug:WARNING
      log_level = warn
      no-logrotate = True



  12. Thomas Klosinsky December 9, 2014 at 12:34 pm

    if encountering a 502 gateway error it might be because of selinux activated:
    setsebool -P httpd_can_network_connect true
    should fix it.


  13. Drenzla November 21, 2014 at 3:33 am

    Thank you for taking time to create this tutorial. I have tried twice to install odoo 8.0 on CentOS 6.6 to no avail. I can not get the browser to display anything, and the /var/log/odoo/odoo-server.log is empty. There is no entry in httpd.conf for odoo. There are no password showing in /etc/odoo-server.conf. I have followed the directions for install on CentOS 6 exactly both times and even re-provisioned the server to make sure I had a clean install the second time. There were no error messages displayed during install either time. Same exact results both times. Please advise how to find problem.
    Thank you


  14. romcapasso November 8, 2014 at 4:49 pm

    Internal Server Error

    The server encountered an internal error and was unable to complete your request. Either the server is overloaded or there is an error in the application.



  15. mivaho November 6, 2014 at 3:53 pm

    thnx, worked perfectly except for 2 things.

    First, I’m behind a proxy so for the oddo user I had to put http,https and (just to be sure) ftp env to my proxy in .bash_profile and source it. After that I could do all the pip installs.

    Second is something you did change in the Centos 6 how to. In the part where you do the server conf in /etc/odoo.server.conf you do the part for the log rotation as well. In the Centos 6 howto you put “cat > /etc/logrotate.d/odoo-server << EOF" in the line above it. Maybe change that in this one as well.

    Rest worked like a charm, again thnx


  16. Olver October 5, 2014 at 4:12 pm


    Thanks for the tutorial. I’m new to Linux and I was struggling with the Odoo installation. When I ran the “git clone” command on my CentOS 7 box I got the following error message:

    git: command not found

    I looked around on the web and I found that Odoo can be manually downloaded and installed on the server thanks to this tutorial https://www.rosehosting.com/blog/install-odoo-8-on-a-centos-7-vps/


    • daviddean99 October 5, 2014 at 4:37 pm

      That error response means the “git” package wasn’t installed. You might have missed a step because git is included in the list of additional packages we installed in section 3:

      yum -y install gcc zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libffi-devel libxslt libxslt-devel libxml2 libxml2-devel openldap-devel libjpeg-turbo-devel openjpeg-devel libtiff-devel libyaml-devel python-virtualenv git libpng12 libXext xorg-x11-fonts-Type1


  17. Ashutosh October 5, 2014 at 7:44 am

    I am facing this PIL issue on my fresh CENTOS 7 VPS
    bash[479]: from ..models import (
    bash[479]: File “/opt/odoo/openerp/models.py”, line 61, in
    bash[479]: from . import api
    bash[479]: File “/opt/odoo/openerp/api.py”, line 71, in
    bash[479]: from openerp.tools import frozendict
    bash[479]: File “/opt/odoo/openerp/tools/__init__.py”, line 30, in
    bash[479]: from image import *
    bash[479]: File “/opt/odoo/openerp/tools/image.py”, line 27, in
    bash[479]: from PIL import Image
    bash[479]: ImportError: No module named PIL



    • daviddean99 October 5, 2014 at 7:54 am

      Hi Pankaj. Make sure you installed the Pillow library in section 3. Pillow is a replacement for PIL which I found had problems detecting the additional image and other libraries we installed earlier in the tutorial.

      systemctl stop odoo
      su - odoo
      /bin/virtualenv odoo
      source odoo/bin/activate
      pip install pillow
      systemctl start odoo


  18. Andrew September 29, 2014 at 9:41 am

    Same as Jeff please. Really struggling with Odoo V8 on Centos 6.5 with Python 2.6! Help. Postgresql working fine but I’m struggling to get Python 2.7 installed and working with Odoo. Thanks in advance.


  19. Jeff September 27, 2014 at 9:48 am

    Can you provide article like this but for CentOS 6.5? I have tried (and failed) to install odoo 8 on CentOS 6.5.


Leave a Comment

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: