Skip to content

Documentation suggestion for Open-webUI using Python (conda) and Ollama #459

Open
@LucIJspeert

Description

@LucIJspeert

This is a little guide I wrote to make it simpler to start Ollama+Open-webUI in the case that Open-webUI is installed in a conda environment. My suggestion is that this could be added to the documentation docs/getting-started/quick-start/starting-with-ollama, or to the tutorial section. While it works for me now, it can be that I missed something while writing it down.

One-click solution to start Ollama and Open-webUI

These instructions explain how to make a script and desktop entry in linux that will make it easy to start the Ollama service and the Open-webUI service as well as automatically open the browser at the right local address.

Start by making a separate shell script for stopping the Ollama service (this resolves an issue where Ollama will not start because the address it is trying to bind to is already in use - by itself). Call this file stop_ollama.sh and put the following into it:

#!/bin/bash
systemctl stop ollama

Now save this script in some directory of your choosing, for example /home/usr/ollama-open-webui/stop_ollama.sh. Replace usr by your username in these paths. This file needs to be made executable:

sudo chmod +x /home/usr/ollama-open-webui/stop_ollama.sh

It also needs to be given the right privileges so that we don't need to type our password every time:

sudo visudo

Add a line at the bottom:

yourusername ALL=(ALL) NOPASSWD: /home/usr/ollama-open-webui/stop_ollama.sh

This will prompt you for your password once. Next, we make the main script that starts the services and opens a browser (tab) in the default program. Call it something like start_services.sh and put it in the same folder as the previous script.

#!/usr/bin/env bash
######################################################
#  A little script to start up ollama and open-webui #
######################################################

# Stop ollama because of reasons...
sudo /home/usr/ollama-open-webui/stop_ollama.sh

# Start ollama in a new tab as an interactive bash shell
gnome-terminal --tab --title="Ollama" -- bash -i -c "
    ollama serve;
    exec bash
"

# Start open-webui in another new tab as an interactive bash shell
gnome-terminal --tab --title="Open-WebUI" -- bash -i -c "
    conda activate openwebui;
    open-webui serve;
    exec bash
"

# Open browser tab with the right address
gnome-terminal --tab --title="Browser" -- bash -i -c "
    sleep 5;
    xdg-open http://localhost:8080/;
    exec bash
"

It uses the first script to stop the Ollama service, then opens another terminal tab to start the Ollama service there. This assumes you are using a system with a gnome-terminal (I'm sure you'll be able to adapt it if this is not the case). It opens another tab to start the Open-webUI service: it is important that this is an interactive bash shell, as otherwise the right things (./bashrc, conda) will not be initialised. If you installed Open-webUI in another environment than with conda, edit the environment activation line in the script. The commands exec bash make sure the tabs don't automatically close after execution, so that any error messages can be seen. Lastly it opens another tab that waits 5 seconds for the services to start and then opens a browser tab to go to the localhost address for Open-webUI. This script has to be made executable, too.

sudo chmod +x /home/usr/ollama-open-webui/start_services.sh

We're almost there, we just need to make a desktop entry to make this truly a one-click solution. Make a file called start_ollama_webui.desktop or similar and save it in the folder /home/usr/.local/share/applications with the following content:

[Desktop Entry]
Name=Ollama+Open-webUI
Comment=Start Ollama and Open-WebUI
Exec=/home/usr/ollama-open-webui/start_services.sh
Icon=utilities-terminal
Terminal=true
Type=Application
Categories=Development;

You should now be able to find this entry (by searching for 'ollama') in the 'start' menu and run the whole setup with one click! Optionally, download an Ollama icon and add the path /home/usr/ollama-open-webui/ollama_icon.png to the line Icon=. Using Categories=Development makes sure you can also find the entry in the 'Programming' category of the menu. You can add it to your panel or desktop if desired.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions