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.
相关文章
- 无相关文章
- 版权声明:自由转载-非商用-非衍生-保持署名 | Creative Commons BY-NC-ND 3.0
- 原文网址:https://tianmeng.org/archives/527/
- 最后修改时间:2025年11月10日 23:11:01
当前暂无评论 »