How to Install Odoo 18 on AlmaLinux 9

How to install Odoo 18 on AlmaLinux 9

Odoo provides many applications, including accounting, inventory management, CRM, and e-commerce. This versatility makes it a favored option for businesses of all sizes. This guide will teach you how to install Odoo 18 on AlmaLinux 9, ensuring you have a fully operational Odoo instance on your Alma Linux system. Follow each step meticulously, and refer back to this guide whenever necessary.

Prerequisites:

  • An AlmaLinux 9 VPS
  • At least 2GB of RAM
  • SSH root access or a system user with sudo privileges

Step 1. Update System Packages

To start, log in to your Alma Linux 9 VPS using SSH:

ssh root@IP_Address -p Port_number

Replace ‘IP_Address’ and ‘Port_number’ with your server’s actual IP address and SSH port number. If needed, replace ‘root’ with the username of your sudo account.

Once logged in, you must make sure that all AlmaLinux OS packages installed on the server are up to date. You can do this by running the following commands:

dnf update && dnf upgrade

Step 2. Install Dependencies:

Afterwards, install essential dependencies on your server. Run the following command to install these dependencies:

dnf install git gcc redhat-rpm-config libxslt-devel bzip2-devel openldap-devel libjpeg-devel freetype-devel curl unzip openssl-devel wget yum-utils make libffi-devel zlib-devel tar

Step 3. Enable PowerTools repository

The PowerTools repository is necessary to install the psycopg2 module required by Odoo to connect to PostgreSQL. You can activate it by running the below command:

dnf config-manager --set-enabled crb

Step 4. Install Python 3.12:

Odoo 18 requires Python 3.10 or later to run. Let’s download the source code for the latest Python 3.12 version, which is 3.12.7. Use the following command:

wget https://www.python.org/ftp/python/3.12.7/Python-3.12.7.tgz

Output:

# wget https://www.python.org/ftp/python/3.12.7/Python-3.12.7.tgz
--2024-11-09 13:25:20--  https://www.python.org/ftp/python/3.12.7/Python-3.12.7.tgz
Resolving www.python.org (www.python.org)... 151.101.0.223, 151.101.64.223, 151.101.128.223, ...
Connecting to www.python.org (www.python.org)|151.101.0.223|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 27016272 (26M) [application/octet-stream]
Saving to: ‘Python-3.12.7.tgz’

Python-3.12.7.tgz                                                              100%[==================================================================================================================================================================================================>]  25.76M  67.5MB/s    in 0.4s    

2024-11-09 13:25:21 (67.5 MB/s) - ‘Python-3.12.7.tgz’ saved [27016272/27016272]

Next, extract the downloaded file using the following command:

tar xvf Python-3.12.7.tgz

After extracting, navigate to the Python installation folder and run the following commands:

cd Python-3.12.7
./configure --with-system-ffi --with-computed-gotos --enable-loadable-sqlite-extensions

This step will set up the Python installation and configure it for compilation.

Next, we compile and install the source code using make command. Use the following commands:

make -j ${nproc} 
make altinstall

After the installation finishes, verify the Python version by using the following command:

python3.12 -V

You should get the following output:

# python3.12 -V
Python 3.12.7

Step 5. Install PostgreSQL:

Odoo utilizes PostgreSQL as its database system and requires the version 12.0 or later. So you will need to add the official PostgreSQL Repository for the Alma Linux system by running the below command:

dnf install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-9-x86_64/pgdg-redhat-repo-latest.noarch.rpm

Now install the the latest version of PostgreSQL with the following command:

dnf install -y postgresql17-server postgresql17 postgresql17-devel

Once the installation is complete, initialize the PostgreSQL database:

/usr/pgsql-17/bin/postgresql-17-setup initdb

Next, initiate and enable the PostgreSQL service with the following command. This command will start PostgreSQL and configure it to launch automatically during boot.

systemctl enable postgresql-17 && systemctl start postgresql-17

After installing PostgreSQL, create a new PostgreSQL user for Odoo with the following command:

su - postgres -c "createuser -s odoo18"

Step 6. Install Wkhtmltopdf:

To facilitate printing in Odoo 18, you will need a wkhtmltopdf version greater than 0.12.5. Wkhtmltopdf is a command-line tool that transforms HTML content into PDF format using Qt WebKit. To install wkhtmltopdf on your Alma Linux server, use the following command:

dnf install -y https://github.com/wkhtmltopdf/packaging/releases/download/0.12.6.1-2/wkhtmltox-0.12.6.1-2.almalinux9.x86_64.rpm

Once the installation is complete, you can check the version with the following command::

wkhtmltopdf --version

Output:

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

Step 7. Install and Configure Odoo 18 on AlmaLinux 9

We’re setting up an Odoo 18 instance using a dedicated system user account. To do this, let’s create a new system account named “odoo18” using the following command.

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

Next, access the “odoo18” user and clone Odoo 18 repository from GitHub:

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

Next, create a new python virtual environment to your Odoo 18 with the following command:

python3.12 -m venv odoo18-venv

Next, activate your virtual environment:

source odoo18-venv/bin/activate

Next install all required Python dependencies using the following command:

pip3 install wheel 
pip3 install -r odoo/requirements.txt

Now, you can deactivate the virtual environment and create a new directory to upload your custom Odoo add-ons:

deactivate
mkdir /opt/odoo18/custom-addons

Once Odoo installation is completed, exit from user ‘odoo18’ and create the Odoo log directory.

exit
mkdir /var/log/odoo18

Make sure to set permissions for your Odoo user:

chown -R odoo18: /var/log/odoo18/

Next, create an Odoo configuration file with the following command:

nano /etc/odoo18.conf

Copy and paste the following content into the Odoo configuration file:

[options]
admin_passwd = StrongPassword
db_host = False
db_port = False
db_user = odoo18
db_password = False
xmlrpc_port = 8069
logfile = /var/log/odoo18/odoo.log
addons_path = /opt/odoo18/odoo/addons,/opt/odoo18/custom-addons

Be sure to update the value of the “StrongPassword” key above with a more secure password. This is used as your Odoo master password, necessary for creating, deleting and restoring databases.

Step 8. Create Odoo Systemd Service File

Now that Odoo is installed and configured, to start, restart, or stop it, you need to create a Systemd service file. You can create it using the following command:

nano /etc/systemd/system/odoo18.service

Add the following lines:

[Unit]
Description=Odoo18
Requires=postgresql-17.service
After=network.target postgresql-17.service

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

[Install]
WantedBy=multi-user.target

Save and close the file then reload the systemd daemon to apply the changes:

systemctl daemon-reload

Next, initiate and enable the Odoo 18 service with the following command. This command will start Odoo 18 and configure it to launch automatically during boot.

systemctl start odoo18 && systemctl enable odoo18

Check if the Odoo 18 service is started correctly using the following command:

systemctl status odoo18

If the service started correctly its output should be similar to:

# systemctl status odoo18
● odoo18.service - Odoo18
     Loaded: loaded (/etc/systemd/system/odoo18.service; enabled; preset: disabled)
     Active: active (running) since Sat 2024-11-09 14:10:21 CST; 2s ago
   Main PID: 21474 (python3)
      Tasks: 1 (limit: 23191)
     Memory: 65.8M
        CPU: 1.939s
     CGroup: /system.slice/odoo18.service
             └─21474 /opt/odoo18/odoo18-venv/bin/python3 /opt/odoo18/odoo/odoo-bin -c /etc/odoo18.conf

You can access the Odoo backend using the URL http://YOUR_SERVER_IP:8069. You should see the following page:

Step 9. Configure Reverse Proxy

If you want to use a domain name instead of your server’s IP address, a web server is required. In this tutorial, we’ll install and use Nginx. Execute the following command to install nginx:

dnf install -y nginx

Next, create an Nginx server block:

nano /etc/nginx/conf.d/odoo18.conf

Add the following lines:

upstream odoo {
  server 127.0.0.1:8069;
}
upstream odoochat {
  server 127.0.0.1:8072;
}
map $http_upgrade $connection_upgrade {
  default upgrade;
  ''      close;
}

server {
  listen 80;
  server_name odoo.mydomain.com;
  proxy_read_timeout 720s;
  proxy_connect_timeout 720s;
  proxy_send_timeout 720s;

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

  location /websocket {
    proxy_pass http://odoochat;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection $connection_upgrade;
    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;
  }

  location / {
    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;
    proxy_redirect off;
    proxy_pass http://odoo;
  }

  gzip_types text/css text/scss text/plain text/xml application/xml application/json application/javascript;
  gzip on;
}

Be sure to update “odoo.mydomain.com” with your domain name.

Save and close the file then reload the nginx service to apply the changes:

systemctl reload nginx

You can now access Odoo using your domain name at http://odoo.mydomain.com and begin working on your project. For additional details about Odoo 18, its features, and configuration, refer to their official documentation.

Of course, you don’t have to install Odoo 18 on Alma Linux 9 if you use one of our Odoo VPS Hosting services, in which case you can simply ask our expert Linux admins to install and configure Odoo 18 on Alma Linux 9 for you. They are available 24×7 and will take care of your request immediately.

If you learned how to install Odoo 18 on AlmaLinux 9, please share this article with your friends or leave a comment below. Thanks

Leave a Comment