Streamlit turns a Python script into an interactive web application. This guide installs it in a project-specific virtual environment, builds a small app and checks both its output and a text-input interaction. The commands were tested with Streamlit 1.66.0 and Python 3.12 on Rocky Linux 9 in an isolated container.

Install Python and create the application

Use a normal account with sudo access. Run the following Bash commands from a directory where streamlit-lab does not already exist. Installing Python with dnf supplies the interpreter; pip installs Streamlit only inside .venv. The pinned version makes this example reproducible. Do not use sudo pip or replace the operating system’s Python.

sudo dnf install -y python3.12 python3.12-pip
mkdir streamlit-lab
cd streamlit-lab
python3.12 -m venv .venv
. .venv/bin/activate
python -m pip install 'streamlit==1.66.0'
python -m streamlit version
cat > app.py <<'PY'
import streamlit as st

st.title('Hello, Streamlit!')
st.write('This is a simple Streamlit application.')
name = st.text_input('Your name', 'World')
st.write(f'Hello, {name}!')
PY

Check the app before starting the server

Streamlit’s AppTest executes the script and lets us check an interaction. The assertions below verify the heading, enter Shapehost into the text box and check the resulting greeting. A successful run prints Streamlit render and input checks passed.

python - <<'PY'
from streamlit.testing.v1 import AppTest
app = AppTest.from_file('app.py').run()
assert not app.exception
assert app.title[0].value == 'Hello, Streamlit!'
app.text_input[0].set_value('Shapehost').run()
assert not app.exception
assert any(item.value == 'Hello, Shapehost!' for item in app.markdown)
print('Streamlit render and input checks passed')
PY

Run the application

From streamlit-lab with .venv active, run the following command. It stays in the foreground until you press Ctrl+C. The address option limits the listener to the local machine. On a remote VPS, use an SSH port-forwarding session to view it locally; opening port 8501 to the internet is not required.

python -m streamlit run app.py --server.address 127.0.0.1 --server.port 8501 --server.headless true --browser.gatherUsageStats false

Open http://127.0.0.1:8501 in your browser on the same machine, or through your SSH tunnel. Enter a name and check the greeting. Do not add st.run() or an extra __main__ launcher to app.py: the Streamlit command runs the script and manages reruns when inputs change. This foreground example does not configure automatic startup after logout or reboot.

Optional Apache HTTP proxy for a local lab

This optional example assumes a dedicated Rocky Linux 9 test machine and Apache 2.4.47 or newer. Keep Streamlit running in the first terminal. In a second terminal, install httpd and add the virtual host below. Replace streamlit.example.com with the hostname you intend to use. The example uses HTTP for local verification; configure HTTPS and access controls before exposing a real application.

sudo dnf install -y httpd
sudo tee /etc/httpd/conf.d/streamlit.conf > /dev/null <<'APACHE'
<VirtualHost *:80>
    ServerName streamlit.example.com
    ProxyRequests Off
    ProxyPreserveHost On
    ProxyPass / http://127.0.0.1:8501/ upgrade=websocket
    ProxyPassReverse / http://127.0.0.1:8501/
</VirtualHost>
APACHE
sudo httpd -M
sudo httpd -t
sudo httpd -k graceful

The module listing must include proxy_module and proxy_http_module. httpd -t must report Syntax OK before the graceful start/reload. upgrade=websocket allows the browser’s persistent Streamlit connection through the same proxy as HTTP. The backend remains on 127.0.0.1:8501. The httpd command starts or reloads this lab server; it does not enable a boot-time service.

Verify the page and its text input through the proxy hostname. In our isolated container test, the proxied page and /_stcore/health returned HTTP 200, and /_stcore/stream completed a WebSocket 101 upgrade. That container did not exercise SELinux enforcement, a host firewall, TLS issuance or boot-time service management. On a real Rocky Linux VPS, check SELinux policy and firewall access for the proxy, and configure persistent service supervision before relying on it for production. Do not disable SELinux or Streamlit’s request protections to work around a proxy error.

What Streamlit provides

Streamlit supplies interface elements for Python applications. You can display charts, collect inputs and present results from libraries such as pandas or a machine-learning framework. Training models, enforcing authorization and managing shared application state remain responsibilities of your application and its supporting libraries.

References: Streamlit installation, running a Streamlit app and Apache mod_proxy_http.