Installing Odoo 8 From source in VirtualEnv (Ubuntu)
This article will walk you through installing Odoo 8 from source on an Ubuntu (or other Debian distro) box using the Odoo GitHub Repo.
Foreword ∞
This is meant strictly for development environments, as it installs a lot of headers that are only needed to build the binaries. LasLabs will soon be releasing an Open Source Ansible playbook to take care of the production setups, but for now there are always the Odoo docs.
We will be using a Python Virtual Environment in order to better maintain Odoo specific dependencies alongside other Python apps. Checkout The Hitchhiker’s Guide To Python’s article on VirtualEnvs for more information on VirtualEnv.
Configuration Reference ∞
The following table is a reference of configuration variables, such as users and file directories, that you may want to change in your setup. If you do decide to change something, you’ll need to make sure that you transpose these values for your’s in the steps below.
Name | Value |
---|---|
System User | odoo |
Database Name | odoo |
Database User | odoo |
Install Directory | /var/www/odoo |
Configuration Path | /etc/odoo/odoo.conf |
Addons Path | /var/www/odoo/addons |
Log Path | /var/log/odoo/odoo-server.log |
Init Script Path | /etc/init.d/odoo |
VirtualEnv Path | /var/www/odoo/_venv |
Ready The Server ∞
-
Standard procedure when beginning any install is to update your package repos and installations
sudo apt-get update && sudo apt-get -y upgrade
-
Install build dependencies
sudo apt-get install -y git python-virtualenv postgresql-9.* \ postgresql postgresql-server-dev-9.* postgresql-client-9.* \ libxml2-dev libjpeg-dev libldap2-dev libsasl2-dev libxslt1-dev \ python-dev libtiff5-dev
-
Install newest version of WkHtmlToPdf to circumvent stale repo versions with known issues. Find the latest version on their download page
sudo wget http://download.gna.org/wkhtmltopdf/0.12/0.12.2.1/wkhtmltox-0.12.2.1_linux-trusty-amd64.deb sudo dpkg -i wkhtmltox-0.12.2.1_linux-trusty-amd64.deb sudo ln -s /usr/local/bin/wkhtmltopdf /usr/bin sudo ln -s /usr/local/bin/wkhtmltoimage /usr/bin
Configure Database ∞
-
Change to the
postgres
system user so that we can work with the databasesudo su - postgres
-
Create the
odoo
database and user. Save the password that you choose here, we will need it latercreateuser --createdb --username postgres --no-superuser --no-createrole --pwprompt odoo
-
Exit the
postgres
system userexit
Install Odoo ∞
-
Create the Odoo user
sudo adduser --system --group odoo --home /var/www/odoo
-
Checkout the Odoo 8.0 branch from GitHub into the install directory
sudo git clone https://www.github.com/odoo/odoo --depth 1 --branch 8.0 --single-branch /var/www/odoo
-
Update owner to Odoo system user
sudo chown -R odoo: /var/www/odoo
-
Switch to the Odoo system user so that we don’t have to worry about permissions anymore. We need to explicitly define
/bin/bash
as a shell due to the user not having a shell (this is a good thing)sudo su - odoo -s /bin/bash
-
Change to the install directory and create a Python Virtual Environment for dependency isolation
cd /var/www/odoo && virtualenv ./_venv
-
Edit
odoo.py
and change the shebang on the top line to use the Python in the VirtualEnv#!/var/www/odoo/_venv/bin/python
-
Activate the VirtualEnv, install the Python dependencies, then install Odoo
source ./_venv/bin/activate && pip install -r ./requirements.txt && pip install ./
-
If you are developing modules and need Odoo to run tests, you will also need
anybox.testing.openerp
pip install anybox.testing.openerp
-
Exit the Odoo user
exit
Configure Odoo ∞
-
Make the configuration file directory
sudo mkdir /etc/odoo
-
Copy the sample config to its final location. Update the permissions for security (it will be holding passwords)
sudo cp /var/www/odoo/debian/openerp-server.conf /etc/odoo/odoo.conf && sudo chmod 640 /etc/odoo/odoo.conf && sudo chown odoo: /etc/odoo/odoo.conf
-
Edit the configuration file, make it look something like the below (adding in your password). The
admin_password
is used when performing database operations from the database management portal ($ODOO_BASE_URI/web/database/manager
) – such as creations, backups, and drops.[options] admin_passwd = ANOTHER_SUPER_SECRET_PASSWORD_TO_CREATE db_host = False db_port = False db_user = odoo db_password = MY_SUPER_SECRET_DATABASE_PASSWORD addons_path = /var/www/odoo/addons logfile = /var/log/odoo/odoo-server.log
-
Verify that the server runs manually. Use
CTRL+C
to exit the prompt.sudo su - odoo -s /bin/bash source /var/www/odoo/_venv/bin/activate /var/www/odoo/openerp-server
-
Exit Odoo user session
exit
Allow Automatic Booting ∞
-
Copy the sample init script to the init folder, and set permissions
sudo cp /var/www/odoo/debian/init /etc/init.d/odoo && sudo chmod 755 /etc/init.d/odoo && sudo chown root: /etc/init.d/odoo
-
Make appropriate alterations for our environment by editing
/etc/init.d/odoo
and replacing the variable declarations at the top with the following insteadPATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin DAEMON=/var/www/odoo/odoo.py NAME=odoo DESC=odoo CONFIG=/etc/odoo/odoo.conf LOGFILE=/var/log/odoo/odoo-server.log PIDFILE=/var/run/${NAME}.pid USER=odoo export LOGNAME=$USER
-
In both the init script and config file, we have a log path defined. It doesn’t exist yet, and the Odoo system user will need read/write access to it
sudo mkdir /var/log/odoo && sudo chown odoo:root /var/log/odoo
-
Start the server
sudo /etc/init.d/odoo start
- Test the server by going to
http://ip-or-domain-of-server:8069
-
If there are errors, check the logs –
less /var/log/odoo/odoo-server.log
-
Stop the server (once everything works)
sudo /etc/init.d/odoo stop
-
Allow for automatic booting (as described on StackOverflow)
sudo update-rc.d odoo defaults
-
Start Odoo through system services
sudo service odoo start
Next Steps ∞
From here you would want to create a database and begin configuring Odoo (http://ip-or-domain-of-server:8069/web/database/manager
).
For performance and scalability, it is recommended to run Odoo behind an Nginx proxy (as seen in this article).
Configuration File Reference ∞
Thanks to Luke Branch on the Odoo forums for this:
[options] ## Server startup config - Common options # Admin password for creating, restoring and backing up databases admin_passwd = admin # specify additional addons paths (separated by commas) addons_path = /opt/odoo/addons ## XML-RPC / HTTP - XML-RPC Configuration # disable the XML-RPC protocol xmlrpc = True # Specify the TCP IP address for the XML-RPC protocol. The empty string binds to all interfaces. xmlrpc_interface = 127.0.0.1 # specify the TCP port for the XML-RPC protocol xmlrpc_port = 8069 # Enable correct behavior when behind a reverse proxy proxy_mode = True ## XML-RPC / HTTPS - XML-RPC Secure Configuration # disable the XML-RPC Secure protocol xmlrpcs = True # Specify the TCP IP address for the XML-RPC Secure protocol. The empty string binds to all interfaces. xmlrpcs_interface = # specify the TCP port for the XML-RPC Secure protocol xmlrpcs_port = 8071 # specify the certificate file for the SSL connection secure_cert_file = server.cert # specify the private key file for the SSL connection secure_pkey_file = server.pkey ## NET-RPC - NET-RPC Configuration # enable the NETRPC protocol netrpc = False # specify the TCP IP address for the NETRPC protocol netrpc_interface = 127.0.0.1 # specify the TCP port for the NETRPC protocol netrpc_port = 8070 ## WEB - Web interface Configuration # Filter listed database REGEXP dbfilter = .* ## Static HTTP - Static HTTP service # enable static HTTP service for serving plain HTML files static_http_enable = False # specify the directory containing your static HTML files (e.g '/var/www/') static_http_document_root = None # specify the URL root prefix where you want web browsers to access your static HTML files (e.g '/') static_http_url_prefix = None ## Testing Group - Testing Configuration # Launch a YML test file. test_file = False # If set, will save sample of all reports in this directory. test_report_directory = False # Enable YAML and unit tests. test_disable = False # Commit database changes performed by YAML or XML tests. test_commit = False ## Logging Group - Logging Configuration # file where the server log will be stored (default = None) logfile = /var/log/openerp/openerp-server.log # do not rotate the logfile logrotate = True # Send the log to the syslog server syslog = False # setup a handler at LEVEL for a given PREFIX. An empty PREFIX indicates the root logger. This option can be repeated. Example: "openerp.orm:DEBUG" or "werkzeug:CRITICAL" (default: ":INFO") log_handler = ["[':INFO']"] # specify the level of the logging. Accepted values: info, debug_rpc, warn, test, critical, debug_sql, error, debug, debug_rpc_answer, notset #log_level = debug log_level = info0