A complete Guide on How to Install Odoo 17 on Ubuntu 20.04 LTS
sudo apt-get update -y
sudo apt-get upgrade -y
sudo sudo adduser --system --home=/opt/[odoo17] --group [odoo17]
Install the necessary dependencies.
sudo apt install -y software-properties-common
Add the deadsnakes PPA to install Python 3.10.
sudo add-apt-repository ppa:deadsnakes/ppa
sudo apt update
Install Python 3.10.
sudo apt install -y python3.10
sudo apt install -y python3.10-venv python3.10-dev
curl -sS https://bootstrap.pypa.io/get-pip.py | sudo python3.10
Ensure Python 3.10 is installed correctly. You should see something like Python 3.10.x.
python3.10 --version
sudo apt-get install openssh-server fail2ban
sudo wget https://github.com/wkhtmltopdf/wkhtmltopdf/releases/download/0.12.5/wkhtmltox_0.12.5-1.bionic_amd64.deb
chmod -R 777 wkhtmltox_0.12.5-1.bionic_amd64.deb
sudo dpkg -i wkhtmltox_0.12.5-1.bionic_amd64.deb
sudo apt install -f
sudo apt-get install -y python3-pip
sudo apt-get install python-dev python3-dev libxml2-dev libxslt1-dev zlib1g-dev libsasl2-dev libldap2-dev build-essential libssl-dev libffi-dev libmysqlclient-dev libjpeg-dev libpq-dev libjpeg8-dev liblcms2-dev libblas-dev libatlas-base-dev
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 apt-get install postgresql
sudo su - postgres
createuser --createdb --username postgres --no-createrole --no-superuser --pwprompt [odoo17]
The user and the password are needed for the conf file. Postgres uses a distinct system user to perform tasks.
psql
ALTER USER [odoo17] WITH SUPERUSER;
\q
exit
sudo adduser --system --home=/opt/[odoo17] --group [odoo17]
sudo apt-get install git
sudo su - [odoo17] -s /bin/bash
sudo mkdir /opt/[odoo17]
git clone https://www.github.com/odoo/odoo --depth 1 --branch 17.0 --single-branch /opt/[odoo17]
exit
Ensure Python 3.10 is installed correctly.
sudo -s
python3.10 --version
Create a virtual environment for Odoo 17.
python3.10 -m venv /opt/[odoo17]/venv
Activate the virtual environment & Install Odoo dependencies within it. After you finish deactivate it.
source /opt/[odoo17]/venv/bin/activate
sudo pip3 install -r /opt/[odoo17]/requirements.txt
deactivate
sudo pip3 install -r /opt/[odoo17]/requirements.txt
sudo cp /opt/[odoo17]/debian/odoo.conf /etc/[odoo17].conf
sudo nano /etc/[odoo17].conf
[options]
; This is the password that allows database operations:
; Edit admin_passwd and set your master password there !
admin_passwd = admin
db_host = False
db_port = False
db_user = [odoo17]
db_password = False
proxy_mode = True
addons_path = /opt/[odoo17]/addons
logfile = /var/log/[odoo17]/[odoo17].log
sudo chown [odoo17]: /etc/[odoo17].conf
sudo chmod 640 /etc/[odoo17].conf
sudo mkdir /var/log/[odoo17]
sudo chown [odoo17]:root /var/log/[odoo17]
We have to create a service to run Odoo 17. Let’s create a service file ‘[odoo17].service’ in /etc/systemd/system.
sudo nano /etc/systemd/system/[odoo17].service
[Unit]
Description=Odoo17
Documentation=http://www.odoo.com
[Service]
# Ubuntu/Debian convention:
Type=simple
User=[odoo17]
# if you are using venv then use this ExecStart :
# ExecStart=/opt/[odoo17]/venv/bin/python /opt/[odoo17]/odoo-bin -c /etc/[odoo17].conf
#
ExecStart=/usr/bin/python3.10 /opt/[odoo17]/odoo-bin -c /etc/[odoo17].conf
[Install]
WantedBy=default.target
sudo chmod 755 /etc/systemd/system/[odoo17].service
sudo chown root: /etc/systemd/system/[odoo17].service
sudo systemctl start [odoo17].service
sudo systemctl daemon-reload
sudo systemctl restart odoo17
sudo systemctl enable odoo17
sudo systemctl status odoo17
http://<your_domain_or_IP_address>:8069
This guide will help you set up Apache2 to reverse proxy Odoo on a VPS using the server's IP address.
If you haven't already installed Apache2, you can do so by running the following commands:
sudo apt update
sudo apt install apache2
You need to enable some modules in Apache to use it as a reverse proxy:
sudo a2enmod proxy
sudo a2enmod proxy_http
sudo a2enmod headers
sudo a2enmod rewrite
After enabling these modules, restart Apache to apply the changes:
sudo systemctl restart apache2
Create a new configuration file for your Odoo setup in Apache:
sudo nano /etc/apache2/sites-available/odoo.conf
Add the following configuration to the file. Replace YOUR_SERVER_IP
with your VPS's IP address:
<VirtualHost *:80>
ServerAdmin admin@yourdomain.com
ServerName YOUR_SERVER_IP
ProxyRequests Off
ProxyPass / http://localhost:8069/
ProxyPassReverse / http://localhost:8069/
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
<Location />
Order allow,deny
Allow from all
</Location>
ErrorLog ${APACHE_LOG_DIR}/odoo_error.log
CustomLog ${APACHE_LOG_DIR}/odoo_access.log combined
</VirtualHost>
Save and close the file.
Enable the site configuration and disable the default site:
sudo a2ensite odoo.conf
sudo a2dissite 000-default.conf
Step 5: Restart Apache
To apply your new configuration, restart Apache:
sudo systemctl restart apache2
You should now be able to access Odoo using your VPS's IP address in a web browser. Simply type http://YOUR_SERVER_IP
in your browser's address bar, where YOUR_SERVER_IP
is your VPS's IP address.
Check Firewall Status: First, check if the firewall is active on your Ubuntu server. The default firewall for Ubuntu is UFW (Uncomplicated Firewall). Check its status with:
sudo ufw status
Allow Apache Through Firewall: Since you are using Apache as a reverse proxy for Odoo, you need to allow Apache through the firewall. Apache registers a few profiles with UFW. You can allow traffic on port 80 (HTTP)
with the following command:
sudo ufw allow 'Apache'
Enable the Firewall: If the firewall is not active, enable it with:
sudo ufw enable
Check the Updated Firewall Status: Finally, check the status again to ensure your rules are active:
sudo ufw status
If you encounter the warning AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1. Set the 'ServerName' directive globally
, follow these steps:
Open the Apache2 Configuration File:
sudo nano /etc/apache2/apache2.conf
Set the Global ServerName: Add a line at the bottom of this file with your server's IP address or a dummy FQDN. For example:
ServerName YOUR_SERVER_IP
Replace YOUR_SERVER_IP
with your server's public IP address
.
Save and Close the File: After adding the line, save the file and exit the editor.
Restart Apache: To apply the changes, restart Apache:
sudo systemctl restart apache2
Check the Status Again: Finally, check the status of Apache again to ensure the warning is gone:
systemctl status apache2
This should resolve the warning about the server's FQDN.
Additional Notes
Accessing Odoo: You can now access Odoo using your server's IP address: http://YOUR_SERVER_IP/web
Firewall Considerations: If you're accessing the server via SSH, make sure to allow SSH (port 22) through the firewall before enabling it to avoid locking yourself out of the server:
sudo ufw allow ssh