How to Install Odoo 12 on Ubuntu 18.04 with Apache as a Reverse Proxy

In this tutorial, we will guide you through the steps of installing Odoo 12 on an Ubuntu 18.04 VPS. Additionally, we will show you how to install and configure the Apache web server as a reverse proxy for your Odoo application.

Odoo (formerly OpenERP) is a simple and intuitive suite of open-source enterprise management applications, such as Website Builder, eCommerce, CRM, Accounting, Manufacturing, Project and Warehouse Management, Human Resources, Marketing, and many more. Odoo comes in two editions: Community edition, which is free, and Enterprise edition. In our case, we will install and use the Community edition. Let’s begin.

Prerequisites

  • Ubuntu 18.04 with 2GB of memory or higher (we’ll be using our Managed Ubuntu SSD 2 VPS for this)
  • Python 3
  • PostgreSQL
  • Apache
  • SSH access with root privileges, or access to the root user

Step 1: Log in via SSH and Update the System

Log in to your Ubuntu 18.04 VPS with SSH as a root user

ssh root@IP_Address -p Port_number

You can check whether you have the proper Ubuntu version installed on your server with the following command:

lsb_release -a

You should get this output:

Distributor ID: Ubuntu
Description: Ubuntu 18.04.1 LTS
Release: 18.04
Codename: bionic

Once you are logged in, run the following command to update all installed packages to the latest available version.

apt update && apt upgrade

Step 2: Install PostgreSQL Server

Odoo requires a PostgreSQL database to store its information, so we will have to install the PostgreSQL server. We will install a PostgreSQL server using the following command:

apt install postgresql

Once installed, PostgreSQL server will be started and it’s also enabled to start at server boot.

Step 3: Install Odoo

Method 1

If you want to install Odoo on your fresh server or you currently do not have an Odoo instance running on your server, you can follow this method.

Add repository and install Odoo

Odoo is not available in the official Ubuntu 18.04 repository, so in order to install it, we will need to add the Odoo repository to the server. In order to do it, run the following commands:

wget -O - https://nightly.odoo.com/odoo.key | apt-key add -
echo "deb http://nightly.odoo.com/12.0/nightly/deb/ ./" >> /etc/apt/sources.list.d/odoo.list

Next, update the local package database

apt update

and install Odoo using the apt package manager

apt install odoo

This command will install Odoo 12, Python 3 and all necessary Python modules, create a PostgreSQL user, and start the Odoo instance. After the installation is completed, you can check the status of the Odoo service:

systemctl status odoo

Method 2

If you want to run multiple Odoo version on your Ubuntu 18.04 server and/or you have another version of Odoo running on your server, you can follow these steps to install and configure Odoo 12 using their Github repository and Python virtual environment.

Install dependencies

apt install build-essential wget git python3-pip python3-dev python3-venv python3-wheel python3-setuptools libxslt-dev libzip-dev libldap2-dev libsasl2-dev python3-setuptools node-less

Create a new system and PostgreSQL user for Odoo

useradd -m -d /opt/odoo12 -U -r -s /bin/bash odoo12
su - postgres -c "createuser -s odoo12"

Install Wkhtmltopdf

The wkhtmltopdf package is an open source tool that Odoo uses to make HTML in PDF formats so that it can print PDF reports. The recommended version for Odoo is 0.12.1 which is not available in the official Ubuntu 18.04 repositories.

cd /opt
wget https://builds.wkhtmltopdf.org/0.12.1.3/wkhtmltox_0.12.1.3-1~bionic_amd64.deb
apt install /opt/wkhtmltox_0.12.1.3-1~bionic_amd64.deb

That’s it, wkhtmltopdf has been installed.

Install odoo 12

su - odoo12
git clone https://www.github.com/odoo/odoo --depth 1 --branch 12.0 /opt/odoo12/odoo

Now, still as user odoo12, let’s create a new python virtual environment

python3 -m venv odoo-venv

Then, let’s activate it

source odoo-venv/bin/activate

pip3 install wheel
pip3 install -r odoo/requirements.txt
(venv) $ deactivate && exit

We need an Odoo configuration file, we can copy the one from GitHub:

cp /opt/odoo12/odoo/debian/odoo.conf /etc/odoo12.conf

We can create a master password, you can change the “m0d1fyth15” to your own password. Also, add addons_path and xmlrpc_port if you want to specify a port to run Odoo on, if you do not specify it, then Odoo will run on its default port, 8069.

nano /etc/odoo12.conf
[options]
; This is the password that allows database operations:
admin_passwd = m0d1fyth15
db_host = False
db_port = False
db_user = odoo12
db_password = False
addons_path = /opt/odoo12/odoo/addons
xmlrpc_port = 8001

Save the file then exit, then we create a systemd file to run Odoo 12.

nano /etc/systemd/system/odoo12.service
[Unit]
Description=Odoo12
Requires=postgresql.service
After=network.target postgresql.service

[Service]
Type=simple
SyslogIdentifier=odoo12
PermissionsStartOnly=true
User=odoo12
Group=odoo12
ExecStart=/opt/odoo12/odoo-venv/bin/python3 /opt/odoo12/odoo/odoo-bin -c /etc/odoo12.conf
StandardOutput=journal+console

[Install]
WantedBy=multi-user.target
systemctl daemon-reload
systemctl start odoo12

At this point, we can access our new Odoo 12 installation at http://IP_Address:Odoo_port. To access it using a domain we need to configure a reverse proxy, and this time we will use Apache to do it.

Setting up Apache as a Reverse Proxy

If you have a valid domain name and you would like to use it in order to access your Odoo application instead of typing the IP address and the port number in the URL, we will now show you how to set up a reverse proxy using the Apache web server.

We will start by installing the Apache web server. Apache is considered as the most widely used web server software. It is fast, secure, reliable and can be easily customized depending on your needs.

To install Apache on your server, run the following command:

apt install apache2

After the installation is complete, you should enable Apache to start automatically upon system boot. You can do that with the following command:

systemctl enable apache2

To verify that Apache is running, open your web browser and enter your server IP address, (e.g. http://111.222.333.444). If Apache is successfully installed you should see a message saying “It works!”.

Next, we will need to enable some additional proxy modules for Apache. You can do this with the following commands:

Need a fast and easy fix?
✔ Unlimited Managed Support
✔ Supports Your Software
✔ 2 CPU Cores
✔ 2 GB RAM
✔ 50 GB PCIe4 NVMe Disk
✔ 1854 GeekBench Score
✔ Unmetered Data Transfer
NVME 2 VPS

Now just $43 .99
/mo

GET YOUR VPS
a2enmod proxy
a2enmod proxy_http

Once this is done, open a new configuration file for your domain with the following command:

nano /etc/apache2/sites-available/yourdomain.com.conf

And enter the following:
ServerName yourdomain.com
ServerAlias www.yourdomain.com

ProxyRequests Off

Order deny,allow
Allow from all


ProxyPass / http://yourdomain.com:8069/
ProxyPassReverse / http://yourdomain.com:8069/

Order allow,deny
Allow from all

Remember to replace ‘yourdomain.com‘ with your actual domain name.

Enable “yourdomain.conf” configuration in Apache using:

a2ensite yourdomain.com

Restart the Apache Web Server

Save the file, close it and restart Apache for the changes to take effect:

service apache2 restart

Now you should be able to access Odoo with your domain name at http://yourdomain.com. Create your first Odoo database using the master password we set earlier in this tutorial, and start working on your project. For more information about Odoo 12, its features and configuration, please check their official documentation.

Install Odoo 12 CentOS 7


Of course, you don’t have to install Odoo 12 on Ubuntu 18.04 if you use one of our Odoo VPS Hosting services, in which case you can simply ask our expert Linux admins to install Odoo 12 on Ubuntu 18.04, for you. They are available 24×7 and will take care of your request immediately. You can also refer to this guide: How to Install Odoo 14 on Ubuntu 20.04 with Apache as a Reverse Proxy for more information.

PS. If you liked this post on installing Odoo 12 on Ubuntu 18.04 with Apache as a reverse proxy, please share it with your friends on the social networks using the share shortcuts, or simply leave a comment in the comments section. Thanks.

4 thoughts on “How to Install Odoo 12 on Ubuntu 18.04 with Apache as a Reverse Proxy”

    • You can try and install Let’s Encrypt SSL which offers a free SSL:
      First, install certbot:
      sudo apt-get install software-properties-common
      sudo add-repository universe
      sudo apt-get update
      sudo apt-get install certbot python3-certbot-apache

      Second, generate a free SSL certificate for your domain:
      sudo certbot –apache
      Note: You can enable redirection if you want HTTP traffic to be redirected to HTTPS

      Reply
  1. If I already have an apache installation, with SSL browsing with https, How should I add the configuration to the actual apache?
    Is it possible to redirect to a subdomain, for example oddo.mybusiness.com, taking into account that I already have the www.mybusiness.com with my web page.

    Many thanks in advance.

    Reply
    • You can still follow the exact same steps as explained in the tutorial.
      You just need to create a new configuration file for your new domain, for example at /etc/apache2/sites-available/yourdomain.com.conf

      Reply

Leave a Comment