Log in via SSH and Update your Server

First, you will need to log in to your CentOS 8 VPS by using SSH as the root user:

ssh root@IP_ADDRESS -p PORT_NUMBER

Replace IP_ADRRESS and PORT_NUMBER with the correct server IP address and SSH port number. The default port number is 22, but your server may have a unique one set.

Next, run the following commands to upgrade all installed packages on your VPS:

dnf update -y

Once all of the packages are updated, restart your system to apply any changes that require a reboot. This ensures a clean slate on which we’ll be installing our Odoo 14 instance.

Install the Required Dependencies

Before you begin with the Odoo installation, you will need to install Python 3 and some other Odoo dependencies onto your system. You can install all of them using the following command:

dnf install python3 python3-devel git gcc redhat-rpm-config libxslt-devel bzip2-devel openldap-devel libjpeg-devel freetype-devel curl unzip -y

Once all the packages are installed, you will also need to install the wkhtmltopdf package in your system. Wkhtmltopdf is an open-source tool that can be used to convert the HTML format to a PDF, that way Odoo can export PDF reports.

You can install it by running the following command:

dnf install https://github.com/wkhtmltopdf/wkhtmltopdf/releases/download/0.12.5/wkhtmltox-0.12.5-1.centos8.x86_64.rpm

Verify that wkhtmltopdf is installed on your server:

# wkhtmltopdf --version
wkhtmltopdf 0.12.5 (with patched qt)

Once this is done, you can proceed to the next step.

Install and Configure PostgreSQL

Odoo uses PostgreSQL to store its data. You can install the PostgreSQL server with the following command:

dnf install postgresql postgresql-server postgresql-contrib -y

Once the installation is completed, initialize the database with the following command:

postgresql-setup initdb

To start the PostgreSQL service and enable it to automatically start after every server reboot, run the following commands:

systemctl start postgresql
systemctl enable postgresql

Next, log in to the PostgreSQL shell and create a new PostgreSQL user for your Odoo database, with the following command. The name we used is odoo14, but you can use any name you like. KEEP IN MIND that the username you set here has to be identical to the system user that you’re going to create in the next step:

su - postgres -c "createuser -s odoo14"

Install and Configure Odoo 14 on CentOS 8

In this section, we will download Odoo 14 from the official Git repository and install it in a Python virtual environment.

First, we need to create a new system user for our Odoo installation. Make sure the username is the same as the PostgreSQL user we created in the previous step:

useradd -m -U -r -d /opt/odoo14 -s /bin/bash odoo14

Next, log in as the newly created odoo14 user and download Odoo 14 from the official Git repository:

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

Once the download is complete, create a new Python virtual environment for the Odoo 14 installation with the following command:

cd /opt/odoo14 && python3 -m venv odoo14-venv

Activate the virtual environment with the following command:

source odoo14-venv/bin/activate

You can now install the required python modules using the pip3 command, as shown below:

(odoo14-venv) $ pip3 install wheel
(odoo14-venv) $ pip3 install -r odoo14/requirements.txt

Once all the required modules are installed successfully, deactivate the virtual environment and switch back to the sudo or root user with the following command:

(odoo14-venv) $ deactivate && exit

Next, create a separate directory for Odoo’s custom addons/apps. The best practice is to install custom Odoo modules in a separate directory. This ensures that if some custom module doesn’t work, it can easily be removed without risking the removal of default modules that come included with the regular installation.

mkdir /opt/odoo/odoo14-custom-addons
chown odoo: /opt/odoo/odoo14-custom-addons

The following commands will create a log file for the new Odoo 14 installation:

mkdir /var/log/odoo14 && touch /var/log/odoo14/odoo14.log
chown -R odoo14: /var/log/odoo14/

You can now create a configuration file for your Odoo installation:

nano /etc/odoo14.conf

Open that file and enter the following information:

[options]
; This is the password that allows database operations:
admin_passwd = master_password
db_host = False
db_port = False
db_user = odoo14
db_password = False
xmlrpc_port = 8069
; longpolling_port = 8072
logfile = /var/log/odoo14/odoo14.log
logrotate = True
addons_path = /opt/odoo/odoo14/addons,/opt/odoo/odoo14-custom-addons

Make sure you set a strong and difficult to guess master_password.

After you are done, save and close the file.

Create a Systemd Unit File for Odoo 14

We will now create a systemd unit file so that we can run our Odoo 14 instance as a service.

You can create the service with the following command:

nano /etc/systemd/system/odoo14.service

Once you open the file, add the following lines:

[Unit]
Description=Odoo14
Requires=postgresql.service
After=network.target postgresql.service
[Service]
Type=simple
SyslogIdentifier=odoo14
PermissionsStartOnly=true
User=odoo14
Group=odoo14
ExecStart=/opt/odoo14/venv/bin/python3 /opt/odoo14/odoo/odoo-bin -c /etc/odoo14.conf
StandardOutput=journal+console
[Install]
WantedBy=multi-user.target

Save and close the file, then reload the systemd daemon list with the following command:

systemctl daemon-reload

You can now start the Odoo 14 service and enable it to start at boot with the following commands:

systemctl start odoo14
systemctl enable odoo14

You can now verify the status of your Odoo 14 service with:

systemctl status odoo14

Configure Nginx as a Reverse Proxy

Your Odoo 14 install is complete and is now accessible at your CentOS 8 server’s public IP with the post number 8069. However, if you want to access your Odoo application using a domain name instead of typing the IP address and the port number in the URL, you will have to configure a reverse proxy on your server.

We will show you how to implement the reverse proxy configuration using the Nginx web server. Nginx is a powerful and high-performance web server that focuses on customization and performance.

First, install Nginx with the following command:

dnf install nginx -y

Once installed, create a new Nginx virtual host configuration file. Replace yourdomain.com with your registered domain name:

nano /etc/nginx/conf.d/yourdomain.com.conf

Add the following lines:

upstream odoo {
server 127.0.0.1:8069;
}
upstream odoochat {
server 127.0.0.1:8072;
}
server {
listen 80;
server_name yourdomain.com;
proxy_read_timeout 720s;
proxy_connect_timeout 720s;
proxy_send_timeout 720s;
# Proxy headers
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Real-IP $remote_addr;
# log files
access_log /var/log/nginx/yourdomain.com.log;
error_log /var/log/nginx/yourdomain.com.log;
# Handle longpoll requests
location /longpolling {
proxy_pass http://odoochat;
}
# Cache static files
location ~* /web/static/ {
proxy_cache_valid 200 90m;
proxy_buffering on;
expires 864000;
proxy_pass http://odoo;
}
gzip_types text/css text/less text/plain text/xml application/xml application/json application/javascript;
gzip on;
}

Make sure to replace yourdomain.com with your registered domain name.

You can now start the Nginx service and enable it to start at boot with the following commands:

systemctl start nginx
systemctl enable nginx

You will also need to configure your Odoo to use the proxy. You can do it by editing the Odoo configuration file:

nano /etc/odoo14.conf

And add the following line to the end of the file:

proxy_mode = True

Save and close the file, then restart the Odoo 14 service to implement the changes:

systemctl restart odoo14

Access the Odoo 14 Instance

You should now be able to access the Odoo 14 instance with your domain name at http://yourdomain.com.

By anup

Leave a Reply

Your email address will not be published. Required fields are marked *