Managing UV Projects in the Web Panel

作者:小鱼的互联网观察 发布时间:November 10, 2025 分类:互联网观察

**Managing UV Projects in the Web Panel**


In modern Python project development, **uv** has become an extremely efficient and lightweight project management tool. It helps developers quickly create virtual environments, manage dependencies, and run Python applications. For users of the Baota Panel (BT Panel), integrating UV projects into the panel for management makes project operations and maintenance more convenient and ensures more stable background operation.


This article details how to use the **"Other Projects"** feature in the latest version of Baota Panel to manage UV projects.


**I. Preparations**


**Installing UV**


First, you need to install the `uv` tool on your server. If it's not already installed, you can use the following command:


```bash

curl -LsSf https://astral.sh/uv/install.sh | sh

```


After installation, you can verify successful installation by running:


```bash

uv --version

```


**Creating a UV Project**


Here's an example of creating a FastAPI project:


```bash

cd /www/wwwroot

uv init fastapi_app

cd fastapi_app

uv add fastapi uvicorn

```


This completes project creation, virtual environment initialization, and dependency installation.


**II. Adding a UV Project in Baota Panel**


In the latest version of Baota Panel, you can manage UV projects using the **"Other Projects"** feature under **"Websites"**. The specific steps are as follows:


1.  **Open Baota Panel**

    Navigate to the Baota Panel homepage. Find the **"Websites"** section in the left navigation bar, then locate and click on the **"Other Projects"** feature.


2.  **Add a New Project**

    Click the **"Add Other Project"** button. A form will pop up requiring the following information:


    *   **Project Name:** Choose a custom name for your project, e.g., `fastapi_app`.

    *   **Run Directory:** Enter the root directory of your UV project, for example:

        ```

        /www/wwwroot/fastapi_app

        ```

    *   **Program Start Command:** Enter the absolute path to `uv` along with the run command, for example:

        ```

        /root/.local/bin/uv run uvicorn main:app --host 0.0.0.0 --port 6677

        ```

        **Note:** To ensure the background process can correctly run `uv`, you must use the absolute path to `uv` and not rely on the `PATH` environment variable.

    *   **Run User:** Select `root` or another user on the server who has permission to access the project directory.

    *   **Log Paths:** You can set paths for output log files to facilitate debugging and monitoring, for example:

        *   Output Log: `/www/wwwlogs/fastapi_app.out.log`

        *   Error Log: `/www/wwwlogs/fastapi_app.err.log`


3.  **Save and Start**

    After filling out the form, click **Save**, then click **Start**. The Baota Panel will automatically launch your UV project using its built-in Supervisor.


**III. Background Management and Maintenance**


**Checking Status**

In the "Other Projects" list, you can view the operational status of your UV project, including:

*   Whether it is running

*   Start time

*   Log file locations


**Auto-restart**

Baota Panel uses Supervisor to manage processes. Therefore, the project will automatically restart if it exits abnormally, ensuring service stability.


**Updating Dependencies**

If you need to add new dependencies to your UV project, you can access the project directory via SSH or the Baota terminal:


```bash

cd /www/wwwroot/fastapi_app

uv add <package_name>

uv sync

```


Then restart the project through the Baota Panel for the new dependencies to take effect.


**IV. Important Notes**


*   **Absolute Path Required:** The `uv` command must be specified using its absolute path; otherwise, Baota cannot locate it in the background.

*   **Virtual Environment Dependencies:** UV creates and uses a `.venv` virtual environment. Ensure all project dependencies are installed within it.

*   **Python Version:** When creating the UV project, you can specify the Python version. Ensure it is compatible with your project code.

*   **Log Management:** It is recommended to set log paths under `/www/wwwlogs` for centralized management.


**V. Summary**


Using the **"Other Projects"** feature in Baota Panel allows for easy management of UV projects, enabling:


*   Stable background operation

*   Automatic restart

*   Centralized log management

*   No need to manually activate the virtual environment


This approach is suitable not only for FastAPI projects but also for other Python web frameworks like Django or Flask. By combining UV's dependency management with Baota's background operational capabilities, managing Python projects in a production environment becomes more convenient, secure, and efficient.


在web中管理 uv 项目

作者:小鱼的互联网观察 发布时间:November 10, 2025 分类:互联网观察

在现代 Python 项目开发中,uv 已经成为一个非常高效、轻量的项目管理工具,它可以帮助开发者快速创建、管理虚拟环境、安装依赖并运行 Python 应用。对于使用宝塔面板(BT 面板)的用户来说,将 uv 项目集成到面板中进行管理,可以让项目运维更便捷、后台运行更稳定。


本文将详细介绍在 宝塔面板最新版本中,如何使用 “其它项目”功能管理 uv 项目。


一、准备工作


安装 uv


首先需要在服务器上安装 uv 工具,如果尚未安装,可以通过以下命令安装:


curl -LsSf https://astral.sh/uv/install.sh | sh



安装完成后,可以通过:


uv --version



检查 uv 是否安装成功。


创建 uv 项目


以创建一个 FastAPI 项目为例:


cd /www/wwwroot

uv init fastapi_app

cd fastapi_app

uv add fastapi uvicorn



这样就完成了项目创建、虚拟环境初始化以及依赖安装。


二、在宝塔面板中添加 uv 项目


在宝塔面板的最新版本中,可以通过,网站, “其它项目” 功能来管理 uv 项目。具体步骤如下:


1. 打开宝塔面板


进入宝塔面板首页,在左侧导航找到网站, “其它项目” 功能,点击进入。


2. 添加新项目


点击 “添加其它项目” 按钮,会弹出一个表单,需要填写以下信息:


项目名称:自定义一个项目名称,如 fastapi_app


运行目录:填写 uv 项目的根目录,例如:


/www/wwwroot/fastapi_app



程序启动命令:填写 uv 的绝对路径以及运行命令,例如:


/root/.local/bin/uv run uvicorn main:app --host 0.0.0.0 --port 6677



注意:为了保证 后台能够正确运行 uv,必须使用 uv 的绝对路径,而不是依赖环境变量 PATH。


运行用户:可以选择 root 或服务器上其他有权限访问项目目录的用户。


日志路径:可以设置输出日志文件路径,便于调试和监控:


/www/wwwlogs/fastapi_app.out.log

/www/wwwlogs/fastapi_app.err.log


3. 保存并启动


填写完成后,点击 保存,然后点击 启动,宝塔面板就会通过内置的 Supervisor 自动启动 uv 项目。


三、后台管理与维护


查看状态


在“其它项目”列表中,可以查看 uv 项目的运行状态,包括:


是否正在运行


启动时间


日志文件位置


自动重启


宝塔面板使用 Supervisor 管理进程,因此项目会在异常退出时自动重启,确保服务稳定。


更新依赖


如果需要给 uv 项目添加新依赖,可以通过 SSH 或宝塔终端进入项目目录:


cd /www/wwwroot/fastapi_app

uv add <package_name>

uv sync



然后通过宝塔面板重启项目,使新依赖生效。


四、注意事项


绝对路径必填:uv 命令必须填写绝对路径,否则宝塔无法在后台找到 uv


虚拟环境依赖:使用 uv 创建的 .venv 虚拟环境,因此确保项目依赖已安装


Python 版本:在 uv 项目创建时,可以指定 Python 版本,确保与项目代码兼容


日志管理:建议将日志路径设置在 /www/wwwlogs,方便统一管理


五、总结


通过宝塔面板的 “其它项目” 功能,可以轻松管理 uv 项目,实现:


后台稳定运行


自动重启


日志集中管理


无需手动激活虚拟环境


这种方式不仅适合 FastAPI 项目,也适用于其他 Python web 框架,如 Django 或 Flask。结合 uv 的依赖管理和宝塔的后台运维功能,Python 项目在生产环境中管理起来更加便捷、安全、高效。


  1. 页码:
网站地图 京ICP证030173号