Using Official Repositories
Database setup
Install PostgreSQL
sudo apt update
sudo apt install postgresql postgresql-contribEnsure PostgreSQL starts now and on boot:
sudo systemctl start postgresql
sudo systemctl enable postgresqlCreate database and user, and set up the required permissions:
Replace credentials as needed. This example uses:
Username:
ocsuserPassword:
ocsuserDatabase Name:
ocsdb
sudo -u postgres psql <<EOF
-- Create user and database
CREATE USER ocsuser WITH PASSWORD 'ocsuser';
CREATE DATABASE ocsdb;
-- Grant basic connect permission
GRANT ALL PRIVILEGES ON DATABASE ocsdb TO ocsuser;
-- Connect to the database to set default privileges
\c ocsdb
-- Allow the application user to create objects in the public schema
GRANT USAGE, CREATE ON SCHEMA public TO ocsuser;
-- Set default privileges for future tables, sequences, and functions
ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT ALL ON TABLES TO ocsuser;
ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT ALL ON SEQUENCES TO ocsuser;
ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT ALL ON FUNCTIONS TO ocsuser;
EOFConfigure PostgreSQL for remote connections:
Update postgresql.conf to listen for remote connections.
Assuming PostgreSQL version 17, modify the listen_addresses setting:
sudo sed -i "s/#listen_addresses = 'localhost'/listen_addresses = '*'/" /etc/postgresql/17/main/postgresql.confAdd a client authentication rule. Allow remote connections for the ocsuser user and ocsdb database:
echo "host ocsdb ocsuser 0.0.0.0/0 scram-sha-256" | sudo tee -a /etc/postgresql/17/main/pg_hba.confRestart the PostgreSQL service to apply the configuration changes:
sudo systemctl restart postgresqlOCS Inventory Setup
Add the OCS Inventory repository
Add the OCS Inventory repository. This imports the GPG key used to sign OCS Inventory packages and registers the APT repository.
Replace <distribution_codename> with your system’s codename.
Supported codenames:
Debian:
bookworm,trixieUbuntu:
jammy,noble,plucky
curl -fsSL https://deb-v3.ocsinventory-ng.org/repo-signing-key.gpg | sudo gpg --dearmor -o /etc/apt/trusted.gpg.d/ocs-archive-keyring.gpg
echo "deb https://deb-v3.ocsinventory-ng.org/ <distribution_codename> main" | sudo tee /etc/apt/sources.list.d/ocsinventory.list
sudo apt updateThis installs:
/etc/apt/trusted.gpg.d/ocs-archive-keyring.gpg- the public GPG key used to verify package signatures/etc/apt/sources.list.d/ocsinventory.list- the repository definition
Install the packages
sudo apt install ocsinventory-serverThis pulls in both ocsinventory-backend and ocsinventory-frontend with matching versions.
On installation,
ocsinventory-backendcreates a dedicated system user used to run the uWSGI worker process and own the application files. It also generates a DjangoSECRET_KEYautomatically.
Configure the backend
Run the interactive configuration script. Set the database connection and frontend redirection URL. The script then applies database migrations.
sudo /usr/share/ocsinventory-backend/tools/configure-ocsinventory-backend.shYou will be prompted for:
The database engine: PostgreSQL or MySQL/MariaDB.
The database host, port, name, username, and password.
The frontend URL used for login redirection:
FRONTEND_REDIRECT.
The script installs the matching Python database driver and runs manage.py migrate.
The following example shows the database prompts:
dev@ocsbackend:/usr/share/ocsinventory-backend/tools$ sudo bash configure-ocsinventory-backend.sh
=================================================
= =
= OCS Inventory Backend configuration =
= =
=================================================
Select the database engine:
[1] PostgreSQL
[2] MySQL | MariaDB
Database engine [1|2]: 1
Database engine configured for PostgreSQL
Try to install PostgreSQL python library
Requirement already satisfied: psycopg2-binary>=2.9.9 in /usr/lib/ocsinventory-backend/venv/lib/python3.12/site-packages (from -r /usr/share/ocsinventory-backend/requirements_psql.txt (line 1)) (2.9.10)
Which host is running database server ?: 192.168.1.10
On which port is running database server ?: 5432
What is the database name ?: ocsdb
What is the database user name ?: ocsuser
What is the database user password ?: ocsuser
Configuration completed !
Now, running database migrations...
Database migrations successfully applied !
For more information, look at /tmp/ocsinventory-backend-configuration.log for the database migrations logs.
===========================================================
= =
= OCS Inventory Backend successfully configured =
= =
===========================================================
After successful configuration:
Database migrations will run automatically.
Logs for the database migrations can be found at
/tmp/ocsinventory-backend-configuration.log.
Configure domain names
By default, both vhosts use server_name _;. They answer any request, regardless of its Host header. Configure a distinct hostname for each component when they share a server.
Update server_name in each Nginx vhost. For example, use ocsinventory-backend.com for the API. Use ocsinventory-frontend.com for the web console.
sudo sed -i 's/server_name _;/server_name ocsinventory-backend.com;/' /etc/nginx/sites-available/ocsinventory-backend
sudo sed -i 's/server_name _;/server_name ocsinventory-frontend.com;/' /etc/nginx/sites-available/ocsinventory-frontend
sudo nginx -t
sudo systemctl restart nginxWhen both components share a node, two catch-all vhosts conflict. Assign each component a distinct hostname.
Ensure both domains resolve to this server's IP address. Use DNS or /etc/hosts.
If you configure a backend domain, update the frontend API route. Edit /usr/share/ocsinventory-frontend/config/config.json:
{
"BACKEND_API_ROUTE": "http://ocsinventory-backend.com:8081/"
}Services installed
nginx
Serves the frontend and reverse-proxies the backend.
80 (frontend), 8081 (backend)
ocsinventory-backend-uwsgi
Runs the Django backend through uWSGI.
Unix socket: /var/run/ocsinventory-backend/ocsinventory-backend.sock
Useful commands:
sudo systemctl status ocsinventory-backend-uwsgi
sudo journalctl -u ocsinventory-backend-uwsgi -n 50 --no-pager
sudo tail -n 50 /var/log/ocsinventory-backend/ocsinventory-backend.logVerify installation
To confirm the installation was successful:
Log into the web console and verify the interface loads correctly.
Connect an OCS agent to the server and verify data transmission.
Having trouble? Check our Troubleshooting section.
Add the OCS Inventory repository
The ocsinventory-release package configures the YUM/DNF repository and imports the GPG key used to sign OCS Inventory packages.
sudo dnf install -y https://rpm-v3.ocsinventory-ng.org/rpm/ocsinventory-release-latest.[elX|fcXX].noarch.rpmReplace
elXorfcXXwith the version matching your operating system, from those supported by OCS Inventory:
Enterprise Linux (RHEL, Rocky, AlmaLinux):
el9,el10Fedora:
fc42,fc43,fc44
This installs:
/etc/yum.repos.d/ocsinventory.repo- the repository definition/etc/pki/rpm-gpg/RPM-GPG-KEY-ocsinventory- the public GPG key, imported automatically on install
The key is not imported at this point. DNF imports it automatically the first time a package is actually installed from the ocsinventory repository (see step 2), prompting you to confirm the key fingerprint unless assumeyes is set.
Install the packages
sudo dnf install -y ocsinventory-serverThis pulls in both ocsinventory-backend and ocsinventory-frontend with matching versions.
On this first install from the ocsinventory repository, DNF prompts you to confirm and import the GPG key. Once accepted, you can verify it was imported with:
rpm -qa gpg-pubkey* --qf '%{name}-%{version}-%{release} --> %{summary}\n' | grep -i ocsinventoryOn installation,
ocsinventory-backendcreates a dedicated system userocsbackend(member of thenginxgroup) used to run the uWSGI worker process and own the application files, and generates a DjangoSECRET_KEYautomatically.
Configure the backend
Run the interactive configuration script to set the database connection and the frontend redirection URL, then apply database migrations:
sudo /usr/share/ocsinventory-backend/tools/configure-ocsinventory-rhel.shYou will be prompted for:
the database engine (PostgreSQL or MySQL/MariaDB)
the database host, port, name, username and password
the frontend URL used for login redirection (
FRONTEND_REDIRECT)
The script installs the matching Python database driver, runs manage.py migrate, and restarts ocsinventory-backend-uwsgi and nginx.
Configure domain names
By default both vhosts use server_name _;, meaning they answer any request regardless of the Host header. If you serve OCS Inventory under dedicated domains (e.g. ocsinventory-backend.com for the API and ocsinventory-frontend.com for the web console), update server_name in each vhost accordingly:
sudo sed -i 's/server_name _;/server_name ocsinventory-backend.com;/' /etc/nginx/conf.d/ocsinventory-backend.conf
sudo sed -i 's/server_name _;/server_name ocsinventory-frontend.com;/' /etc/nginx/conf.d/ocsinventory-frontend.conf
sudo nginx -t
sudo systemctl restart nginxNote : When both components share a single node, each package registers an Nginx server block with server_name _;. Having two catch-all blocks on port 80 creates a conflict. You must assign a distinct hostname to each component.
Make sure both domains resolve (DNS or /etc/hosts) to this server's IP.
If you set a dedicated domain for the backend, update the frontend so it calls the API on that domain instead of the server's bare IP. Edit /usr/share/ocsinventory-frontend/config/config.json:
{
"BACKEND_API_ROUTE": "http://ocsinventory-backend.com:8081/"
}Services installed
nginx
Serves the frontend and reverse-proxies the backend
80 (frontend), 8081 (backend)
ocsinventory-backend-uwsgi
Runs the Django backend via uWSGI
unix socket /var/run/ocsinventory-backend/ocsinventory-backend.sock
Useful commands:
sudo systemctl status ocsinventory-backend-uwsgi
sudo journalctl -u ocsinventory-backend-uwsgi -n 50 --no-pager
sudo tail -n 50 /var/log/ocsinventory-backend/ocsinventory-backend.logVerify installation
To confirm the installation was successful:
Log into the web console and verify the interface loads correctly.
Connect an OCS agent to the server and verify data transmission.
Having trouble? Check our Troubleshooting section.
Last updated

