diff --git a/content/docs/en/installation/deployment-methods/1panel-installation.mdx b/content/docs/en/installation/deployment-methods/1panel-installation.mdx index f45c98de..1b930f9a 100644 --- a/content/docs/en/installation/deployment-methods/1panel-installation.mdx +++ b/content/docs/en/installation/deployment-methods/1panel-installation.mdx @@ -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 - - 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. ![1panel](/assets/1panel/1panel.jpg) -## Install New API +## Step 2: Install New API + +### 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. ![1panel-newapi](/assets/1panel/1panel-newapi.jpg) +### Configure Parameters + Configure New API application parameters on the installation page: - - 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 + - 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. ![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 - - 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 ![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) \ No newline at end of file diff --git a/content/docs/en/installation/deployment-methods/bt-docker-installation.mdx b/content/docs/en/installation/deployment-methods/bt-docker-installation.mdx index dadd53b8..2b1bd0de 100644 --- a/content/docs/en/installation/deployment-methods/bt-docker-installation.mdx +++ b/content/docs/en/installation/deployment-methods/bt-docker-installation.mdx @@ -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. - - - 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 + + + It is strongly recommended to install via "App Store". This section is for advanced users familiar with Docker. - 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) \ No newline at end of file diff --git a/content/docs/ja/installation/deployment-methods/1panel-installation.mdx b/content/docs/ja/installation/deployment-methods/1panel-installation.mdx index 3214248b..d5e7cbba 100644 --- a/content/docs/ja/installation/deployment-methods/1panel-installation.mdx +++ b/content/docs/ja/installation/deployment-methods/1panel-installation.mdx @@ -1,52 +1,128 @@ ---- +--- title: 1Panel パネルのデプロイ --- -## 1Panel パネルのインストール +このドキュメントでは、1Panel パネルを使用して New API をデプロイするための図解チュートリアルを提供します。 + +## 前提条件 + +| 項目 | 要件 | +| --- | --- | +| 1Panel パネル | 最新安定版 | +| 推奨システム | Linux (Ubuntu/CentOS/Debian など) | +| サーバー構成 | 最低1コア2GBメモリ | + +## ステップ1:1Panel パネルのインストール - - 1Panel のインストール、デプロイ、および基本機能の紹介については、[1Panel - 公式ドキュメント](https://1panel.cn/docs/)をご参照ください。 - 1Panel - のインストールとデプロイが完了したら、表示されたURLでブラウザを開き、1Panel - パネルにアクセスします。 + 1Panel のインストール、デプロイ、および基本機能の紹介については、[1Panel 公式ドキュメント](https://1panel.cn/docs/)をご参照ください。 + + 1Panel のインストールとデプロイが完了したら、表示されたURLでブラウザを開き、1Panel パネルにアクセスします。 ![1panel](/assets/1panel/1panel.jpg) -## New API のインストール +## ステップ2:New API のインストール + +### アプリケーションの検索 - アプリケーションストアのアプリケーションリストに入り、【AI】カテゴリで New API - アプリケーションを見つけてインストールします。 + アプリケーションストアのアプリケーションリストに入り、【AI】カテゴリで New API アプリケーションを見つけてインストールします。 ![1panel-newapi](/assets/1panel/1panel-newapi.jpg) +### パラメータの設定 + インストールページで New API アプリケーションのパラメータを設定します。 - - 名前:作成する New API アプリケーションの名前 - - バージョン:New API のバージョンを選択します - - ポート:New API アプリケーションのサービスポート - - タイムゾーン:サーバーのタイムゾーンを入力します(デフォルト Asia/Shanghai) - - 詳細設定:ポートの外部アクセスを必ずチェックしてください +- **名前**:作成する New API アプリケーションの名前 +- **バージョン**:New API のバージョンを選択します +- **ポート**:New API アプリケーションのサービスポート +- **タイムゾーン**:サーバーのタイムゾーンを入力します(デフォルト Asia/Shanghai) +- **詳細設定**:ポートの外部アクセスを必ずチェックしてください ![newapi-setting](/assets/1panel/newapi-setting.jpg) +### インストールの確認 + - 「確認」をクリックしてインストールを開始すると、ページは自動的にインストール済みアプリケーションリストにリダイレクトされ、New - API アプリケーションの状態が「起動済み」になるまで待ちます。 + 「確認」をクリックしてインストールを開始すると、ページは自動的にインストール済みアプリケーションリストにリダイレクトされ、New API アプリケーションの状態が「起動済み」になるまで待ちます。 ![newapi-start](/assets/1panel/newapi-start.jpg) -## New API へのアクセス +## ステップ3:環境変数の設定(重要) + +インストール完了後、以下の重要な環境変数を設定することをお勧めします: + +### 必須環境変数 + +| 変数 | 説明 | 必須 | +| --- | --- | --- | +| `SESSION_SECRET` | セッションシークレット、マルチノードデプロイ時は統一必須 | **必須** | +| `CRYPTO_SECRET` | 暗号化シークレット、Redis使用時に必須 | 条件付き必須 | + +### 設定方法 + +1. 1Panel アプリケーションリストで、New API アプリケーションの **パラメータ** ボタンをクリックします +2. 環境変数セクションに追加します: + - `SESSION_SECRET=your_random_secret_key` + - `CRYPTO_SECRET=your_crypto_secret_key`(オプション) +3. **確認** をクリックして設定を保存します +4. 設定を反映させるためにアプリケーションを再起動します + +### ランダムシークレットの生成 + +```bash +# SESSION_SECRETの生成 +openssl rand -hex 16 + +# またはLinuxコマンドを使用 +head -c 16 /dev/urandom | xxd -p +``` + +## ステップ4:New API へのアクセス - - 「インストール済み」ページで、「ジャンプ」をクリックすると New API の WebUI - ページに入ることができます。 - - 使用前に、「パネル設定」ページで「デフォルトアクセスアドレス」を設定することをお勧めします。 + - 「インストール済み」ページで、「ジャンプ」をクリックすると New API の WebUI ページに入ることができます + - 使用前に、「パネル設定」ページで「デフォルトアクセスアドレス」を設定することをお勧めします ![newapi-visit](/assets/1panel/newapi-visit.jpg) + +初回アクセス時に初期化ページが自動的に表示されます。画面の指示に従って管理者アカウントとパスワードを設定します。 + +## よくある問題 + +### アプリケーション画面にアクセスできない + +1. アプリケーションの状態が「起動済み」か確認 +2. ポートが正しくマッピングされ、開放されているか確認 +3. サーバーのファイアウォールとクラウドサーバーのセキュリティグループを確認 + +### ログイン後にセッションが無効になる + +`SESSION_SECRET`環境変数が設定され、空でないことを確認してください。 + +### バージョンを更新する方法 + +1. 1Panel パネルにログインし、**アプリストア** → **アップグレード可能** ページに移動 +2. New API アプリケーションを見つけ、**アップグレード** ボタンをクリック +3. ターゲットバージョンを選択し、**確認** をクリック + +### データを永続化する方法 + +1Panel アプリケーションはデフォルトで Docker ボリュームにデータを保存します。ストレージ場所をカスタマイズする場合: + +1. アプリケーションパラメータ設定で、ディレクトリマッピングを設定 +2. `/data` ディレクトリが永続ストレージにマッピングされていることを確認 + +## 関連リンク + +- [環境変数設定](/docs/installation/config-maintenance/environment-variables) +- [Docker Composeデプロイ](/docs/installation/deployment-methods/docker-compose-installation) +- [FAQ](/docs/support/faq) +- [GitHubリポジトリ](https://github.com/QuantumNous/new-api) \ No newline at end of file diff --git a/content/docs/ja/installation/deployment-methods/bt-docker-installation.mdx b/content/docs/ja/installation/deployment-methods/bt-docker-installation.mdx index dcdcd1cb..e04f37c5 100644 --- a/content/docs/ja/installation/deployment-methods/bt-docker-installation.mdx +++ b/content/docs/ja/installation/deployment-methods/bt-docker-installation.mdx @@ -6,77 +6,153 @@ title: 宝塔パネルへのデプロイ ## 前提条件 -- 宝塔パネル 9.2.0 以降のバージョンがインストールされていること -- 推奨システム:CentOS 7+、Ubuntu 18.04+、Debian 10+ -- サーバー構成:最低1コア2GBメモリ +| 項目 | 要件 | +| --- | --- | +| 宝塔パネル | バージョン9.2.0以上 | +| 推奨システム | CentOS 7+、Ubuntu 18.04+、Debian 10+ | +| サーバー構成 | 最低1コア2GBメモリ | -## 宝塔パネルのインストール +## ステップ1:宝塔パネルのインストール -1. [宝塔パネル公式サイト](https://www.bt.cn/new/download.html)にアクセスし、お使いのシステムに適したインストールスクリプトをダウンロードします。 -2. インストールスクリプトを実行して宝塔パネルをインストールします。 -3. インストール完了後、提供されたアドレス、ユーザー名、パスワードを使用して宝塔パネルにログインします。 +1. [宝塔パネル公式サイト](https://www.bt.cn/new/download.html)にアクセスし、お使いのシステムに適したインストールスクリプトをダウンロードします +2. インストールスクリプトを実行して宝塔パネルをインストールします +3. インストール完了後、提供されたアドレス、ユーザー名、パスワードを使用して宝塔パネルにログインします -## Dockerのインストール +## ステップ2:Dockerのインストール -1. 宝塔パネルにログイン後、左側のメニューバーで **Docker** を見つけてクリックします。 -2. 初めてアクセスするとDockerサービスのインストールを促されるので、**今すぐインストール** をクリックします。 -3. プロンプトに従ってDockerサービスのインストールを完了します。 +1. 宝塔パネルにログイン後、左側のメニューバーで **Docker** を見つけてクリックします +2. 初めてアクセスするとDockerサービスのインストールを促されるので、**今すぐインストール** をクリックします +3. プロンプトに従ってDockerサービスのインストールを完了します -## New APIのインストール +## ステップ3:New APIのインストール ### 方法一:宝塔アプリストアを使用(推奨) -1. 宝塔パネルのDocker機能で、**アプリストア** をクリックします。 -2. **New-API** を検索して見つけます。 -3. **インストール** をクリックします。 -4. 以下の基本オプションを設定します。 - - コンテナ名:カスタマイズ可能、デフォルトは`new-api` - - ポートマッピング:デフォルトは`3000:3000` - - 環境変数:必要に応じて追加(例:TZ=Asia/Shanghaiなど) - - ディレクトリマッピング:`/data`ディレクトリがホストディレクトリにマッピングされていることを確認します。 -5. **送信** をクリックしてインストールを完了します。 - -### 方法二:カスタムイメージを使用 - -> 「アプリストア」を通じてインストールし、自動設定を完了することを強くお勧めします。このセクションは、Dockerと宝塔コンテナの設定を明確に理解しているユーザー向けの高度な使用法です。 - - - 上記の確認にチェックを入れ、同意した場合にのみ、以下の手順を参照してカスタムイメージを手動で設定してください。 +1. 宝塔パネルのDocker機能で、**アプリストア** をクリックします +2. **New-API** を検索して見つけます +3. **インストール** をクリックします +4. 以下の基本オプションを設定します: + - **コンテナ名**:カスタマイズ可能、デフォルトは `new-api` + - **ポートマッピング**:デフォルトは `3000:3000` + - **環境変数**: + - `SESSION_SECRET`:セッションシークレット(**必須**、マルチノードデプロイ時は統一必須) + - `CRYPTO_SECRET`:暗号化シークレット(Redis使用時に必須) + - **ディレクトリマッピング**:`/data`ディレクトリをホストディレクトリにマッピング +5. **確認** をクリックしてインストールを開始します +6. インストール完了後、`http://サーバーIP:3000` にアクセスします + +### 方法二:Docker Composeを使用 + +より多くのカスタム設定が必要なシナリオに適しています。 + +1. 宝塔パネルでウェブサイトディレクトリを作成します(例:`/www/wwwroot/new-api`) +2. `docker-compose.yml`ファイルを作成します: + +```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 # ランダム文字列に変更してください + - TZ=Asia/Shanghai +``` + +3. SSHターミナルでディレクトリに移動し、起動します: + +```bash +cd /www/wwwroot/new-api +docker-compose up -d +``` + +### 方法三:カスタムイメージを使用 + + + 「アプリストア」からのインストールを強くお勧めします。このセクションはDockerに精通した上級者向けです。 - 1. 宝塔パネルのDocker機能で、**イメージ管理** をクリックします。 - 2. **イメージ取得** -> **イメージをプル** をクリックします。 - 3. イメージ名を入力:`calciumion/new-api:latest` - 4. **送信** をクリックし、イメージのプルが完了するのを待ちます。 - 5. プルが完了したら、**コンテナリスト** に移動し、**コンテナ作成** をクリックします。 - 6. 以下の情報を入力します。 - - コンテナ名:`new-api`(カスタマイズ可能) - - イメージ:プルしたばかりの`calciumion/new-api:latest`を選択 - - ポートマッピング:`3000:3000`を追加 - - ディレクトリマッピング:`/your/host/path:/data`を追加(ホストパスに置き換えてください) - - 環境変数:必要に応じて追加(例:TZ=Asia/Shanghaiなど) - 7. **送信** をクリックしてインストールを完了します。 +1. 宝塔パネルのDocker機能で、**イメージ管理** をクリックします +2. **イメージ取得** → **イメージプル** をクリックします +3. イメージ名を入力:`calciumion/new-api:latest` +4. **送信** をクリックし、イメージのプルが完了するまで待ちます +5. プル完了後、**コンテナリスト** に入り、**コンテナ作成** をクリックします +6. 以下の情報を入力します: + - **コンテナ名**:`new-api`(カスタマイズ可能) + - **イメージ**:プルした `calciumion/new-api:latest` を選択 + - **ポートマッピング**:`3000:3000` を追加 + - **ディレクトリマッピング**:`/your/host/path:/data` を追加(ホストパスに置き換え) + - **環境変数**:必要に応じて追加 +7. **送信** をクリックしてインストールを完了します -## 設定とアクセス +## 環境変数の設定 -インストール完了後、以下のURLでNew APIにアクセスできます。 +### 必須環境変数 - http://サーバーIP:3000 +| 変数 | 説明 | 必須 | +| --- | --- | --- | +| `SESSION_SECRET` | セッションシークレット、マルチノードデプロイ時は統一必須 | **必須** | +| `CRYPTO_SECRET` | 暗号化シークレット、Redis使用時に必須 | 条件付き必須 | +| `SQL_DSN` | データベース接続文字列(外部DB使用時) | オプション | +| `REDIS_CONN_STRING` | Redis接続文字列 | オプション | -初回アクセス時には自動的に初期化ページに誘導されます。ページの手順に従って管理者アカウントとパスワードを設定し(初回インストール時のみ必要)、設定した管理者アカウントでログインします。 +### ランダムシークレットの生成 -## よくある質問 +```bash +# SESSION_SECRETの生成 +openssl rand -hex 16 -### 1. New APIインターフェースにアクセスできない +# またはLinuxコマンドを使用 +head -c 16 /dev/urandom | xxd -p +``` -- ポートマッピングが正しいか確認します -- サーバーのファイアウォールで3000番ポートが許可されているか確認します -- コンテナが正常に動作しているか確認します +## アクセスと初期化 -### 2. データが永続化されない +インストール完了後、`http://サーバーIP:3000` にアクセスします -- `/data`ディレクトリが正しくマッピングされているか確認します -- ホストディレクトリの権限が正しいか確認します +初回アクセス時に初期化ページが自動的に表示されます。画面の指示に従って管理者アカウントとパスワードを設定します。 + +## よくある問題 + +### 3000ポートにアクセスできない + +1. サーバーのファイアウォールが3000ポートを許可しているか確認 +2. 宝塔パネルの**セキュリティ**で3000ポートを開放 +3. クラウドサーバーのセキュリティグループがポートを開放しているか確認 + +### ログイン後にセッションが無効になる + +`SESSION_SECRET`環境変数が設定され、空でないことを確認してください。 + +### データを永続化する方法 + +Dockerボリュームマッピングを使用してデータディレクトリを永続化します: + +```yaml +volumes: + - ./data:/data +``` + +### バージョンを更新する方法 + +```bash +# 最新イメージをプル +docker pull calciumion/new-api:latest + +# Docker Composeで再起動 +docker-compose down && docker-compose up -d + +# または宝塔コンテナ管理でコンテナを再起動 +``` + +## 関連リンク + +- [環境変数設定](/docs/installation/config-maintenance/environment-variables) +- [Docker Composeデプロイ](/docs/installation/deployment-methods/docker-compose-installation) +- [FAQ](/docs/support/faq) +- [GitHubリポジトリ](https://github.com/QuantumNous/new-api) \ No newline at end of file diff --git a/content/docs/zh/installation/deployment-methods/1panel-installation.mdx b/content/docs/zh/installation/deployment-methods/1panel-installation.mdx index 822984eb..4aded649 100644 --- a/content/docs/zh/installation/deployment-methods/1panel-installation.mdx +++ b/content/docs/zh/installation/deployment-methods/1panel-installation.mdx @@ -1,18 +1,30 @@ ---- +--- title: 1Panel 面板部署 --- -## 安装 1Panel 面板 +本文档提供使用 1Panel 面板部署 New API 的图文教程。 + +## 前置要求 + +| 项目 | 要求 | +| --- | --- | +| 1Panel 面板 | 最新稳定版 | +| 推荐系统 | Linux (Ubuntu/CentOS/Debian 等) | +| 服务器配置 | 至少 1 核 2G 内存 | + +## 步骤一:安装 1Panel 面板 - - 关于 1Panel 的安装部署与基础功能介绍,请参考 [1Panel - 官方文档](https://1panel.cn/docs/) - 在完成了 1Panel - 的安装部署后,根据提示网址打开浏览器进入 1Panel 面板 + 关于 1Panel 的安装部署与基础功能介绍,请参考 [1Panel 官方文档](https://1panel.cn/docs/) + + 在完成了 1Panel 的安装部署后,根据提示网址打开浏览器进入 1Panel 面板 ![1panel](/assets/1panel/1panel.jpg) -## 安装 New API +## 步骤二:安装 New API + +### 搜索应用 进入应用商店应用列表,在【AI】分类下找到 New API 应用进行安装 @@ -20,30 +32,97 @@ title: 1Panel 面板部署 ![1panel-newapi](/assets/1panel/1panel-newapi.jpg) +### 配置参数 + 在安装页面配置 New API 应用参数: - - 名称:要创建的 New API 应用的名称 - - 版本:选择 New API 的版本 - - 端口:New API 应用的服务端口 - - 时区:输入服务器所在时区(默认 Asia/Shanghai) - - 高级设置:务必勾选端口外部访问 +- **名称**:要创建的 New API 应用的名称 +- **版本**:选择 New API 的版本 +- **端口**:New API 应用的服务端口 +- **时区**:输入服务器所在时区(默认 Asia/Shanghai) +- **高级设置**:务必勾选端口外部访问 ![newapi-setting](/assets/1panel/newapi-setting.jpg) +### 确认安装 + - 点击确认开始安装,页面自将动跳转到已安装应用列表,等待 New API - 应用状态变为已启动 + 点击确认开始安装,页面将自动跳转到已安装应用列表,等待 New API 应用状态变为已启动 ![newapi-start](/assets/1panel/newapi-start.jpg) -## 访问 New API +## 步骤三:配置环境变量(重要) + +安装完成后,建议配置以下关键环境变量: + +### 必要环境变量 + +| 变量名 | 说明 | 是否必填 | +| --- | --- | --- | +| `SESSION_SECRET` | 会话密钥,多机部署必须一致 | **必填** | +| `CRYPTO_SECRET` | 加密密钥,使用 Redis 时必填 | 条件必填 | + +### 配置方法 + +1. 在 1Panel 应用列表中,点击 New API 应用的 **参数** 按钮 +2. 在环境变量区域添加: + - `SESSION_SECRET=your_random_secret_key` + - `CRYPTO_SECRET=your_crypto_secret_key`(可选) +3. 点击 **确认** 保存配置 +4. 重启应用使配置生效 + +### 生成随机密钥 + +```bash +# 生成 SESSION_SECRET +openssl rand -hex 16 + +# 或使用 Linux 命令 +head -c 16 /dev/urandom | xxd -p +``` + +## 步骤四:访问 New API - - 在 `已安装` 页面,点击 `跳转` 即可进入 New API 的 WebUI 页面 - 使用前建议在 - `面板设置` 页面设置好 `默认访问地址` + - 在 `已安装` 页面,点击 `跳转` 即可进入 New API 的 WebUI 页面 + - 使用前建议在 `面板设置` 页面设置好 `默认访问地址` ![newapi-visit](/assets/1panel/newapi-visit.jpg) + +首次访问将自动引导到初始化页面,按照页面指引设置管理员账号与密码。 + +## 常见问题 + +### 无法访问应用界面 + +1. 检查应用状态是否为"已启动" +2. 确认端口是否正确映射并开放 +3. 检查服务器防火墙和云服务器安全组 + +### 登录后提示会话失效 + +确保设置了 `SESSION_SECRET` 环境变量,且值不为空。 + +### 如何更新版本 + +1. 登录 1Panel 面板,进入 **应用商店** → **可升级页面** +2. 找到 New API 应用,点击 **升级** 按钮 +3. 选择目标版本,点击 **确认** + +### 数据如何持久化 + +1Panel 应用默认会将数据存储在 Docker 卷中。如需自定义存储位置: + +1. 在应用参数设置中,配置目录映射 +2. 确保 `/data` 目录映射到持久化存储 + +## 相关链接 + +- [环境变量配置](/docs/installation/config-maintenance/environment-variables) +- [Docker Compose 部署](/docs/installation/deployment-methods/docker-compose-installation) +- [常见问题](/docs/support/faq) +- [GitHub 仓库](https://github.com/QuantumNous/new-api) \ No newline at end of file diff --git a/content/docs/zh/installation/deployment-methods/bt-docker-installation.mdx b/content/docs/zh/installation/deployment-methods/bt-docker-installation.mdx index b3f1bc99..dadfcae3 100644 --- a/content/docs/zh/installation/deployment-methods/bt-docker-installation.mdx +++ b/content/docs/zh/installation/deployment-methods/bt-docker-installation.mdx @@ -1,79 +1,158 @@ ---- +--- title: 宝塔面板部署 --- -本文档提供了使用宝塔面板Docker功能部署New API的图文教程。 +本文档提供使用宝塔面板 Docker 功能部署 New API 的图文教程。 ## 前置要求 -- 安装宝塔面板 9.2.0 及以上版本 -- 推荐系统:CentOS 7+、Ubuntu 18.04+、Debian 10+ -- 服务器配置:至少1核2G内存 +| 项目 | 要求 | +| --- | --- | +| 宝塔面板 | ≥ 9.2.0 版本 | +| 推荐系统 | CentOS 7+、Ubuntu 18.04+、Debian 10+ | +| 服务器配置 | 至少 1 核 2G 内存 | -## 安装宝塔面板 +## 步骤一:安装宝塔面板 -1. 前往[宝塔面板官网](https://www.bt.cn/new/download.html)下载适合您系统的安装脚本 +1. 前往 [宝塔面板官网](https://www.bt.cn/new/download.html) 下载适合您系统的安装脚本 2. 运行安装脚本安装宝塔面板 -3. 安装完成后,使用提供的地址、用户名和密码登录到宝塔面板 +3. 安装完成后,使用提供的地址、用户名和密码登录宝塔面板 -## 安装Docker +## 步骤二:安装 Docker 1. 登录宝塔面板后,在左侧菜单栏找到并点击 **Docker** -2. 首次进入会提示安装Docker服务,点击 **立即安装** -3. 按照提示完成Docker服务的安装 +2. 首次进入会提示安装 Docker 服务,点击 **立即安装** +3. 按照提示完成 Docker 服务的安装 -## 安装New API +## 步骤三:安装 New API ### 方法一:使用宝塔应用商店(推荐) -1. 在宝塔面板Docker功能中,点击 **应用商店** +1. 在宝塔面板 Docker 功能中,点击 **应用商店** 2. 搜索并找到 **New-API** 3. 点击 **安装** 4. 配置以下基本选项: - - 容器名称:可自定义,默认为`new-api` - - 端口映射:默认为`3000:3000` - - 环境变量:根据需要添加(如TZ=Asia/Shanghai等) - - 目录映射:确保将`/data`目录映射到主机目录 -5. 点击 **提交**,完成安装 + - **容器名称**:可自定义,默认为 `new-api` + - **端口映射**:默认为 `3000:3000` + - **环境变量**: + - `SESSION_SECRET`:会话密钥(**必填**,多机部署时必须一致) + - `CRYPTO_SECRET`:加密密钥(使用 Redis 时必填) + - **目录映射**:确保将 `/data` 目录映射到主机目录 +5. 点击 **确认** 开始安装 +6. 等待安装完成后,访问 `http://您的服务器IP:3000` 即可使用 + +### 方法二:使用 Docker Compose + +适合需要更多自定义配置的场景。 + +1. 在宝塔面板中创建网站目录,如 `/www/wwwroot/new-api` +2. 创建 `docker-compose.yml` 文件: + +```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 # 请修改为随机字符串 + - TZ=Asia/Shanghai +``` + +3. 通过 SSH 终端进入目录并启动: + +```bash +cd /www/wwwroot/new-api +docker-compose up -d +``` + +### 方法三:使用自定义镜像 + + + 强烈建议通过"应用商店"安装。本节为高级用法,适合熟悉 Docker 的用户。 + -### 方法二:使用自定义镜像 +1. 在宝塔面板 Docker 功能中,点击 **镜像管理** +2. 点击 **获取镜像** → **拉取镜像** +3. 输入镜像名称:`calciumion/new-api:latest` +4. 点击 **提交**,等待镜像拉取完成 +5. 拉取完成后,进入 **容器列表**,点击 **创建容器** +6. 填写以下信息: + - **容器名称**:`new-api`(可自定义) + - **镜像**:选择刚刚拉取的 `calciumion/new-api:latest` + - **端口映射**:添加 `3000:3000` + - **目录映射**:添加 `/your/host/path:/data`(替换为您的主机路径) + - **环境变量**:根据需要添加 +7. 点击 **提交**,完成安装 -> 强烈建议通过“应用商店”安装并自动完成配置。本节为高级用法,适合明确了解Docker与宝塔容器配置的用户。 +## 环境变量配置 - - 仅在您勾选并同意上述确认后,再参考以下步骤手动配置自定义镜像: - +### 必要环境变量 + +| 变量名 | 说明 | 是否必填 | +| --- | --- | --- | +| `SESSION_SECRET` | 会话密钥,多机部署必须一致 | **必填** | +| `CRYPTO_SECRET` | 加密密钥,使用 Redis 时必填 | 条件必填 | +| `SQL_DSN` | 数据库连接字符串(使用外部数据库时) | 可选 | +| `REDIS_CONN_STRING` | Redis 连接字符串 | 可选 | - 1. 在宝塔面板Docker功能中,点击 **镜像管理** - 2. 点击 **获取镜像** -> **拉取镜像** - 3. 输入镜像名称:`calciumion/new-api:latest` - 4. 点击 **提交**,等待镜像拉取完成 - 5. 拉取完成后,进入 **容器列表**,点击 **创建容器** - 6. 填写以下信息: - - 容器名称:`new-api`(可自定义) - - 镜像:选择刚刚拉取的`calciumion/new-api:latest` - - 端口映射:添加`3000:3000` - - 目录映射:添加`/your/host/path:/data`(替换为您的主机路径) - - 环境变量:根据需要添加(如TZ=Asia/Shanghai等) - 7. 点击 **提交**,完成安装 +### 生成随机密钥 -## 配置与访问 +```bash +# 生成 SESSION_SECRET +openssl rand -hex 16 -安装完成后,您可以通过以下地址访问New API: +# 或使用 Linux 命令 +head -c 16 /dev/urandom | xxd -p +``` - http://服务器IP:3000 +## 访问与初始化 -首次访问将自动引导到初始化页面。按照页面指引设置管理员账号与密码(仅首次安装需要),完成后使用所设置的管理员账号登录。 +安装完成后,访问 `http://服务器IP:3000` + +首次访问将自动引导到初始化页面,按照页面指引设置管理员账号与密码。 ## 常见问题 -### 1. 无法访问New API界面 +### 无法访问 3000 端口 + +1. 检查服务器防火墙是否开放 3000 端口 +2. 在宝塔面板 **安全** 中放行 3000 端口 +3. 检查云服务器安全组是否开放端口 + +### 登录后提示会话失效 + +确保设置了 `SESSION_SECRET` 环境变量,且值不为空。 + +### 数据如何持久化 + +使用 Docker 卷映射数据目录: + +```yaml +volumes: + - ./data:/data +``` + +### 如何更新版本 + +```bash +# 拉取最新镜像 +docker pull calciumion/new-api:latest + +# 使用 Docker Compose 重启 +docker-compose down && docker-compose up -d -- 检查端口映射是否正确 -- 确认服务器防火墙是否放行3000端口 -- 查看容器是否正常运行 +# 或使用宝塔容器管理重启容器 +``` -### 2. 数据无法持久化 +## 相关链接 -- 确认是否正确映射了`/data`目录 -- 检查主机目录权限是否正确 +- [环境变量配置](/docs/installation/config-maintenance/environment-variables) +- [Docker Compose 部署](/docs/installation/deployment-methods/docker-compose-installation) +- [常见问题](/docs/support/faq) +- [GitHub 仓库](https://github.com/QuantumNous/new-api) \ No newline at end of file