Installing Odoo 8

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 [[https://github.com/odoo/odoo|Odoo GitHub Repo]].

[[[TOC]]]

—-

= Foreword =

This is meant strictly for development environments, as it installs a lot of headers that are only needed to build the binaries. [[https://laslabs.com|LasLabs]] will soon be releasing an Open Source Ansible playbook to take care of the production setups, but for now there are always the [[https://www.odoo.com/documentation/8.0/setup/deploy.html|Odoo docs]].

We will be using a Python Virtual Environment in order to better maintain Odoo specific dependencies alongside other Python apps. Checkout [[http://docs.python-guide.org/en/latest/dev/virtualenvs/|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

{{{ lang=bash
sudo apt-get update &&
sudo apt-get -y upgrade
}}}

# Install build dependencies

{{{ lang=bash
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 [[http://wkhtmltopdf.org/downloads.html|their download page]]

{{{ lang=bash
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 database

{{{ lang=bash
sudo su – postgres
}}}

# Create the `odoo` database and user. Save the password that you choose here, we will need it later

{{{ lang=bash
createuser –createdb –username postgres –no-superuser –no-createrole –pwprompt odoo
}}}

# Exit the `postgres` system user

{{{ lang=bash
exit
}}}

= Install Odoo =

# Create the Odoo user

{{{ lang=bash
sudo adduser –system –group odoo –home /var/www/odoo
}}}

# Checkout the Odoo 8.0 branch from GitHub into the install directory

{{{ lang=bash
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

{{{ lang=bash
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 ([[http://www.cyberciti.biz/tips/howto-linux-shell-restricting-access.html|this is a good thing]])

{{{ lang=bash
sudo su – odoo -s /bin/bash
}}}

# Change to the install directory and create a [[http://docs.python-guide.org/en/latest/dev/virtualenvs/|Python Virtual Environment]] for dependency isolation

{{{ lang=bash
cd /var/www/odoo &&
virtualenv ./_venv
}}}
# Edit `odoo.py` and change the shebang on the top line to use the Python in the VirtualEnv

{{{ lang=bash
#!/var/www/odoo/_venv/bin/python
}}}

# Activate the VirtualEnv, install the Python dependencies, then install Odoo

{{{ lang=bash
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`

{{{ lang=bash
pip install anybox.testing.openerp
}}}

# Exit the Odoo user

{{{ lang=bash
exit
}}}

= Configure Odoo =

# Make the configuration file directory

{{{ lang=bash
sudo mkdir /etc/odoo
}}}

# Copy the sample config to its final location. Update the permissions for security (it will be holding passwords)

{{{ lang=bash
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.

{{{ lang=bash
[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.

{{{ lang=bash
sudo su – odoo -s /bin/bash
source /var/www/odoo/_venv/bin/activate
/var/www/odoo/openerp-server
}}}

** If you get something like below, the server is working. You can verify by going to `http://ip-of-odoo-server:80
{{{ lang=bash
2015-09-15 04:45:25,516 18499 INFO ? openerp: OpenERP version 8.0
2015-09-15 04:45:25,516 18499 INFO ? openerp: addons paths: [‘/var/www/rx/.local/share/Odoo/addons/8.0′, u’/var/www/rx/openerp/addons’, u’/var/www/rx/addons’]
2015-09-15 04:45:25,516 18499 INFO ? openerp: database hostname: localhost
2015-09-15 04:45:25,516 18499 INFO ? openerp: database port: 5432
2015-09-15 04:45:25,516 18499 INFO ? openerp: database user: rx
2015-09-15 04:45:25,625 18499 INFO ? openerp.service.server: HTTP service (werkzeug) running on 0.0.0.0:8069
2015-09-15 04:45:29,120 18499 INFO ? openerp.addons.bus.bus: Bus.loop listen imbus on db postgres
2015-09-15 04:45:29,429 18499 INFO ? openerp.addons.report.models.report: Will use the Wkhtmltopdf binary at /usr/local/bin/wkhtmltopdf
2015-09-15 04:45:29,563 18499 INFO ? openerp.http: HTTP Configuring static files
2015-09-15 04:45:29,571 18499 INFO None openerp.http: Generating nondb routing
2015-09-15 04:45:29,583 18499 ERROR None openerp.http: Exception during JSON request handling.
Traceback (most recent call last):
File “/var/www/rx/openerp/http.py”, line 537, in _handle_exception
return super(JsonRequest, self)._handle_exception(exception)
File “/var/www/rx/openerp/http.py”, line 1415, in _dispatch_nodb
func, arguments = self.nodb_routing_map.bind_to_environ(request.httprequest.environ).match()
File “/var/www/rx/_venv/local/lib/python2.7/site-packages/werkzeug/routing.py”, line 1430, in match
raise NotFound()
NotFound: 404: Not Found
}}}

# Exit Odoo user session

{{{ lang=bash
exit
}}}

= Allow Automatic Booting =

# Copy the sample init script to the init folder, and set permissions

{{{ lang=bash
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 instead

{{{ lang=bash
PATH=/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

{{{ lang=bash
sudo mkdir /var/log/odoo &&
sudo chown odoo:root /var/log/odoo
}}}

# Start the server

{{{ lang=bash
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)

{{{ lang=bash
sudo /etc/init.d/odoo stop
}}}

# Allow for automatic booting (as described [[http://stackoverflow.com/questions/7221757/run-automatically-program-on-startup-under-linux-ubuntu/7221787#7221787|on StackOverflow]])

{{{ lang=bash
sudo update-rc.d odoo defaults
}}}

# Start Odoo through system services

{{{ lang=bash
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 [[https://blog.laslabs.com/2013/09/performance-metrics-apache-vs-nginx/|this article]]).

= Configuration File Reference =

Thanks to [[https://www.odoo.com/fr_FR/forum/help-1/question/how-to-install-odoo-from-github-on-ubuntu-14-04-for-testing-purposes-only-ie-not-for-production-52627|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 = info
}}}


Posted

in

,

by

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *