Thursday, August 16, 2018

How to Install Odoo 11 on Ubuntu 16.04 / 18.04

METHOD 1
INSTALL ODOO 11 ON UBUNTU 16.04 / 18.04

STEP 1
sudo apt-get update

STEP 2
sudo apt-get -y upgrade

STEP 3
sudo apt-get install python3-pip -y
apt-get install libpq-dev -y
pip3 install Babel decorator docutils ebaysdk feedparser gevent greenlet html2text Jinja2 lxml Mako MarkupSafe mock num2words ofxparse passlib Pillow psutil psycogreen psycopg2 pydot pyparsing PyPDF2 pyserial python-dateutil python-openid pytz pyusb PyYAML qrcode reportlab requests six suds-jurko vatnumber vobject Werkzeug XlsxWriter xlwt xlrd

python3 -m pip install werkzeug==0.16.0
pip3 install phonenumbers

STEP 4
sudo apt-get install -y npm
sudo ln -s /usr/bin/nodejs /usr/bin/node
sudo npm install -g less less-plugin-clean-css
sudo apt-get install node-less -y
npm install -g less@3.0.4 less-plugin-clean-css      -----For Style issue

STEP 5
Postgres for Ubuntu 16.04
sudo apt-get install python-software-properties
echo 'deb http://apt.postgresql.org/pub/repos/apt/ xenial-pgdg main' >> /etc/apt/sources.list.d/pgdg.list
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
sudo apt-get update
sudo apt-get install postgresql postgresql-contrib -y
Postgres for Ubuntu 18.04
sudo apt-get install wget ca-certificates
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt/ `lsb_release -cs`-pgdg main" >> /etc/apt/sources.list.d/pgdg.list'
sudo apt-get update -y
sudo apt-get install postgresql postgresql-contrib -y
sudo apt install postgresql postgresql-contrib

STEP 6
sudo su postgres
cd
createuser --createdb --username postgres --no-createrole --no-superuser --pwprompt odoo
createuser --createdb --username postgres --no-createrole --no-superuser --pwprompt root
exit

STEP 7
sudo adduser --system --home=/opt/odoo --group odoo

STEP 8
cd /opt/odoo
sudo wget https://pypi.python.org/packages/a8/70/bd554151443fe9e89d9a934a7891aaffc63b9cb5c7d608972919a002c03c/gdata-2.0.18.tar.gz
sudo tar zxvf gdata-2.0.18.tar.gz
sudo chown -R odoo: gdata-2.0.18
sudo -s
cd gdata-2.0.18/
python setup.py install
exit

STEP 9
cd /opt/odoo
sudo apt-get install git
sudo su - odoo -s /bin/bash
git clone https://www.github.com/odoo/odoo --depth 1 --branch 11.0 --single-branch
exit

STEP 10
sudo mkdir /var/log/odoo
sudo chown -R odoo:root /var/log/odoo

STEP 11
sudo vim /etc/odoo.conf
#Copy and paste below content in config file , write correct addons paths
[options]
; This is the password that allows database operations:
; admin_passwd = admin
db_host = False
db_port = False
db_user = odoo
db_password = False
logfile = /var/log/odoo/odoo-server.log
addons_path = /opt/odoo/addons,/opt/odoo/odoo/addons

sudo chown odoo: /etc/odoo.conf

STEP 12
sudo apt-get -f install
sudo wget https://github.com/wkhtmltopdf/wkhtmltopdf/releases/download/0.12.1/wkhtmltox-0.12.1_linux-trusty-amd64.deb
sudo dpkg -i wkhtmltox-0.12.1_linux-trusty-amd64.deb
sudo cp /usr/local/bin/wkhtmltoimage /usr/bin/wkhtmltoimage
sudo cp /usr/local/bin/wkhtmltopdf /usr/bin/wkhtmltopdf

STEP 13
cd /opt/odoo/odoo
./odoo-bin

STEP 14
http://localhost:8069


METHOD 2
sudo apt update && sudo apt upgrade
sudo apt-get install openssh-server fail2ban
sudo ufw allow ssh
sudo ufw allow 8069/tcp
sudo ufw enable
sudo adduser --system --home=/opt/odoo --group odoo
sudo apt-get install postgresql
sudo su - postgres
createuser --createdb --username postgres --no-createrole --no-superuser --pwprompt odoo
odoo
odoo
exit
sudo apt-get install -y python3-pip
sudo pip3 install Babel decorator docutils ebaysdk feedparser gevent greenlet html2text Jinja2 lxml Mako MarkupSafe mock num2words ofxparse passlib Pillow psutil psycogreen psycopg2 pydot pyparsing PyPDF2 pyserial python-dateutil python-openid pytz pyusb PyYAML qrcode reportlab requests six suds-jurko vatnumber vobject Werkzeug XlsxWriter xlwt xlrd
sudo apt-get install -y npm
sudo ln -s /usr/bin/nodejs /usr/bin/node
sudo npm install -g less less-plugin-clean-css
sudo apt-get install -y node-less
sudo wget https://github.com/wkhtmltopdf/wkhtmltopdf/releases/download/0.12.1/wkhtmltox-0.12.1_linux-trusty-amd64.deb
or
https://downloads.wkhtmltopdf.org/0.12/0.12.5/wkhtmltox_0.12.5-1.xenial_i386.deb
sudo dpkg -i wkhtmltox-0.12.1_linux-trusty-amd64.deb
sudo dpkg -i wkhtmltox_0.12.5-1.xenial_i386.deb
sudo apt-get install -f
sudo dpkg -i wkhtmltox-0.12.1_linux-trusty-amd64.deb
sudo cp /usr/local/bin/wkhtmltopdf /usr/bin
sudo cp /usr/local/bin/wkhtmltoimage /usr/bin
sudo apt-get install git
sudo rm -rf /opt/odoo
sudo su - odoo -s /bin/bash
exit
sudo git clone https://www.github.com/odoo/odoo --depth 1 --branch 11.0 --single-branch /opt/odoo
sudo pip3 install -r /opt/odoo/doc/requirements.txt
sudo pip3 install -r /opt/odoo/requirements.txt    [error in LDAP module]
sudo apt-get install curl
sudo curl -sL https://deb.nodesource.com/setup_4.x | sudo -E bash -

#sudo apt-get update && sudo apt-get install yarn

sudo npm install -g less less-plugin-clean-css
sudo apt install -y nodejs
sudo cp /opt/odoo/debian/odoo.conf /etc/odoo.conf
sudo mkdir /var/log/odoo
sudo chown odoo:root /var/log/odoo
sudo nano /etc/odoo.conf

[options]
; This is the password that allows database operations:
admin_passwd = admin
db_host = False
db_port = False
db_user = odoo
db_password = False
addons_path = /opt/odoo/addons
logfile = /var/log/odoo/odoo.log
xmlrpc_port = 8069

sudo chown odoo: /etc/odoo.conf
sudo chmod 640 /etc/odoo.conf

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

[Unit]
Description=Odoo ERP and CRM
Requires=postgresql.service
After=network.target postgresql.service
[Service]
Type=simple
PermissionsStartOnly=true
SyslogIdentifier=odoo-server
User=odoo
Group=odoo
ExecStart=/opt/odoo/odoo-bin --config=/etc/odoo.conf --addons-path=/opt/odoo/addons/
WorkingDirectory=/opt/odoo/
StandardOutput=journal+console

[Install]
WantedBy=multi-user.target

sudo chmod 755 /etc/systemd/system/odoo.service
sudo chown root: /etc/systemd/system/odoo.service
sudo chown -R odoo: /opt/odoo/
sudo chown odoo:root /var/log/odoo
sudo chown odoo: /etc/odoo.conf
sudo chmod 640 /etc/odoo.conf
systemctl daemon-reload
sudo systemctl start odoo
sudo journalctl -u postgresql
sudo systemctl stop odoo
sudo systemctl status odoo

sudo systemctl enable odoo
sudo journalctl -u odoo
http://:localhost:8069









Proxy Pass odoo 8069 to 80 with enhancements

 

There are couple of things that you should be familiar before going through the steps
  1. Odoo
  2. Linux
  3. Nginx

So i assume the application was now accessible through your port 8069, eg. 188.xx.xx.xx:8069 or yourdomain.com:8069 and your requirement would be
  1. your application should be run on port 80, or your domain eg: yourdomain.com
  2. your application should be run under secure connection
  3. your application should not be accessible through port 8069 anymore     

sudo apt-get install nginx
nano /etc/nginx/sites-available/odoo

upstream odoo {
    server 127.0.0.1:8069;
}

server {
    listen 80;
    server_name yourdomain.com;
    root        /usr/share/nginx/html;
    index       index.html index.htm;
    access_log  /var/log/nginx/yourdomaincom.access.log;
    error_log   /var/log/nginx/yourdomaincom.error.log;

    location / {
        proxy_pass  http://odoo;
        # force timeouts if the backend dies
        proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504;
        proxy_redirect off;

        # set headers
        proxy_set_header    Host            $host;
        proxy_set_header    X-Real-IP       $remote_addr;
        proxy_set_header    X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header    X-Forwarded-Proto https;
    }

    # cache some static data in memory for 60mins
    location ~* /web/static/ {
        proxy_cache_valid 200 60m;
        proxy_buffering on;
        expires 864000;
        proxy_pass http://odoo;
    }
}
Save and exit

cd /etc/nginx/sites-enabled/
ln -s ../sites-available/odoo odoo
rm -rf default
cd cd /etc/nginx/sites-available/
rm -rf default
nginx -t
iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 8069 -j REDIRECT --to-port 80
/etc/init.d/nginx restart

Open URL http://localhost or http://ip

 

No comments:

Post a Comment