Installing Inventree on Ubuntu Server
Inventree is an open-source inventory management system that you can install on your Ubuntu Server to keep track of your inventory. This tutorial will guide you through the steps to install Inventree on Ubuntu Server.
Prerequisites
Before installing Inventree, you should have the following:
- Ubuntu Server installed and running
- Root privileges or access to a user with sudo privileges
- Internet connectivity
Step 1: Install the required dependencies
Before you can install Inventree on your Ubuntu Server, you need to install its dependencies. You can do this using the following command:
sudo apt-get update
sudo apt-get install python3 python3-pip python3-dev libpq-dev nginx curl
Step 2: Install virtualenv
Virtualenv is a tool that creates isolated Python environments. You can use it to install Inventree and its dependencies in a separate environment. You can install it using the following command:
sudo pip3 install virtualenv
Step 3: Create a virtual environment
Now that you have installed virtualenv, navigate to the directory where you want to install Inventree and create a virtual environment using the following command:
cd /opt
sudo mkdir inventree
sudo chown -R $USER:$USER inventree
cd inventree
virtualenv env
source env/bin/activate
This will create a new virtual environment and activate it.
Step 4: Install Inventree
Now that you have created a virtual environment, install Inventree using the following command:
pip3 install inventree
Step 5: Configure Inventree
Inventree comes with a default configuration file, which you can modify to suit your needs. To create a configuration file, navigate to the virtual environment's bin directory using the following command:
cd env/bin
Now, create a new file called inventree_config.py using the following command:
sudo nano inventree_config.py
This will open the Nano text editor. You can add your configuration options to this file. Here is an example configuration:
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql',
'NAME': 'inventree',
'USER': 'inventreeuser',
'PASSWORD': 'inventreepassword',
'HOST': 'localhost',
'PORT': '5432',
}
}
This configuration tells Inventree to use PostgreSQL as its database backend, and the database name is inventree. You may also need to modify the database username and password to suit your needs. Save and exit the file.
Step 6: Migrate the database
Now that you have configured Inventree, you can migrate the database using the following command:
cd /opt/inventree
python3 manage.py migrate
Step 7: Create a superuser
Now, create a superuser using the following command:
python3 manage.py createsuperuser
This will create a new user that you can use to log in to Inventree.
Step 8: Configure Nginx
Inventree comes with a sample Nginx configuration file. You can use this as a starting point for your own configuration. Navigate to the Nginx configuration directory using the following command:
cd /etc/nginx/sites-available
Now, create a new configuration file using the following command:
sudo nano inventree
This will open the Nano text editor. Add the following configuration:
server {
listen 80;
server_name your-domain.com;
location / {
proxy_pass http://127.0.0.1:8000;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
}
location /static/ {
alias /opt/inventree/staticfiles/;
}
}
Make sure to replace your-domain.com with your actual domain name. Save and exit the file.
Now, create a symbolic link from the sites-available directory to the sites-enabled directory using the following command:
sudo ln -s /etc/nginx/sites-available/inventree /etc/nginx/sites-enabled/
Finally, restart Nginx using the following command:
sudo systemctl restart nginx
Step 9: Run Inventree
Now that you have installed and configured Inventree, you can run it using the following command:
cd /opt/inventree
source env/bin/activate
python3 manage.py runserver
You can now access Inventree by visiting http://your-domain.com in your web browser.
Conclusion
Inventree is a powerful open-source inventory management system that you can install on your Ubuntu Server to keep track of your inventory. By following this tutorial, you should now have Inventree installed and running on your Ubuntu Server.