Hosting your own Odoo instance on Ubuntu 16.04

 

My friend and I decided to begin our own business, and we quickly decided that we wanted the help of Odoo. To make a long story short, I installed Odoo on Ubuntu 18.04 with the help of a lovely script. Everything worked great until I found out that me choosing to use Ubuntu 18.04 was a mistake. Although Odoo itself is compatible with Ubuntu 18.04, and even though the script had said it had been compatible with 18.04, there was a dependent program that isn’t compatible and resulted in my online store not being operational. It was for that very reason that I decided to quickly make this guide. It was the lack of guides and discussion that resulted in me having to re-do everything I spent hours setting up.

What had been happening:

I mentioned that everything had been working just fine. Literally, everything was working, except for my online payment acquirer. When a shopper came through to purchase something from my shop, they’d add it to their cart, proceed through checkout, pay with Paypal, and then receive a “500 internal server error” once Paypal was returning them to my site. I’m a little embarrassed to admit that I spent days attempting to figure this out. I finally realized that the problem was with the dependency wkhtmltox not being installed. The version that Odoo v11CE wanted wasn’t compatible with Ubuntu 18.04, and the version of wkhtmltox that was compatible with Ubuntu 18.04 didn’t work with Odoo v11CE.

How to successfully host your own Odoo v11:

Biggest suggestion: I highly suggest utilizing Ubuntu 16.04 as your OS because it is the most commonly used, and has the most documentation in regards to Odoo.

My setup: I have a server in my house that is running Proxmox and it hosts all of my virtual machines. One of those machines is an instance of ISPconfig that hosts websites. Because I’m installing Odoo on a completely different VM, I created the website in the ISPconfig control panel, but am having it use “proxy_pass” to forward all requests to the odoo instance. My Odoo instance will be installed on a LXC container running Ubuntu 16.04 with all current regular and security updates.

Lets get started:

If you need help installing/setting up a fresh copy of Ubuntu 16.04, click here for a good guide to follow.

Updating your fresh OS:

I mentioned that I am installing Odoo on a fresh copy of Ubuntu 16.04 with all of the current updates. Just to make sure you’re in the same boat, run the following command:

sudo apt-get update && sudo apt-get upgrade -y

[Optional Step] Installing Webmin

This was also captured at the end of the guide I mentioned earlier. I personally love Webmin and highly recommend installing it.

  1. from terminal run the following command:
    sudo nano /etc/apt/sources.list.d/webmin.list
  2. Add the following line to that file:
    deb http://download.webmin.com/download/repository sarge contrib
  3. hit [CTRL][X] at the same time and save the file.
  4. Run the following command to download the webmin key
    sudo wget http://www.webmin.com/jcameron-key.asc
  5. Add the downloaded key with the command:
    sudo apt-key add jcameron-key.asc
  6. Remove the key that we no longer need with the following command:
    rm jcameron-key.asc
  7. Update apt with the following command:
    sudo apt-get update
  8. Install webmin with the following command:
    sudo apt-get install webmin -y

Installing Odoo

After playing around with Odoo for quite some time, expirmenting with several different instances of it, I stumbled across this handy script that does all of the hard work for you. It can be found here.

In terminal, run the following command to grab a copy of the scriptwget https://raw.githubusercontent.com/Yenthe666/InstallScript/11.0/odoo_install.sh

[FYI] You can edit any portion of that script (to select different versions of Odoo, etc) by running the following command:
nano odoo_install.sh

Then, we need to change the permissions of that script before we can run it, so lets execute this command:
chmod +x odoo_install.sh

Finally, we’ll run the script with this command:
./odoo_install.sh

Fixing Your Database:

Before you’re able to actually start using Odoo, you’ll have to fix a database formatting issue. Here is where I grabbed these steps from. To do this, follow these steps:

Run this command in terminal:
sudo -u postgres psql postgres

Then run these commands to edit the database formatting:
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';

Then, to get out of the database, hit [CTRL] and [D] keys at the same time.

You should now be able to access your Odoo by going to http://YOUR_ODOO_IP:8069

Before doing that, I make it so that you don’t need the port number to access Odoo.

Installing Nginx:

As I mentioned, I also install nginx so that requests can be received on http port 80 versus only 8069. To do this, I referenced this guide and made it work for our case.

To get started, we have to install Nginx:
sudo apt-get install nginx -y

Then, I run the following commands to create SSL certificates:
sudo mkdir /etc/nginx/ssl
cd /etc/nginx/ssl
sudo openssl genrsa -des3 -passout pass:x -out server.pass.key 2048
sudo openssl rsa -passin pass:x -in server.pass.key -out server.key
sudo rm server.pass.key
sudo openssl req -new -key server.key -out server.csr
sudo openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt

Next, you have to configure nginx:
sudo nano /etc/nginx/sites-available/yourOdooSite.com

When that opens, paste the following into:

upstream oddo {
server 127.0.0.1:8069;
}

server {
listen 443 default;
server_name yourOdooSite.com;

access_log /var/log/nginx/oddo.access.log;
error_log /var/log/nginx/oddo.error.log;

ssl on;
ssl_certificate /etc/nginx/ssl/server.crt;
ssl_certificate_key /etc/nginx/ssl/server.key;
keepalive_timeout 60;

ssl_ciphers HIGH:!ADH:!MD5;
ssl_protocols SSLv3 TLSv1;
ssl_prefer_server_ciphers on;

proxy_buffers 16 64k;
proxy_buffer_size 128k;

location / {
proxy_pass http://oddo;
proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504;
proxy_redirect off;

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;
}

location ~* /web/static/ {
proxy_cache_valid 200 60m;
proxy_buffering on;
expires 864000;
proxy_pass http://oddo;
}
}

server {
listen 80;
server_name yourOdooSite.com;

add_header Strict-Transport-Security max-age=2592000;
rewrite ^/.*$ https://$host$request_uri? permanent;
}

Before exiting and saving, change all of the “yourOdooSite.com” values that should be set to your own.

Then hit [CTRL] and [X] to leave, select to save and replace the existing file.

Next, create the symbolic link from sites-available to sites-enabled to activate this configuration:
sudo ln -s /etc/nginx/sites-available/yourOdooSite.com /etc/nginx/sites-enabled/yourOdooSite.com

Restart Nginx:
sudo /etc/init.d/nginx restart

Congrats! You’ve made your Odoo instance!

Online Porfolio Sale<<

About the author : motermouth15

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.