Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,52 +2,127 @@
title: 1Panel Panel Deployment
---

## Install 1Panel Panel
This document provides a graphical tutorial for deploying New API using the 1Panel panel.

## Prerequisites

| Item | Requirement |
| --- | --- |
| 1Panel Panel | Latest stable version |
| Recommended OS | Linux (Ubuntu/CentOS/Debian, etc.) |
| Server Configuration | At least 1 core and 2GB RAM |

## Step 1: Install 1Panel Panel

<Callout type="info" title="Install 1Panel Panel">
- For information on 1Panel installation, deployment, and basic features,
please refer to the [1Panel Official Documentation](https://1panel.cn/docs/) -
After completing the 1Panel installation and deployment, open your browser to
the prompted URL to access the 1Panel panel.
For information on 1Panel installation, deployment, and basic features, please refer to the [1Panel Official Documentation](https://1panel.cn/docs/)

After completing the 1Panel installation and deployment, open your browser to the prompted URL to access the 1Panel panel.
</Callout>

![1panel](/assets/1panel/1panel.jpg)

## Install New API
## Step 2: Install New API

### Search for Applications

<Callout type="info" title="Search for Applications">
Go to the application list in the App Store, find the New API application
under the [AI] category, and install it.
Go to the application list in the App Store, find the New API application under the [AI] category, and install it.
</Callout>

![1panel-newapi](/assets/1panel/1panel-newapi.jpg)

### Configure Parameters

<Callout type="info" title="Install Application">
Configure New API application parameters on the installation page:
</Callout>

- Name: The name of the New API application to be created
- Version: Select the version of New API
- Port: The service port for the New API application
- Timezone: Enter the timezone where the server is located (default Asia/Shanghai)
- Advanced Settings: Be sure to check external port access
- **Name**: The name of the New API application to be created
- **Version**: Select the version of New API
- **Port**: The service port for the New API application
- **Timezone**: Enter the timezone where the server is located (default Asia/Shanghai)
- **Advanced Settings**: Be sure to check external port access

![newapi-setting](/assets/1panel/newapi-setting.jpg)

### Confirm Installation

<Callout type="info" title="Confirm Installation">
Click Confirm to start the installation. The page will automatically redirect
to the installed applications list. Wait for the New API application status to
change to Started.
Click Confirm to start the installation. The page will automatically redirect to the installed applications list. Wait for the New API application status to change to Started.
</Callout>

![newapi-start](/assets/1panel/newapi-start.jpg)

## Access New API
## Step 3: Configure Environment Variables (Important)

After installation, it is recommended to configure the following key environment variables:

### Required Environment Variables

| Variable | Description | Required |
| --- | --- | --- |
| `SESSION_SECRET` | Session secret, must be consistent for multi-node deployment | **Required** |
| `CRYPTO_SECRET` | Encryption secret, required when using Redis | Conditional |

### Configuration Method

1. In the 1Panel application list, click the **Parameters** button for the New API application
2. Add in the environment variables section:
- `SESSION_SECRET=your_random_secret_key`
- `CRYPTO_SECRET=your_crypto_secret_key` (optional)
3. Click **Confirm** to save the configuration
4. Restart the application for the configuration to take effect

### Generate Random Secrets

```bash
# Generate SESSION_SECRET
openssl rand -hex 16

# Or use Linux command
head -c 16 /dev/urandom | xxd -p
```

## Step 4: Access New API

<Callout type="info" title="Access Application">
- On the `Installed` page, click `Jump` to enter the New API WebUI page. -
Before use, it is recommended to set the `Default Access Address` on the
`Panel Settings` page.
- On the `Installed` page, click `Jump` to enter the New API WebUI page
- Before use, it is recommended to set the `Default Access Address` on the `Panel Settings` page
</Callout>

![newapi-visit](/assets/1panel/newapi-visit.jpg)

The first visit will automatically guide you to the initialization page. Follow the on-screen instructions to set up an administrator account and password.

## Common Issues

### Cannot access application interface

1. Check if the application status is "Started"
2. Confirm that the port is correctly mapped and open
3. Check the server firewall and cloud server security group

### Session invalid after login

Ensure the `SESSION_SECRET` environment variable is set and not empty.

### How to update version

1. Log in to 1Panel panel, go to **App Store** → **Upgradable page**
2. Find the New API application, click the **Upgrade** button
3. Select the target version, click **Confirm**

### How to persist data

1Panel applications store data in Docker volumes by default. To customize storage location:

1. In the application parameter settings, configure directory mapping
2. Ensure the `/data` directory is mapped to persistent storage

## Related Links

- [Environment Variables Configuration](/docs/installation/config-maintenance/environment-variables)
- [Docker Compose Deployment](/docs/installation/deployment-methods/docker-compose-installation)
- [FAQ](/docs/support/faq)
- [GitHub Repository](https://github.com/QuantumNous/new-api)
Original file line number Diff line number Diff line change
Expand Up @@ -6,78 +6,153 @@ This document provides a graphical tutorial for deploying New API using the Baot

## Prerequisites

- Install Baota Panel version 9.2.0 or higher
- Recommended OS: CentOS 7+, Ubuntu 18.04+, Debian 10+
- Server Configuration: At least 1 core and 2GB RAM
| Item | Requirement |
| --- | --- |
| Baota Panel | Version 9.2.0 or higher |
| Recommended OS | CentOS 7+, Ubuntu 18.04+, Debian 10+ |
| Server Configuration | At least 1 core and 2GB RAM |

## Install Baota Panel
## Step 1: Install Baota Panel

1. Go to the [Baota Panel Official Website](https://www.bt.cn/new/download.html) to download the installation script suitable for your system.
2. Run the installation script to install Baota Panel.
3. After installation, use the provided address, username, and password to log in to Baota Panel.
1. Go to the [Baota Panel Official Website](https://www.bt.cn/new/download.html) to download the installation script suitable for your system
2. Run the installation script to install Baota Panel
3. After installation, use the provided address, username, and password to log in to Baota Panel

## Install Docker
## Step 2: Install Docker

1. After logging in to Baota Panel, find and click **Docker** in the left sidebar.
2. The first time you enter, you will be prompted to install the Docker service. Click **Install Now**.
3. Follow the prompts to complete the Docker service installation.
1. After logging in to Baota Panel, find and click **Docker** in the left sidebar
2. The first time you enter, you will be prompted to install the Docker service. Click **Install Now**
3. Follow the prompts to complete the Docker service installation

## Install New API
## Step 3: Install New API

### Method One: Using Baota App Store (Recommended)

1. In the Baota Panel Docker feature, click **App Store**.
2. Search for and find **New-API**.
3. Click **Install**.
4. Configure the following basic options:
- Container Name: Customizable, defaults to `new-api`
- Port Mapping: Defaults to `3000:3000`
- Environment Variables: Add as needed (e.g., TZ=Asia/Shanghai)
- Directory Mapping: Ensure the `/data` directory is mapped to a host directory.
5. Click **Submit** to complete the installation.

### Method Two: Using a Custom Image

> It is strongly recommended to install via the "App Store" for automatic configuration. This section is for advanced users who have a clear understanding of Docker and Baota container configuration.

<Callout
type="warn"
title="I confirm that I want to manually set up the image and will resolve any issues myself."
>
Only refer to the following steps to manually configure a custom image after
you have checked and agreed to the above confirmation:
1. In the Baota Panel Docker feature, click **App Store**
2. Search for and find **New-API**
3. Click **Install**
4. Configure the following basic options:
- **Container Name**: Customizable, defaults to `new-api`
- **Port Mapping**: Defaults to `3000:3000`
- **Environment Variables**:
- `SESSION_SECRET`: Session secret (**Required**, must be consistent for multi-node deployment)
- `CRYPTO_SECRET`: Encryption secret (Required when using Redis)
- **Directory Mapping**: Ensure the `/data` directory is mapped to a host directory
5. Click **Confirm** to start installation
6. After installation completes, access `http://your-server-ip:3000`

### Method Two: Using Docker Compose

Suitable for scenarios requiring more custom configuration.

1. Create a website directory in Baota Panel, such as `/www/wwwroot/new-api`
2. Create a `docker-compose.yml` file:

```yaml
version: '3'
services:
new-api:
image: calciumion/new-api:latest
container_name: new-api
restart: always
ports:
- "3000:3000"
volumes:
- ./data:/data
environment:
- SESSION_SECRET=your_session_secret_here # Replace with random string
- TZ=Asia/Shanghai
```

3. Enter the directory via SSH terminal and start:

```bash
cd /www/wwwroot/new-api
docker-compose up -d
```

### Method Three: Using Custom Image

<Callout type="warn" title="Advanced Usage">
It is strongly recommended to install via "App Store". This section is for advanced users familiar with Docker.
</Callout>

1. In the Baota Panel Docker feature, click **Image Management**.
2. Click **Get Image** -> **Pull Image**.
3. Enter Image Name: `calciumion/new-api:latest`
4. Click **Submit** and wait for the image pull to complete.
5. After the pull is complete, go to **Container List** and click **Create Container**.
6. Fill in the following information:
- Container Name: `new-api` (customizable)
- Image: Select the `calciumion/new-api:latest` image you just pulled.
- Port Mapping: Add `3000:3000`
- Directory Mapping: Add `/your/host/path:/data` (replace with your host path)
- Environment Variables: Add as needed (e.g., TZ=Asia/Shanghai)
7. Click **Submit** to complete the installation.
1. In the Baota Panel Docker feature, click **Image Management**
2. Click **Get Image** **Pull Image**
3. Enter Image Name: `calciumion/new-api:latest`
4. Click **Submit** and wait for the image pull to complete
5. After the pull is complete, go to **Container List** and click **Create Container**
6. Fill in the following information:
- **Container Name**: `new-api` (customizable)
- **Image**: Select the `calciumion/new-api:latest` image you just pulled
- **Port Mapping**: Add `3000:3000`
- **Directory Mapping**: Add `/your/host/path:/data` (replace with your host path)
- **Environment Variables**: Add as needed
7. Click **Submit** to complete the installation

## Configuration and Access
## Environment Variables

After installation, you can access New API at the following address:
### Required Environment Variables

http://服务器IP:3000
| Variable | Description | Required |
| --- | --- | --- |
| `SESSION_SECRET` | Session secret, must be consistent for multi-node deployment | **Required** |
| `CRYPTO_SECRET` | Encryption secret, required when using Redis | Conditional |
| `SQL_DSN` | Database connection string (when using external database) | Optional |
| `REDIS_CONN_STRING` | Redis connection string | Optional |

The first visit will automatically guide you to the initialization page. Follow the on-screen instructions to set up an administrator account and password (only required for the first installation), then log in using the administrator account you set.
### Generate Random Secrets

```bash
# Generate SESSION_SECRET
openssl rand -hex 16

# Or use Linux command
head -c 16 /dev/urandom | xxd -p
```

## Access and Initialization

After installation, access `http://server-ip:3000`

The first visit will automatically guide you to the initialization page. Follow the on-screen instructions to set up an administrator account and password.

## Common Issues

### 1. Unable to access New API interface
### Cannot access port 3000

1. Check if the server firewall allows port 3000
2. In Baota Panel **Security**, allow port 3000
3. Check if the cloud server security group allows the port

### Session invalid after login

Ensure the `SESSION_SECRET` environment variable is set and not empty.

### How to persist data

Use Docker volume mapping for the data directory:

```yaml
volumes:
- ./data:/data
```

### How to update version

```bash
# Pull latest image
docker pull calciumion/new-api:latest

# Restart with Docker Compose
docker-compose down && docker-compose up -d

- Check if port mapping is correct.
- Confirm if the server firewall allows port 3000.
- Check if the container is running normally.
# Or restart container via Baota container management
```

### 2. Data cannot be persisted
## Related Links

- Confirm if the `/data` directory is correctly mapped.
- Check if host directory permissions are correct.
- [Environment Variables Configuration](/docs/installation/config-maintenance/environment-variables)
- [Docker Compose Deployment](/docs/installation/deployment-methods/docker-compose-installation)
- [FAQ](/docs/support/faq)
- [GitHub Repository](https://github.com/QuantumNous/new-api)
Loading