Musfiqur Rahman

write something meaningless for human but meaningful for machine

Deploy Odoo 11 in 11 Minutes

2018-01-14 Musfiqur Rahman

Odoo ERP System is one of the renowned ERP System in the world. But the resources of odoo Deployment is not handy. My Purpose is to make an article on simplest deployment of Odoo ERP in Ubuntu 16.04 . If we follow these following steps, we will make production ready deployment in 11 minutes.

Step 1: First update the package index and then upgrade to make sure all installed programs are up to date.

sudo apt-get update
sudo apt-get upgrade -y
sudo apt-get install python3.x-dev #your python3 version specific (e.g for Python3.6 use sudo apt-get install python3.6-dev)

Step 2: Good Security Practice is to use a dedicated user for running odoo, with no special privileges. Create a users for system and database

sudo adduser --disable-password --gecos "Odoo" odoo

sudo su -c "createuser odoo" postgres

sudo su postgres

createdb --owner=odoo odoo-prod

exit

Step 3: Make sure that your system Python environment is up to date with odoo-11 requirement file

sudo -H pip install --upgrade pip

virtualenv -p python3 env3

wget https://raw.githubusercontent.com/odoo/odoo/11.0/requirements.txt

source env3/bin/activate

pip install -r requirements.txt

Step 4 : Now change to the dedicated odoo user and clone the odoo-11 from git repo

sudo su odoo

cd ~ #move to odoo dedicated home directory

git clone https://github.com/odoo/odoo.git /home/odoo/odoo-11.0 -b 11.0 --depth=1

Step 5: Now Test odoo is currently configured for this system or not. Then exit odoo user.

/home/odoo/odoo-11.0/odoo-bin --help

exit

Step 6: Setting up the configuration file in using —save option when starting odoo server which saves the configuration in ~/.odoorc

sudo su -c "/var/www/env3/bin/python ~/odoo-11.0/odoo-bin -d odoo_prod11 --save --stop-after-init" odoo

Step 7: Now store it in /etc/odoo folder or your expected location

sudo mkdir /etc/odoo

sudo su odoo

sudo cp /home/odoo/.odoorc /etc/odoo/odoo11.conf #save odoo.conf 

sudo chown -R odoo /etc/odoo

Step 8: We also wants to create the directory where the odoo service will store it’s log file. This is expected to be somewhere inside /var/log

sudo mkdir /var/log/odoo
sudo chown odoo /var/log/odoo

Step 9: Add the log file directory in /etc/odoo/odoo.conf configuration file

sudo nano /etc/odoo/odoo11.conf

logfile = /var/log/odoo/odoo-prod11.log 

Step 10: Check the effect of the settings by made by running the server

sudo su -c "/var/www/env3/bin/python ~/odoo-11.0/odoo-bin -c /etc/odoo/odoo.conf" odoo

sudo tail -f /var/log/odoo/odoo-prod11.log # Check the tail of log file

Step 11: Setting up as a system service. To add a new service to the system, we just need to create a file describing it. Create a file in the following directory

sudo nano /lib/systemd/system/odoo.service

Now add the following content into odoo.service

[Unit]
Description=Odoo
After=postgresql.service

[Service]
Type=simple
User=odoo
Group=odoo
ExecStart=/var/www/env3/bin/python /home/odoo/odoo-11.0/odoo-bin -c /etc/odoo/odoo.conf

[Install]
WantedBy=multi-user.target

Step 12: Now we need to register the new service

sudo systemctl enable odoo.service

Step 13: Start the new service using the following command

sudo systemctl start odoo

Step 14: Check the status that odoo is running fine or not

sudo systemctl status odoo

Step 15: To stop the odoo service , input the following command

sudo systemctl stop odoo

Step 16: Before Installing nginx, stop the service of apache2

sudo service apache2 stop

Step 17: Now install the nginx application

sudo apt-get install nginx

Step 18: Now disable the default configuration provided by the Nginx installation and symlink the current one

sudo rm /etc/nginx/sites-enabled/default

sudo touch /etc/nginx/sites-available/odoo

sudo ln -s /etc/nginx/site-available/odoo /etc/nginx/sites-enabled/odoo

Step 19: Now configure the configuration file as follows:

sudo nano /etc/nginx/sites-available/odoo

#Configuration file code
upstream <ip/address-link>{
	server 127.0.0.1:8069;
}

server {
 	location / {
		proxy_pass http://<ip/address-link>;
	}
}

Step 20: Test that the edited configuration is correct using following command

sudo nginx -t

Step 21: Reload the nginx configuration as follows

sudo /etc/init.d/nginx reload

Disclaimer: This article was written on 14.01.2018. The author is planning to try out the latest odoo deployment. Stay Tuned.