docs: Add one-click installation script for PPanel with Docker support
- Introduced `install-ppanel.sh` script for automated installation of PPanel using Docker Compose. - Updated installation documentation to include one-click deployment options and detailed configuration steps. - Enhanced configuration files for MySQL and Redis with necessary parameters. - Improved Docker Compose setup with health checks and custom network configurations. - Added instructions for firewall configuration and reverse proxy setup for production environments. - Included troubleshooting tips and advanced options for non-interactive installations and proxy environments.
This commit is contained in:
parent
62d45bbac1
commit
912c5c4cb6
14
docs/.vitepress/cache/deps/_metadata.json
vendored
14
docs/.vitepress/cache/deps/_metadata.json
vendored
@ -1,31 +1,31 @@
|
||||
{
|
||||
"hash": "9bf5c878",
|
||||
"configHash": "c28f4e57",
|
||||
"hash": "7e859c1e",
|
||||
"configHash": "1f757845",
|
||||
"lockfileHash": "e3b0c442",
|
||||
"browserHash": "ae910468",
|
||||
"browserHash": "1e554b7a",
|
||||
"optimized": {
|
||||
"vue": {
|
||||
"src": "../../../../node_modules/vue/dist/vue.runtime.esm-bundler.js",
|
||||
"file": "vue.js",
|
||||
"fileHash": "4ddaa62e",
|
||||
"fileHash": "329c7fd1",
|
||||
"needsInterop": false
|
||||
},
|
||||
"vitepress > @vue/devtools-api": {
|
||||
"src": "../../../../node_modules/@vue/devtools-api/dist/index.js",
|
||||
"file": "vitepress___@vue_devtools-api.js",
|
||||
"fileHash": "327d077d",
|
||||
"fileHash": "65813058",
|
||||
"needsInterop": false
|
||||
},
|
||||
"vitepress > @vueuse/core": {
|
||||
"src": "../../../../node_modules/@vueuse/core/index.mjs",
|
||||
"file": "vitepress___@vueuse_core.js",
|
||||
"fileHash": "25a885ed",
|
||||
"fileHash": "015db502",
|
||||
"needsInterop": false
|
||||
},
|
||||
"vitepress-theme-teek": {
|
||||
"src": "../../../../node_modules/vitepress-theme-teek/es/index.mjs",
|
||||
"file": "vitepress-theme-teek.js",
|
||||
"fileHash": "bc0f7cc8",
|
||||
"fileHash": "0cc0cf7f",
|
||||
"needsInterop": false
|
||||
}
|
||||
},
|
||||
|
||||
194
docs/.vitepress/cache/deps/vitepress-theme-teek.js
vendored
194
docs/.vitepress/cache/deps/vitepress-theme-teek.js
vendored
File diff suppressed because one or more lines are too long
@ -67,6 +67,10 @@ export default defineConfig({
|
||||
text: "Installation",
|
||||
items: [
|
||||
{ text: "Overview", link: "/guide/installation/" },
|
||||
{
|
||||
text: "One-Click Deployment",
|
||||
link: "/guide/installation/one-click",
|
||||
},
|
||||
{
|
||||
text: "Docker Compose",
|
||||
link: "/guide/installation/docker-compose",
|
||||
@ -250,6 +254,10 @@ export default defineConfig({
|
||||
text: "安装部署",
|
||||
items: [
|
||||
{ text: "概览", link: "/zh/guide/installation/" },
|
||||
{
|
||||
text: "一键部署",
|
||||
link: "/zh/guide/installation/one-click",
|
||||
},
|
||||
{
|
||||
text: "Docker Compose",
|
||||
link: "/zh/guide/installation/docker-compose",
|
||||
|
||||
@ -209,7 +209,7 @@ docker compose ps
|
||||
After successful installation, you can access:
|
||||
|
||||
- **User Panel**: `http://your-server-ip:8080`
|
||||
- **Admin Panel**: `http://your-server-ip:8080/admin`
|
||||
- **Admin Panel**: `http://your-server-ip:8080/admin/`
|
||||
|
||||
::: warning Default Credentials
|
||||
Please change the default admin password immediately after first login for security.
|
||||
|
||||
@ -23,19 +23,29 @@ uname -m
|
||||
|
||||
Visit the [GitHub Releases](https://github.com/perfect-panel/ppanel/releases) page or download directly:
|
||||
|
||||
::: tip Installation Directory
|
||||
You can install PPanel in any directory. This guide uses `/opt/ppanel` as an example. If you choose a different directory, adjust the paths in subsequent commands accordingly.
|
||||
:::
|
||||
|
||||
```bash
|
||||
# Create installation directory
|
||||
# Create installation directory (customizable)
|
||||
sudo mkdir -p /opt/ppanel
|
||||
cd /opt/ppanel
|
||||
|
||||
# Download for Linux amd64
|
||||
wget https://github.com/perfect-panel/ppanel/releases/latest/download/ppanel-linux-amd64.tar.gz
|
||||
wget https://github.com/perfect-panel/ppanel/releases/latest/download/gateway-linux-amd64.tar.gz
|
||||
|
||||
# Or for Linux arm64
|
||||
# wget https://github.com/perfect-panel/ppanel/releases/latest/download/ppanel-linux-arm64.tar.gz
|
||||
# wget https://github.com/perfect-panel/ppanel/releases/latest/download/gateway-linux-arm64.tar.gz
|
||||
|
||||
# Or for macOS amd64
|
||||
# wget https://github.com/perfect-panel/ppanel/releases/latest/download/gateway-darwin-amd64.tar.gz
|
||||
|
||||
# Or for macOS arm64 (Apple Silicon)
|
||||
# wget https://github.com/perfect-panel/ppanel/releases/latest/download/gateway-darwin-arm64.tar.gz
|
||||
|
||||
# Extract
|
||||
tar -xzf ppanel-linux-amd64.tar.gz
|
||||
tar -xzf gateway-linux-amd64.tar.gz
|
||||
|
||||
# Verify extracted files
|
||||
ls -la
|
||||
@ -44,8 +54,7 @@ ls -la
|
||||
Expected files:
|
||||
```
|
||||
/opt/ppanel/
|
||||
├── ppanel-server # Main server binary
|
||||
├── gateway # Gateway binary
|
||||
├── gateway # Gateway executable
|
||||
└── etc/ # Configuration directory
|
||||
└── ppanel.yaml # Configuration file
|
||||
```
|
||||
@ -55,52 +64,92 @@ Expected files:
|
||||
### Step 1: Prepare Configuration
|
||||
|
||||
```bash
|
||||
# Copy sample configuration
|
||||
sudo cp etc/ppanel.yaml etc/ppanel.yaml.backup
|
||||
|
||||
# Edit configuration
|
||||
sudo nano etc/ppanel.yaml
|
||||
sudo nano /opt/ppanel/etc/ppanel.yaml
|
||||
```
|
||||
|
||||
**Basic Configuration Example:**
|
||||
**Configuration Example:**
|
||||
|
||||
::: tip Relative Paths
|
||||
Paths in the configuration (such as `Path`, `logs`, etc.) support relative paths. Relative paths are relative to the program's working directory (WorkingDirectory), which is `/opt/ppanel` in the systemd service.
|
||||
:::
|
||||
|
||||
```yaml
|
||||
server:
|
||||
host: 0.0.0.0
|
||||
port: 8080
|
||||
mode: release # debug, release, or test
|
||||
Host: 0.0.0.0
|
||||
Port: 8080
|
||||
TLS:
|
||||
Enable: false
|
||||
CertFile: ""
|
||||
KeyFile: ""
|
||||
Debug: false
|
||||
|
||||
database:
|
||||
type: sqlite
|
||||
path: /opt/ppanel/data/ppanel.db
|
||||
# For MySQL/PostgreSQL:
|
||||
# type: mysql
|
||||
# host: localhost
|
||||
# port: 3306
|
||||
# user: ppanel
|
||||
# password: your_password
|
||||
# database: ppanel
|
||||
Static:
|
||||
Admin:
|
||||
Enabled: true
|
||||
Prefix: /admin
|
||||
Path: ./static/admin
|
||||
User:
|
||||
Enabled: true
|
||||
Prefix: /
|
||||
Path: ./static/user
|
||||
|
||||
log:
|
||||
level: info # debug, info, warn, error
|
||||
path: /opt/ppanel/logs
|
||||
JwtAuth:
|
||||
AccessSecret: your-secret-key-change-this
|
||||
AccessExpire: 604800
|
||||
|
||||
gateway:
|
||||
port: 8080
|
||||
timeout: 30s
|
||||
Logger:
|
||||
ServiceName: ApiService
|
||||
Mode: console
|
||||
Encoding: plain
|
||||
TimeFormat: "2006-01-02 15:04:05.000"
|
||||
Path: logs
|
||||
Level: info
|
||||
MaxContentLength: 0
|
||||
Compress: false
|
||||
Stat: true
|
||||
KeepDays: 0
|
||||
StackCooldownMillis: 100
|
||||
MaxBackups: 0
|
||||
MaxSize: 0
|
||||
Rotation: daily
|
||||
FileTimeFormat: 2006-01-02T15:04:05.000Z07:00
|
||||
|
||||
MySQL:
|
||||
Addr: localhost:3306
|
||||
Username: your-username
|
||||
Password: your-password
|
||||
Dbname: ppanel
|
||||
Config: charset=utf8mb4&parseTime=true&loc=Asia%2FShanghai
|
||||
MaxIdleConns: 10
|
||||
MaxOpenConns: 10
|
||||
SlowThreshold: 1000
|
||||
|
||||
Redis:
|
||||
Host: localhost:6379
|
||||
Pass: your-redis-password
|
||||
DB: 0
|
||||
```
|
||||
|
||||
::: warning Required Configuration
|
||||
**MySQL and Redis are required.** Please configure the following before deployment:
|
||||
- `JwtAuth.AccessSecret` - Use a strong random secret (required)
|
||||
- `MySQL.*` - Configure your MySQL database connection (required)
|
||||
- `Redis.*` - Configure your Redis connection (required)
|
||||
:::
|
||||
|
||||
### Step 2: Create Required Directories
|
||||
|
||||
```bash
|
||||
# Create data and log directories
|
||||
sudo mkdir -p /opt/ppanel/data
|
||||
sudo mkdir -p /opt/ppanel/logs
|
||||
sudo mkdir -p /opt/ppanel/static
|
||||
|
||||
# Set proper permissions
|
||||
sudo chmod 755 /opt/ppanel
|
||||
sudo chmod 700 /opt/ppanel/data
|
||||
sudo chmod 755 /opt/ppanel/logs
|
||||
sudo chmod 755 /opt/ppanel/static
|
||||
```
|
||||
|
||||
## Running the Service
|
||||
@ -110,16 +159,12 @@ sudo chmod 755 /opt/ppanel/logs
|
||||
For quick testing:
|
||||
|
||||
```bash
|
||||
# Make binaries executable
|
||||
sudo chmod +x /opt/ppanel/ppanel-server
|
||||
# Make binary executable
|
||||
sudo chmod +x /opt/ppanel/gateway
|
||||
|
||||
# Run server directly
|
||||
# Run directly
|
||||
cd /opt/ppanel
|
||||
sudo ./ppanel-server
|
||||
|
||||
# In another terminal, run gateway (if separate)
|
||||
# sudo ./gateway
|
||||
sudo ./gateway
|
||||
```
|
||||
|
||||
Press `Ctrl+C` to stop.
|
||||
@ -147,7 +192,7 @@ Wants=network-online.target
|
||||
Type=simple
|
||||
User=root
|
||||
WorkingDirectory=/opt/ppanel
|
||||
ExecStart=/opt/ppanel/ppanel-server
|
||||
ExecStart=/opt/ppanel/gateway
|
||||
Restart=always
|
||||
RestartSec=10
|
||||
|
||||
@ -262,7 +307,7 @@ ps aux | grep ppanel
|
||||
### Access the Application
|
||||
|
||||
- **User Panel**: `http://your-server-ip:8080`
|
||||
- **Admin Panel**: `http://your-server-ip:8080/admin`
|
||||
- **Admin Panel**: `http://your-server-ip:8080/admin/`
|
||||
|
||||
### Configure Firewall
|
||||
|
||||
@ -312,70 +357,11 @@ sudo systemctl reload nginx
|
||||
|
||||
## Upgrading
|
||||
|
||||
### Backup Before Upgrade
|
||||
Upgrade PPanel directly from the **Admin Dashboard**. On the dashboard homepage, you can check for new versions and upgrade with one click.
|
||||
|
||||
```bash
|
||||
# Stop service
|
||||
sudo systemctl stop ppanel
|
||||
|
||||
# Backup current version
|
||||
sudo cp -r /opt/ppanel /opt/ppanel-backup-$(date +%Y%m%d)
|
||||
|
||||
# Backup database
|
||||
sudo cp /opt/ppanel/data/ppanel.db /opt/ppanel/data/ppanel.db.backup-$(date +%Y%m%d)
|
||||
|
||||
# Backup configuration
|
||||
sudo cp /opt/ppanel/etc/ppanel.yaml /opt/ppanel/etc/ppanel.yaml.backup-$(date +%Y%m%d)
|
||||
```
|
||||
|
||||
### Download and Install New Version
|
||||
|
||||
```bash
|
||||
# Download new version
|
||||
cd /tmp
|
||||
wget https://github.com/perfect-panel/ppanel/releases/latest/download/ppanel-linux-amd64.tar.gz
|
||||
|
||||
# Extract to temporary location
|
||||
mkdir ppanel-new
|
||||
tar -xzf ppanel-linux-amd64.tar.gz -C ppanel-new
|
||||
|
||||
# Backup old binaries
|
||||
sudo mv /opt/ppanel/ppanel-server /opt/ppanel/ppanel-server.old
|
||||
sudo mv /opt/ppanel/gateway /opt/ppanel/gateway.old
|
||||
|
||||
# Install new binaries
|
||||
sudo cp ppanel-new/ppanel-server /opt/ppanel/
|
||||
sudo cp ppanel-new/gateway /opt/ppanel/
|
||||
|
||||
# Set permissions
|
||||
sudo chmod +x /opt/ppanel/ppanel-server
|
||||
sudo chmod +x /opt/ppanel/gateway
|
||||
|
||||
# Start service
|
||||
sudo systemctl start ppanel
|
||||
|
||||
# Check status
|
||||
sudo systemctl status ppanel
|
||||
```
|
||||
|
||||
### Rollback
|
||||
|
||||
If upgrade fails:
|
||||
|
||||
```bash
|
||||
# Stop service
|
||||
sudo systemctl stop ppanel
|
||||
|
||||
# Restore old binaries
|
||||
sudo mv /opt/ppanel/ppanel-server.old /opt/ppanel/ppanel-server
|
||||
sudo mv /opt/ppanel/gateway.old /opt/ppanel/gateway
|
||||
|
||||
# Restore database (if needed)
|
||||
sudo cp /opt/ppanel/data/ppanel.db.backup-YYYYMMDD /opt/ppanel/data/ppanel.db
|
||||
|
||||
# Start service
|
||||
sudo systemctl start ppanel
|
||||
```
|
||||
::: tip
|
||||
The system will automatically handle the upgrade process, including downloading the new binary and restarting the service.
|
||||
:::
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
@ -413,14 +399,14 @@ sudo systemctl restart ppanel
|
||||
```bash
|
||||
# Check architecture compatibility
|
||||
uname -m
|
||||
file /opt/ppanel/ppanel-server
|
||||
file /opt/ppanel/gateway
|
||||
|
||||
# Check if executable
|
||||
ls -la /opt/ppanel/ppanel-server
|
||||
sudo chmod +x /opt/ppanel/ppanel-server
|
||||
ls -la /opt/ppanel/gateway
|
||||
sudo chmod +x /opt/ppanel/gateway
|
||||
|
||||
# Check for missing libraries (should be none for static binary)
|
||||
ldd /opt/ppanel/ppanel-server
|
||||
ldd /opt/ppanel/gateway
|
||||
```
|
||||
|
||||
### High Memory Usage
|
||||
@ -497,7 +483,7 @@ sudo nano /etc/systemd/system/ppanel.service
|
||||
# Change: User=ppanel
|
||||
|
||||
# If binding to port < 1024, grant capability
|
||||
sudo setcap 'cap_net_bind_service=+ep' /opt/ppanel/ppanel-server
|
||||
sudo setcap 'cap_net_bind_service=+ep' /opt/ppanel/gateway
|
||||
|
||||
sudo systemctl daemon-reload
|
||||
sudo systemctl restart ppanel
|
||||
|
||||
@ -77,17 +77,17 @@ Create a `docker-compose.yml` file with the following content:
|
||||
version: '3.8'
|
||||
|
||||
services:
|
||||
ppanel:
|
||||
ppanel-service:
|
||||
image: ppanel/ppanel:latest
|
||||
container_name: ppanel
|
||||
container_name: ppanel-service
|
||||
restart: always
|
||||
ports:
|
||||
- "8080:8080"
|
||||
volumes:
|
||||
- ./ppanel-config:/app/etc:ro
|
||||
- ppanel-data:/app/data
|
||||
restart: unless-stopped
|
||||
environment:
|
||||
- TZ=UTC
|
||||
- ./config:/app/etc:ro
|
||||
- ./web:/app/static
|
||||
networks:
|
||||
- ppanel-net
|
||||
healthcheck:
|
||||
test: ["CMD", "wget", "--quiet", "--tries=1", "--spider", "http://localhost:8080/health"]
|
||||
interval: 30s
|
||||
@ -95,43 +95,94 @@ services:
|
||||
retries: 3
|
||||
start_period: 40s
|
||||
|
||||
volumes:
|
||||
ppanel-data:
|
||||
driver: local
|
||||
networks:
|
||||
ppanel-net:
|
||||
driver: bridge
|
||||
```
|
||||
|
||||
**Configuration Explanation:**
|
||||
|
||||
- **image**: Docker image to use (latest or specific version like `v0.1.2`)
|
||||
- **ports**: Map container port 8080 to host port 8080
|
||||
- **container_name**: Set a custom container name
|
||||
- **ports**: Map container port 8080 to host port 8080 (change host port if needed)
|
||||
- **volumes**:
|
||||
- `./ppanel-config:/app/etc:ro` - Configuration directory (read-only)
|
||||
- `ppanel-data:/app/data` - Persistent data storage
|
||||
- **restart**: Auto-restart policy
|
||||
- **environment**: Set timezone (change to your timezone like `Asia/Shanghai`)
|
||||
- `./config:/app/etc:ro` - Configuration directory (read-only)
|
||||
- `./web:/app/static` - Static files directory (admin and user frontend)
|
||||
- **networks**: Create a custom network for service isolation
|
||||
- **restart**: Auto-restart policy (always restart on failures)
|
||||
- **healthcheck**: Monitor service health
|
||||
|
||||
### Step 3: Prepare Configuration
|
||||
|
||||
```bash
|
||||
# Create configuration directory
|
||||
mkdir -p ppanel-config
|
||||
mkdir -p config
|
||||
|
||||
# Create configuration file
|
||||
cat > ppanel-config/ppanel.yaml <<EOF
|
||||
# PPanel Configuration
|
||||
server:
|
||||
host: 0.0.0.0
|
||||
port: 8080
|
||||
cat > config/ppanel.yaml <<EOF
|
||||
Host: 0.0.0.0
|
||||
Port: 8080
|
||||
TLS:
|
||||
Enable: false
|
||||
CertFile: ""
|
||||
KeyFile: ""
|
||||
Debug: false
|
||||
|
||||
database:
|
||||
type: sqlite
|
||||
path: /app/data/ppanel.db
|
||||
Static:
|
||||
Admin:
|
||||
Enabled: true
|
||||
Prefix: /admin
|
||||
Path: ./static/admin
|
||||
User:
|
||||
Enabled: true
|
||||
Prefix: /
|
||||
Path: ./static/user
|
||||
|
||||
# Add more configuration as needed
|
||||
JwtAuth:
|
||||
AccessSecret: your-secret-key-change-this
|
||||
AccessExpire: 604800
|
||||
|
||||
Logger:
|
||||
ServiceName: ApiService
|
||||
Mode: console
|
||||
Encoding: plain
|
||||
TimeFormat: "2006-01-02 15:04:05.000"
|
||||
Path: logs
|
||||
Level: info
|
||||
MaxContentLength: 0
|
||||
Compress: false
|
||||
Stat: true
|
||||
KeepDays: 0
|
||||
StackCooldownMillis: 100
|
||||
MaxBackups: 0
|
||||
MaxSize: 0
|
||||
Rotation: daily
|
||||
FileTimeFormat: 2006-01-02T15:04:05.000Z07:00
|
||||
|
||||
MySQL:
|
||||
Addr: localhost:3306
|
||||
Username: your-username
|
||||
Password: your-password
|
||||
Dbname: ppanel
|
||||
Config: charset=utf8mb4&parseTime=true&loc=Asia%2FShanghai
|
||||
MaxIdleConns: 10
|
||||
MaxOpenConns: 10
|
||||
SlowThreshold: 1000
|
||||
|
||||
Redis:
|
||||
Host: localhost:6379
|
||||
Pass: your-redis-password
|
||||
DB: 0
|
||||
EOF
|
||||
```
|
||||
|
||||
::: warning Required Configuration
|
||||
**MySQL and Redis are required.** Please configure the following before deployment:
|
||||
- `JwtAuth.AccessSecret` - Use a strong random secret (required)
|
||||
- `MySQL.*` - Configure your MySQL database connection (required)
|
||||
- `Redis.*` - Configure your Redis connection (required)
|
||||
:::
|
||||
|
||||
::: tip
|
||||
For detailed configuration options, please refer to the [Configuration Guide](/guide/configuration).
|
||||
:::
|
||||
@ -169,7 +220,7 @@ docker compose logs -f ppanel
|
||||
After successful installation, you can access:
|
||||
|
||||
- **User Panel**: `http://your-server-ip:8080`
|
||||
- **Admin Panel**: `http://your-server-ip:8080/admin`
|
||||
- **Admin Panel**: `http://your-server-ip:8080/admin/`
|
||||
|
||||
::: warning Default Credentials
|
||||
Please change the default admin password immediately after first login for security.
|
||||
@ -272,43 +323,11 @@ Using `docker compose down -v` will delete all data volumes. Only use this if yo
|
||||
|
||||
## Upgrading
|
||||
|
||||
### Backup Before Upgrade
|
||||
Upgrade PPanel directly from the **Admin Dashboard**. On the dashboard homepage, you can check for new versions and upgrade with one click.
|
||||
|
||||
```bash
|
||||
# Backup configuration
|
||||
tar czf ppanel-config-backup-$(date +%Y%m%d).tar.gz ppanel-config/
|
||||
|
||||
# Backup data volume
|
||||
docker run --rm \
|
||||
-v ppanel_ppanel-data:/data \
|
||||
-v $(pwd):/backup \
|
||||
alpine tar czf /backup/ppanel-data-backup-$(date +%Y%m%d).tar.gz /data
|
||||
```
|
||||
|
||||
### Upgrade Steps
|
||||
|
||||
```bash
|
||||
# Pull latest image
|
||||
docker compose pull
|
||||
|
||||
# Recreate containers with new image
|
||||
docker compose up -d
|
||||
|
||||
# View logs to verify
|
||||
docker compose logs -f
|
||||
```
|
||||
|
||||
### Rollback
|
||||
|
||||
If you encounter issues after upgrading:
|
||||
|
||||
```bash
|
||||
# Edit docker-compose.yml and change image to previous version
|
||||
# image: ppanel/ppanel:v0.1.1
|
||||
|
||||
# Restart with previous version
|
||||
docker compose up -d
|
||||
```
|
||||
::: tip
|
||||
The system will automatically handle the upgrade process, including pulling the new image and restarting the service.
|
||||
:::
|
||||
|
||||
## Advanced Configuration
|
||||
|
||||
@ -317,7 +336,9 @@ docker compose up -d
|
||||
To use a different port, edit `docker-compose.yml`:
|
||||
|
||||
```yaml
|
||||
ports:
|
||||
services:
|
||||
ppanel-service:
|
||||
ports:
|
||||
- "3000:8080" # Host port 3000 -> Container port 8080
|
||||
```
|
||||
|
||||
@ -403,10 +424,10 @@ sudo lsof -i :8080
|
||||
|
||||
```bash
|
||||
# Fix configuration directory permissions
|
||||
sudo chown -R $USER:$USER ppanel-config/
|
||||
sudo chown -R $USER:$USER config/
|
||||
|
||||
# Make sure files are readable
|
||||
chmod 644 ppanel-config/ppanel.yaml
|
||||
chmod 644 config/ppanel.yaml
|
||||
```
|
||||
|
||||
### Cannot Access from Outside
|
||||
|
||||
@ -67,53 +67,106 @@ mkdir -p ~/ppanel-config
|
||||
|
||||
# Create configuration file
|
||||
cat > ~/ppanel-config/ppanel.yaml <<EOF
|
||||
server:
|
||||
host: 0.0.0.0
|
||||
port: 8080
|
||||
Host: 0.0.0.0
|
||||
Port: 8080
|
||||
TLS:
|
||||
Enable: false
|
||||
CertFile: ""
|
||||
KeyFile: ""
|
||||
Debug: false
|
||||
|
||||
database:
|
||||
type: sqlite
|
||||
path: /app/data/ppanel.db
|
||||
Static:
|
||||
Admin:
|
||||
Enabled: true
|
||||
Prefix: /admin
|
||||
Path: ./static/admin
|
||||
User:
|
||||
Enabled: true
|
||||
Prefix: /
|
||||
Path: ./static/user
|
||||
|
||||
JwtAuth:
|
||||
AccessSecret: your-secret-key-change-this
|
||||
AccessExpire: 604800
|
||||
|
||||
Logger:
|
||||
ServiceName: ApiService
|
||||
Mode: console
|
||||
Encoding: plain
|
||||
TimeFormat: "2006-01-02 15:04:05.000"
|
||||
Path: logs
|
||||
Level: info
|
||||
MaxContentLength: 0
|
||||
Compress: false
|
||||
Stat: true
|
||||
KeepDays: 0
|
||||
StackCooldownMillis: 100
|
||||
MaxBackups: 0
|
||||
MaxSize: 0
|
||||
Rotation: daily
|
||||
FileTimeFormat: 2006-01-02T15:04:05.000Z07:00
|
||||
|
||||
MySQL:
|
||||
Addr: localhost:3306
|
||||
Username: your-username
|
||||
Password: your-password
|
||||
Dbname: ppanel
|
||||
Config: charset=utf8mb4&parseTime=true&loc=Asia%2FShanghai
|
||||
MaxIdleConns: 10
|
||||
MaxOpenConns: 10
|
||||
SlowThreshold: 1000
|
||||
|
||||
Redis:
|
||||
Host: localhost:6379
|
||||
Pass: your-redis-password
|
||||
DB: 0
|
||||
EOF
|
||||
```
|
||||
|
||||
::: warning Required Configuration
|
||||
**MySQL and Redis are required.** Please configure the following before deployment:
|
||||
- `JwtAuth.AccessSecret` - Use a strong random secret (required)
|
||||
- `MySQL.*` - Configure your MySQL database connection (required)
|
||||
- `Redis.*` - Configure your Redis connection (required)
|
||||
:::
|
||||
|
||||
### Step 3: Run Container
|
||||
|
||||
**Basic Command:**
|
||||
```bash
|
||||
docker run -d \
|
||||
--name ppanel \
|
||||
--name ppanel-service \
|
||||
-p 8080:8080 \
|
||||
-v ~/ppanel-config:/app/etc:ro \
|
||||
-v ppanel-data:/app/data \
|
||||
--restart unless-stopped \
|
||||
-v ~/ppanel-web:/app/static \
|
||||
--restart always \
|
||||
ppanel/ppanel:latest
|
||||
```
|
||||
|
||||
**With All Options:**
|
||||
```bash
|
||||
docker run -d \
|
||||
--name ppanel \
|
||||
--name ppanel-service \
|
||||
-p 8080:8080 \
|
||||
-v ~/ppanel-config:/app/etc:ro \
|
||||
-v ppanel-data:/app/data \
|
||||
-e TZ=UTC \
|
||||
--restart unless-stopped \
|
||||
-v ~/ppanel-web:/app/static \
|
||||
--restart always \
|
||||
--memory="2g" \
|
||||
--cpus="2" \
|
||||
--network ppanel-net \
|
||||
ppanel/ppanel:latest
|
||||
```
|
||||
|
||||
**Parameter Explanation:**
|
||||
- `-d`: Run in detached mode (background)
|
||||
- `--name ppanel`: Set container name
|
||||
- `--name ppanel-service`: Set container name
|
||||
- `-p 8080:8080`: Map port (host:container)
|
||||
- `-v ~/ppanel-config:/app/etc:ro`: Mount configuration (read-only)
|
||||
- `-v ppanel-data:/app/data`: Create data volume
|
||||
- `-e TZ=UTC`: Set timezone
|
||||
- `--restart unless-stopped`: Auto-restart policy
|
||||
- `--memory="2g"`: Memory limit
|
||||
- `--cpus="2"`: CPU limit
|
||||
- `-v ~/ppanel-web:/app/static`: Mount static files directory
|
||||
- `--restart always`: Auto-restart policy (always restart)
|
||||
- `--memory="2g"`: Memory limit (optional)
|
||||
- `--cpus="2"`: CPU limit (optional)
|
||||
- `--network ppanel-net`: Connect to custom network (optional)
|
||||
|
||||
### Step 4: Verify Running
|
||||
|
||||
@ -181,43 +234,11 @@ docker volume rm ppanel-data
|
||||
|
||||
## Upgrading
|
||||
|
||||
### Backup Data
|
||||
Upgrade PPanel directly from the **Admin Dashboard**. On the dashboard homepage, you can check for new versions and upgrade with one click.
|
||||
|
||||
```bash
|
||||
# Backup configuration
|
||||
tar czf ppanel-config-backup-$(date +%Y%m%d).tar.gz ~/ppanel-config/
|
||||
|
||||
# Backup data volume
|
||||
docker run --rm \
|
||||
-v ppanel-data:/data \
|
||||
-v $(pwd):/backup \
|
||||
alpine tar czf /backup/ppanel-data-backup-$(date +%Y%m%d).tar.gz /data
|
||||
```
|
||||
|
||||
### Upgrade Process
|
||||
|
||||
```bash
|
||||
# Pull latest image
|
||||
docker pull ppanel/ppanel:latest
|
||||
|
||||
# Stop old container
|
||||
docker stop ppanel
|
||||
|
||||
# Remove old container
|
||||
docker rm ppanel
|
||||
|
||||
# Start new container with same configuration
|
||||
docker run -d \
|
||||
--name ppanel \
|
||||
-p 8080:8080 \
|
||||
-v ~/ppanel-config:/app/etc:ro \
|
||||
-v ppanel-data:/app/data \
|
||||
--restart unless-stopped \
|
||||
ppanel/ppanel:latest
|
||||
|
||||
# Verify
|
||||
docker logs -f ppanel
|
||||
```
|
||||
::: tip
|
||||
The system will automatically handle the upgrade process, including pulling the new image and restarting the service.
|
||||
:::
|
||||
|
||||
## Advanced Usage
|
||||
|
||||
|
||||
289
docs/guide/installation/one-click.md
Normal file
289
docs/guide/installation/one-click.md
Normal file
@ -0,0 +1,289 @@
|
||||
# One-Click Deployment
|
||||
|
||||
The quickest way to deploy PPanel using automated installation scripts. Perfect for quick testing or production deployment.
|
||||
|
||||
## Prerequisites
|
||||
|
||||
- Clean Linux server (Ubuntu 20.04+, Debian 10+, CentOS 8+)
|
||||
- Root or sudo access
|
||||
- Basic network connectivity
|
||||
|
||||
## Installation Steps
|
||||
|
||||
### Option 1: Complete Installation (Recommended)
|
||||
|
||||
Install both Docker and PPanel in one command:
|
||||
|
||||
```bash
|
||||
curl -fsSL https://ppanel.dev/scripts/en/install-docker.sh | sudo bash && \
|
||||
curl -fsSL https://ppanel.dev/scripts/en/install-ppanel.sh | bash
|
||||
```
|
||||
|
||||
### Option 2: Step-by-Step Installation
|
||||
|
||||
If you prefer to install components separately:
|
||||
|
||||
#### Step 1: Install Docker & Docker Compose
|
||||
|
||||
```bash
|
||||
curl -fsSL https://ppanel.dev/scripts/en/install-docker.sh | sudo bash
|
||||
```
|
||||
|
||||
This script will:
|
||||
- ✅ Automatically detect your operating system
|
||||
- ✅ Install Docker Engine and Docker Compose Plugin
|
||||
- ✅ Configure Docker service to start on boot
|
||||
- ✅ Add current user to docker group
|
||||
- ✅ Verify installation
|
||||
|
||||
#### Step 2: Install PPanel
|
||||
|
||||
```bash
|
||||
curl -fsSL https://ppanel.dev/scripts/en/install-ppanel.sh | bash
|
||||
```
|
||||
|
||||
This script will:
|
||||
- ✅ Check Docker environment
|
||||
- ✅ Check port availability
|
||||
- ✅ Create installation directories
|
||||
- ✅ Interactive configuration (MySQL, Redis)
|
||||
- ✅ Generate JWT secret automatically
|
||||
- ✅ Create docker-compose.yml
|
||||
- ✅ Pull Docker images and start services
|
||||
- ✅ Display access information
|
||||
|
||||
## Configuration During Installation
|
||||
|
||||
The installation script will prompt you for the following information:
|
||||
|
||||
### MySQL Configuration (Required)
|
||||
|
||||
```
|
||||
MySQL Address (default: localhost:3306):
|
||||
MySQL Username (default: ppanel):
|
||||
MySQL Password: [your-password]
|
||||
MySQL Database (default: ppanel):
|
||||
```
|
||||
|
||||
### Redis Configuration (Required)
|
||||
|
||||
```
|
||||
Redis Address (default: localhost:6379):
|
||||
Redis Password (optional): [your-password]
|
||||
Redis DB (default: 0):
|
||||
```
|
||||
|
||||
::: tip
|
||||
The installation script will automatically generate a secure JWT secret for you.
|
||||
:::
|
||||
|
||||
## Custom Installation Directory
|
||||
|
||||
By default, PPanel is installed to `~/ppanel`. You can specify a custom directory:
|
||||
|
||||
```bash
|
||||
INSTALL_DIR=/opt/ppanel curl -fsSL https://ppanel.dev/scripts/en/install-ppanel.sh | bash
|
||||
```
|
||||
|
||||
## Custom Port
|
||||
|
||||
By default, PPanel listens on port 8080. To use a different port:
|
||||
|
||||
```bash
|
||||
HOST_PORT=3000 curl -fsSL https://ppanel.dev/scripts/en/install-ppanel.sh | bash
|
||||
```
|
||||
|
||||
## Post-Installation
|
||||
|
||||
### Access Your Installation
|
||||
|
||||
After successful installation, you can access:
|
||||
|
||||
- **User Panel**: `http://your-server-ip:8080`
|
||||
- **Admin Panel**: `http://your-server-ip:8080/admin/`
|
||||
|
||||
### Common Commands
|
||||
|
||||
The installation script displays these useful commands:
|
||||
|
||||
```bash
|
||||
# Navigate to installation directory
|
||||
cd ~/ppanel
|
||||
|
||||
# Check service status
|
||||
docker compose ps
|
||||
|
||||
# View logs
|
||||
docker compose logs -f
|
||||
|
||||
# Restart services
|
||||
docker compose restart
|
||||
|
||||
# Stop services
|
||||
docker compose stop
|
||||
|
||||
# Start services
|
||||
docker compose start
|
||||
```
|
||||
|
||||
### Configure Firewall
|
||||
|
||||
**Ubuntu/Debian:**
|
||||
```bash
|
||||
sudo ufw allow 8080/tcp
|
||||
sudo ufw status
|
||||
```
|
||||
|
||||
**CentOS/RHEL:**
|
||||
```bash
|
||||
sudo firewall-cmd --permanent --add-port=8080/tcp
|
||||
sudo firewall-cmd --reload
|
||||
```
|
||||
|
||||
### Setup Reverse Proxy (Recommended)
|
||||
|
||||
For production deployments, configure a reverse proxy with HTTPS:
|
||||
|
||||
**Nginx:**
|
||||
```nginx
|
||||
server {
|
||||
listen 80;
|
||||
server_name your-domain.com;
|
||||
return 301 https://$server_name$request_uri;
|
||||
}
|
||||
|
||||
server {
|
||||
listen 443 ssl http2;
|
||||
server_name your-domain.com;
|
||||
|
||||
ssl_certificate /path/to/cert.pem;
|
||||
ssl_certificate_key /path/to/key.pem;
|
||||
|
||||
location / {
|
||||
proxy_pass http://localhost:8080;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
**Caddy:**
|
||||
```
|
||||
your-domain.com {
|
||||
reverse_proxy localhost:8080
|
||||
}
|
||||
```
|
||||
|
||||
## Upgrading
|
||||
|
||||
Upgrade PPanel directly from the **Admin Dashboard**. On the dashboard homepage, you can check for new versions and upgrade with one click.
|
||||
|
||||
::: tip
|
||||
The system will automatically handle the upgrade process, including pulling the new image and restarting the service.
|
||||
:::
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
### Installation Failed
|
||||
|
||||
If the installation fails, check:
|
||||
|
||||
1. **Internet connectivity**: Ensure your server can access Docker Hub and GitHub
|
||||
2. **System requirements**: Verify your OS is supported
|
||||
3. **Permissions**: Make sure you have sudo/root access
|
||||
4. **Port availability**: Check if port 8080 is available
|
||||
|
||||
### Docker Not Found
|
||||
|
||||
If you get "Docker not found" error:
|
||||
|
||||
```bash
|
||||
# Check if Docker is installed
|
||||
docker --version
|
||||
|
||||
# If not installed, run the Docker installation script first
|
||||
curl -fsSL https://ppanel.dev/scripts/en/install-docker.sh | sudo bash
|
||||
```
|
||||
|
||||
### Service Won't Start
|
||||
|
||||
Check the logs for errors:
|
||||
|
||||
```bash
|
||||
cd ~/ppanel
|
||||
docker compose logs -f
|
||||
```
|
||||
|
||||
Common issues:
|
||||
- MySQL connection failed: Check MySQL credentials
|
||||
- Redis connection failed: Check Redis credentials
|
||||
- Port already in use: Change the HOST_PORT
|
||||
|
||||
### Permission Denied
|
||||
|
||||
If you get permission errors with Docker:
|
||||
|
||||
```bash
|
||||
# Add user to docker group
|
||||
sudo usermod -aG docker $USER
|
||||
|
||||
# Log out and log back in, or run:
|
||||
newgrp docker
|
||||
```
|
||||
|
||||
## Uninstalling
|
||||
|
||||
To completely remove PPanel:
|
||||
|
||||
```bash
|
||||
cd ~/ppanel
|
||||
docker compose down
|
||||
cd ~
|
||||
rm -rf ~/ppanel
|
||||
```
|
||||
|
||||
## Advanced Options
|
||||
|
||||
### Non-Interactive Installation
|
||||
|
||||
For automated deployments, you can pre-configure settings using environment variables:
|
||||
|
||||
```bash
|
||||
export INSTALL_DIR=/opt/ppanel
|
||||
export HOST_PORT=8080
|
||||
export MYSQL_ADDR=localhost:3306
|
||||
export MYSQL_USER=ppanel
|
||||
export MYSQL_PASSWORD=your-password
|
||||
export MYSQL_DB=ppanel
|
||||
export REDIS_HOST=localhost:6379
|
||||
export REDIS_PASS=your-redis-password
|
||||
export REDIS_DB=0
|
||||
|
||||
curl -fsSL https://ppanel.dev/scripts/en/install-ppanel.sh | bash
|
||||
```
|
||||
|
||||
### Installation Behind Proxy
|
||||
|
||||
If your server is behind a proxy:
|
||||
|
||||
```bash
|
||||
export HTTP_PROXY=http://proxy.example.com:8080
|
||||
export HTTPS_PROXY=http://proxy.example.com:8080
|
||||
|
||||
curl -fsSL https://ppanel.dev/scripts/en/install-docker.sh | sudo bash
|
||||
curl -fsSL https://ppanel.dev/scripts/en/install-ppanel.sh | bash
|
||||
```
|
||||
|
||||
## Next Steps
|
||||
|
||||
- [Configuration Guide](/guide/configuration) - Customize your PPanel setup
|
||||
- [Admin Dashboard](/admin/dashboard) - Start managing your panel
|
||||
- [API Reference](/api/reference) - Integrate with your applications
|
||||
|
||||
## Need Help?
|
||||
|
||||
- Check [GitHub Issues](https://github.com/perfect-panel/ppanel/issues)
|
||||
- Review installation logs
|
||||
- Join our community for support
|
||||
216
docs/public/scripts/en/install-docker.sh
Executable file
216
docs/public/scripts/en/install-docker.sh
Executable file
@ -0,0 +1,216 @@
|
||||
#!/bin/bash
|
||||
|
||||
#######################################################
|
||||
# Docker & Docker Compose Installation Script
|
||||
# Support: Ubuntu/Debian, CentOS/RHEL
|
||||
# Usage: curl -fsSL https://ppanel.dev/scripts/en/install-docker.sh | bash
|
||||
#######################################################
|
||||
|
||||
set -e
|
||||
|
||||
# 颜色输出
|
||||
RED='\033[0;31m'
|
||||
GREEN='\033[0;32m'
|
||||
YELLOW='\033[1;33m'
|
||||
NC='\033[0m' # No Color
|
||||
|
||||
# 日志函数
|
||||
log_info() {
|
||||
echo -e "${GREEN}[INFO]${NC} $1"
|
||||
}
|
||||
|
||||
log_warn() {
|
||||
echo -e "${YELLOW}[WARN]${NC} $1"
|
||||
}
|
||||
|
||||
log_error() {
|
||||
echo -e "${RED}[ERROR]${NC} $1"
|
||||
}
|
||||
|
||||
# Check if running as root
|
||||
check_root() {
|
||||
if [[ $EUID -ne 0 ]]; then
|
||||
log_error "This script must be run with root privileges"
|
||||
log_info "Please use: sudo bash $0"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
# Detect operating system
|
||||
detect_os() {
|
||||
if [[ -f /etc/os-release ]]; then
|
||||
. /etc/os-release
|
||||
OS=$ID
|
||||
VER=$VERSION_ID
|
||||
else
|
||||
log_error "Unable to detect operating system"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
log_info "Detected system: $OS $VER"
|
||||
}
|
||||
|
||||
# Check if Docker is already installed
|
||||
check_docker_installed() {
|
||||
if command -v docker &> /dev/null; then
|
||||
DOCKER_VERSION=$(docker --version | cut -d ' ' -f3 | cut -d ',' -f1)
|
||||
log_warn "Docker is already installed (Version: $DOCKER_VERSION)"
|
||||
read -p "Do you want to reinstall? (y/N): " -n 1 -r
|
||||
echo
|
||||
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
|
||||
log_info "Skipping Docker installation"
|
||||
return 0
|
||||
fi
|
||||
fi
|
||||
return 1
|
||||
}
|
||||
|
||||
# Install Docker - Ubuntu/Debian
|
||||
install_docker_debian() {
|
||||
log_info "Installing Docker on Ubuntu/Debian..."
|
||||
|
||||
# Update package index
|
||||
apt-get update
|
||||
|
||||
# Install dependencies
|
||||
apt-get install -y \
|
||||
ca-certificates \
|
||||
curl \
|
||||
gnupg \
|
||||
lsb-release
|
||||
|
||||
# Add Docker's official GPG key
|
||||
install -m 0755 -d /etc/apt/keyrings
|
||||
curl -fsSL https://download.docker.com/linux/$OS/gpg | gpg --dearmor -o /etc/apt/keyrings/docker.gpg
|
||||
chmod a+r /etc/apt/keyrings/docker.gpg
|
||||
|
||||
# Set up repository
|
||||
echo \
|
||||
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/$OS \
|
||||
$(lsb_release -cs) stable" | tee /etc/apt/sources.list.d/docker.list > /dev/null
|
||||
|
||||
# Install Docker Engine
|
||||
apt-get update
|
||||
apt-get install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
|
||||
|
||||
log_info "Docker installation completed"
|
||||
}
|
||||
|
||||
# Install Docker - CentOS/RHEL
|
||||
install_docker_centos() {
|
||||
log_info "Installing Docker on CentOS/RHEL..."
|
||||
|
||||
# Install yum-utils
|
||||
yum install -y yum-utils
|
||||
|
||||
# Add Docker repository
|
||||
yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
|
||||
|
||||
# Install Docker Engine
|
||||
yum install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
|
||||
|
||||
log_info "Docker installation completed"
|
||||
}
|
||||
|
||||
# Start Docker service
|
||||
start_docker() {
|
||||
log_info "Starting Docker service..."
|
||||
|
||||
systemctl start docker
|
||||
systemctl enable docker
|
||||
|
||||
log_info "Docker service started and enabled at boot"
|
||||
}
|
||||
|
||||
# Configure Docker group (optional)
|
||||
configure_docker_group() {
|
||||
log_info "Configuring Docker group..."
|
||||
|
||||
if ! getent group docker > /dev/null; then
|
||||
groupadd docker
|
||||
fi
|
||||
|
||||
if [[ -n "$SUDO_USER" ]]; then
|
||||
usermod -aG docker "$SUDO_USER"
|
||||
log_info "User $SUDO_USER has been added to docker group"
|
||||
log_warn "Please log out and log back in for group permissions to take effect"
|
||||
fi
|
||||
}
|
||||
|
||||
# Verify installation
|
||||
verify_installation() {
|
||||
log_info "Verifying Docker installation..."
|
||||
|
||||
# Check Docker version
|
||||
if docker --version &> /dev/null; then
|
||||
DOCKER_VERSION=$(docker --version)
|
||||
log_info "✓ $DOCKER_VERSION"
|
||||
else
|
||||
log_error "Docker installation failed"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Check Docker Compose version
|
||||
if docker compose version &> /dev/null; then
|
||||
COMPOSE_VERSION=$(docker compose version)
|
||||
log_info "✓ $COMPOSE_VERSION"
|
||||
else
|
||||
log_error "Docker Compose installation failed"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Run test container
|
||||
log_info "Running test container..."
|
||||
if docker run --rm hello-world &> /dev/null; then
|
||||
log_info "✓ Docker is working correctly"
|
||||
else
|
||||
log_error "Docker test failed"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
# Main function
|
||||
main() {
|
||||
echo "========================================"
|
||||
echo " Docker & Docker Compose Installer"
|
||||
echo "========================================"
|
||||
echo ""
|
||||
|
||||
check_root
|
||||
detect_os
|
||||
|
||||
if check_docker_installed; then
|
||||
verify_installation
|
||||
exit 0
|
||||
fi
|
||||
|
||||
case $OS in
|
||||
ubuntu|debian)
|
||||
install_docker_debian
|
||||
;;
|
||||
centos|rhel|rocky|almalinux)
|
||||
install_docker_centos
|
||||
;;
|
||||
*)
|
||||
log_error "Unsupported operating system: $OS"
|
||||
log_info "Supported systems: Ubuntu, Debian, CentOS, RHEL, Rocky Linux, AlmaLinux"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
start_docker
|
||||
configure_docker_group
|
||||
verify_installation
|
||||
|
||||
echo ""
|
||||
log_info "========================================"
|
||||
log_info "Docker and Docker Compose installed successfully!"
|
||||
log_info "========================================"
|
||||
log_info "Docker version: $(docker --version)"
|
||||
log_info "Docker Compose version: $(docker compose version)"
|
||||
echo ""
|
||||
log_info "Next step: Install PPanel"
|
||||
log_info "Run: curl -fsSL https://ppanel.dev/scripts/en/install-ppanel.sh | bash"
|
||||
}
|
||||
|
||||
main "$@"
|
||||
415
docs/public/scripts/en/install-ppanel.sh
Executable file
415
docs/public/scripts/en/install-ppanel.sh
Executable file
@ -0,0 +1,415 @@
|
||||
#!/bin/bash
|
||||
|
||||
#######################################################
|
||||
# PPanel One-Click Installation Script
|
||||
# Support: Docker Compose Deployment
|
||||
# Usage: curl -fsSL https://ppanel.dev/scripts/en/install-ppanel.sh | bash
|
||||
#######################################################
|
||||
|
||||
set -e
|
||||
|
||||
# 颜色输出
|
||||
RED='\033[0;31m'
|
||||
GREEN='\033[0;32m'
|
||||
YELLOW='\033[1;33m'
|
||||
BLUE='\033[0;34m'
|
||||
NC='\033[0m' # No Color
|
||||
|
||||
# 配置变量
|
||||
INSTALL_DIR="${INSTALL_DIR:-$(pwd)/ppanel}"
|
||||
DOCKER_IMAGE="ppanel/ppanel:latest"
|
||||
CONTAINER_NAME="ppanel-service"
|
||||
HOST_PORT="${HOST_PORT:-8080}"
|
||||
|
||||
# 日志函数
|
||||
log_info() {
|
||||
echo -e "${GREEN}[INFO]${NC} $1"
|
||||
}
|
||||
|
||||
log_warn() {
|
||||
echo -e "${YELLOW}[WARN]${NC} $1"
|
||||
}
|
||||
|
||||
log_error() {
|
||||
echo -e "${RED}[ERROR]${NC} $1"
|
||||
}
|
||||
|
||||
log_step() {
|
||||
echo -e "${BLUE}[STEP]${NC} $1"
|
||||
}
|
||||
|
||||
# Check if Docker is installed
|
||||
check_docker() {
|
||||
if ! command -v docker &> /dev/null; then
|
||||
log_error "Docker is not installed"
|
||||
log_info "Please install Docker first:"
|
||||
log_info "curl -fsSL https://ppanel.dev/scripts/en/install-docker.sh | sudo bash"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if ! docker compose version &> /dev/null; then
|
||||
log_error "Docker Compose is not installed"
|
||||
log_info "Please install Docker Compose first"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
log_info "✓ Docker installed ($(docker --version))"
|
||||
log_info "✓ Docker Compose installed ($(docker compose version --short))"
|
||||
}
|
||||
|
||||
# Check if port is in use
|
||||
check_port() {
|
||||
if command -v netstat &> /dev/null; then
|
||||
if netstat -tuln | grep -q ":$HOST_PORT "; then
|
||||
log_error "Port $HOST_PORT is already in use"
|
||||
log_info "Please set another port: export HOST_PORT=8081"
|
||||
exit 1
|
||||
fi
|
||||
elif command -v ss &> /dev/null; then
|
||||
if ss -tuln | grep -q ":$HOST_PORT "; then
|
||||
log_error "Port $HOST_PORT is already in use"
|
||||
log_info "Please set another port: export HOST_PORT=8081"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
log_info "✓ Port $HOST_PORT is available"
|
||||
}
|
||||
|
||||
# Create installation directories
|
||||
create_directories() {
|
||||
log_step "Creating installation directories..."
|
||||
|
||||
mkdir -p "$INSTALL_DIR"/config
|
||||
# Set permissions to ensure container can read configuration files
|
||||
chmod -R 755 "$INSTALL_DIR"
|
||||
|
||||
log_info "✓ Directories created: $INSTALL_DIR"
|
||||
}
|
||||
|
||||
# 生成随机密钥
|
||||
generate_secret() {
|
||||
if command -v openssl &> /dev/null; then
|
||||
openssl rand -hex 32
|
||||
else
|
||||
cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 64 | head -n 1
|
||||
fi
|
||||
}
|
||||
|
||||
# Get user input
|
||||
get_user_input() {
|
||||
log_step "Configuring PPanel..."
|
||||
echo ""
|
||||
|
||||
# MySQL configuration
|
||||
MYSQL_USER="ppanel"
|
||||
MYSQL_PASSWORD=$(generate_secret | cut -c1-16)
|
||||
MYSQL_DB="ppanel"
|
||||
MYSQL_ROOT_PASSWORD=$(generate_secret | cut -c1-16)
|
||||
|
||||
log_info "✓ MySQL password generated"
|
||||
|
||||
# Redis configuration
|
||||
REDIS_PASS=$(generate_secret | cut -c1-16)
|
||||
|
||||
log_info "✓ Redis password generated"
|
||||
|
||||
# Generate JWT secret
|
||||
JWT_SECRET=$(generate_secret)
|
||||
log_info "✓ JWT secret generated"
|
||||
}
|
||||
|
||||
# Create configuration file
|
||||
create_config() {
|
||||
log_step "Creating configuration file..."
|
||||
|
||||
cat > "$INSTALL_DIR/config/ppanel.yaml" <<EOF
|
||||
Host: 0.0.0.0
|
||||
Port: 8080
|
||||
TLS:
|
||||
Enable: false
|
||||
CertFile: ""
|
||||
KeyFile: ""
|
||||
Debug: false
|
||||
|
||||
Static:
|
||||
Admin:
|
||||
Enabled: true
|
||||
Prefix: /admin
|
||||
Path: ./static/admin
|
||||
User:
|
||||
Enabled: true
|
||||
Prefix: /
|
||||
Path: ./static/user
|
||||
|
||||
JwtAuth:
|
||||
AccessSecret: $JWT_SECRET
|
||||
AccessExpire: 604800
|
||||
|
||||
Logger:
|
||||
ServiceName: ApiService
|
||||
Mode: console
|
||||
Encoding: plain
|
||||
TimeFormat: "2006-01-02 15:04:05.000"
|
||||
Path: logs
|
||||
Level: info
|
||||
MaxContentLength: 0
|
||||
Compress: false
|
||||
Stat: true
|
||||
KeepDays: 0
|
||||
StackCooldownMillis: 100
|
||||
MaxBackups: 0
|
||||
MaxSize: 0
|
||||
Rotation: daily
|
||||
FileTimeFormat: 2006-01-02T15:04:05.000Z07:00
|
||||
|
||||
MySQL:
|
||||
Addr: mysql:3306
|
||||
Username: $MYSQL_USER
|
||||
Password: $MYSQL_PASSWORD
|
||||
Dbname: $MYSQL_DB
|
||||
Config: charset=utf8mb4&parseTime=true&loc=Asia%2FShanghai
|
||||
MaxIdleConns: 10
|
||||
MaxOpenConns: 10
|
||||
SlowThreshold: 1000
|
||||
|
||||
Redis:
|
||||
Host: redis:6379
|
||||
Pass: $REDIS_PASS
|
||||
DB: 0
|
||||
EOF
|
||||
|
||||
log_info "✓ Configuration file created: $INSTALL_DIR/config/ppanel.yaml"
|
||||
# Create docker-compose.yml
|
||||
create_docker_compose() {
|
||||
log_step "Creating Docker Compose configuration..."
|
||||
|
||||
cat > "$INSTALL_DIR/docker-compose.yml" <<'COMPOSE_EOF'
|
||||
services:
|
||||
mysql:
|
||||
image: mysql:8.0
|
||||
container_name: ppanel-mysql
|
||||
restart: always
|
||||
environment:
|
||||
MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD}
|
||||
MYSQL_DATABASE: ${MYSQL_DB}
|
||||
MYSQL_USER: ${MYSQL_USER}
|
||||
MYSQL_PASSWORD: ${MYSQL_PASSWORD}
|
||||
TZ: Asia/Shanghai
|
||||
volumes:
|
||||
- mysql:/var/lib/mysql
|
||||
command: --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci
|
||||
healthcheck:
|
||||
test: [
|
||||
"CMD-SHELL",
|
||||
"mysqladmin ping -h localhost -u $$MYSQL_USER -p$$MYSQL_PASSWORD || exit 1"
|
||||
]
|
||||
interval: 5s
|
||||
timeout: 3s
|
||||
retries: 10
|
||||
start_period: 30s
|
||||
|
||||
redis:
|
||||
image: redis:7-alpine
|
||||
container_name: ppanel-redis
|
||||
restart: always
|
||||
command: redis-server --requirepass ${REDIS_PASS} --appendonly yes
|
||||
volumes:
|
||||
- redis:/data
|
||||
healthcheck:
|
||||
test: ["CMD", "redis-cli", "--raw", "incr", "ping"]
|
||||
interval: 10s
|
||||
timeout: 3s
|
||||
retries: 5
|
||||
|
||||
ppanel-service:
|
||||
image: ${DOCKER_IMAGE}
|
||||
container_name: ${CONTAINER_NAME}
|
||||
restart: always
|
||||
ports:
|
||||
- "${HOST_PORT}:8080"
|
||||
volumes:
|
||||
- ./config:/app/etc:ro
|
||||
depends_on:
|
||||
mysql:
|
||||
condition: service_healthy
|
||||
redis:
|
||||
condition: service_healthy
|
||||
|
||||
volumes:
|
||||
mysql:
|
||||
redis:
|
||||
COMPOSE_EOF
|
||||
|
||||
log_info "✓ Docker Compose configuration created"
|
||||
|
||||
# Create .env file
|
||||
cat > "$INSTALL_DIR/.env" <<ENV_EOF
|
||||
MYSQL_ROOT_PASSWORD=$MYSQL_ROOT_PASSWORD
|
||||
MYSQL_DB=$MYSQL_DB
|
||||
MYSQL_USER=$MYSQL_USER
|
||||
MYSQL_PASSWORD=$MYSQL_PASSWORD
|
||||
REDIS_PASS=$REDIS_PASS
|
||||
DOCKER_IMAGE=$DOCKER_IMAGE
|
||||
CONTAINER_NAME=$CONTAINER_NAME
|
||||
HOST_PORT=$HOST_PORT
|
||||
ENV_EOF
|
||||
|
||||
log_info "✓ Environment variables file created"
|
||||
}
|
||||
|
||||
# Pull Docker image
|
||||
pull_image() {
|
||||
log_step "Pulling Docker image..."
|
||||
|
||||
cd "$INSTALL_DIR"
|
||||
docker compose pull
|
||||
|
||||
log_info "✓ Image pulled successfully"
|
||||
}
|
||||
|
||||
# Start service
|
||||
start_service() {
|
||||
log_step "Starting PPanel service..."
|
||||
|
||||
cd "$INSTALL_DIR"
|
||||
docker compose up -d
|
||||
|
||||
log_info "✓ Service started"
|
||||
}
|
||||
|
||||
# Wait for service to be ready
|
||||
wait_for_service() {
|
||||
log_step "Waiting for service to be ready..."
|
||||
|
||||
local max_attempts=30
|
||||
local attempt=0
|
||||
|
||||
while [[ $attempt -lt $max_attempts ]]; do
|
||||
if command -v curl &> /dev/null; then
|
||||
if curl -s "http://localhost:$HOST_PORT" &> /dev/null; then
|
||||
log_info "✓ Service is ready"
|
||||
return 0
|
||||
fi
|
||||
elif command -v wget &> /dev/null; then
|
||||
if wget --quiet --tries=1 --spider "http://localhost:$HOST_PORT" &> /dev/null; then
|
||||
log_info "✓ Service is ready"
|
||||
return 0
|
||||
fi
|
||||
else
|
||||
# If neither curl nor wget is available, check container health directly
|
||||
if docker inspect ppanel-service --format='{{.State.Health.Status}}' 2>/dev/null | grep -q "healthy"; then
|
||||
log_info "✓ Service is ready"
|
||||
return 0
|
||||
fi
|
||||
fi
|
||||
|
||||
attempt=$((attempt + 1))
|
||||
echo -n "."
|
||||
sleep 2
|
||||
done
|
||||
|
||||
echo ""
|
||||
log_warn "Service startup timeout, please check logs"
|
||||
log_info "View logs: cd $INSTALL_DIR && docker compose logs -f"
|
||||
}
|
||||
|
||||
# Show access information
|
||||
show_access_info() {
|
||||
local internal_ip
|
||||
local public_ip
|
||||
|
||||
# Get internal IP
|
||||
internal_ip=$(hostname -I | awk '{print $1}')
|
||||
|
||||
# Get public IP
|
||||
public_ip=$(curl -s --max-time 5 https://api.ipify.org 2>/dev/null || curl -s --max-time 5 https://ifconfig.me 2>/dev/null || echo "Unable to get")
|
||||
|
||||
echo ""
|
||||
echo "========================================"
|
||||
log_info "PPanel installation completed!"
|
||||
echo "========================================"
|
||||
echo ""
|
||||
log_info "Access URLs:"
|
||||
echo " Internal Access (LAN):"
|
||||
echo " User Panel: http://$internal_ip:$HOST_PORT"
|
||||
echo " Admin Panel: http://$internal_ip:$HOST_PORT/admin/"
|
||||
echo ""
|
||||
if [[ "$public_ip" != "Unable to get" ]]; then
|
||||
echo " Public Access (Internet):"
|
||||
echo " User Panel: http://$public_ip:$HOST_PORT"
|
||||
echo " Admin Panel: http://$public_ip:$HOST_PORT/admin/"
|
||||
echo ""
|
||||
log_warn "Note: Public access requires firewall and router port forwarding configuration"
|
||||
else
|
||||
log_warn "Unable to get public IP, please configure manually for public access"
|
||||
fi
|
||||
echo ""
|
||||
log_info "Database Information:"
|
||||
echo " MySQL (Container Network):"
|
||||
echo " Address: mysql:3306"
|
||||
echo " User: $MYSQL_USER"
|
||||
echo " Password: $MYSQL_PASSWORD"
|
||||
echo " Database: $MYSQL_DB"
|
||||
echo " Root Password: $MYSQL_ROOT_PASSWORD"
|
||||
echo ""
|
||||
echo " Redis (Container Network):"
|
||||
echo " Address: redis:6379"
|
||||
echo " Password: $REDIS_PASS"
|
||||
echo ""
|
||||
log_warn "Note: MySQL and Redis are only accessible within the container network"
|
||||
echo " To access from host, edit docker-compose.yml to add port mappings"
|
||||
echo ""
|
||||
log_info "Installation directory: $INSTALL_DIR"
|
||||
echo ""
|
||||
log_info "Common commands:"
|
||||
echo " Check status: cd $INSTALL_DIR && docker compose ps"
|
||||
echo " View logs: cd $INSTALL_DIR && docker compose logs -f"
|
||||
echo " Restart: cd $INSTALL_DIR && docker compose restart"
|
||||
echo " Stop: cd $INSTALL_DIR && docker compose stop"
|
||||
echo " Start: cd $INSTALL_DIR && docker compose start"
|
||||
echo ""
|
||||
log_warn "Important reminders:"
|
||||
echo " 1. Please keep database password information safe"
|
||||
echo " 2. Please login to admin panel and change the default password"
|
||||
echo " 3. Configure firewall rules to restrict access"
|
||||
echo " 4. Configure reverse proxy and HTTPS for production"
|
||||
echo " 5. Backup database regularly: docker exec ppanel-mysql mysqldump -u root -p$MYSQL_ROOT_PASSWORD $MYSQL_DB > backup.sql"
|
||||
echo ""
|
||||
}
|
||||
|
||||
# Show firewall configuration info
|
||||
show_firewall_info() {
|
||||
if command -v ufw &> /dev/null; then
|
||||
log_info "Ubuntu/Debian firewall configuration:"
|
||||
echo " sudo ufw allow $HOST_PORT/tcp"
|
||||
echo " sudo ufw status"
|
||||
echo ""
|
||||
elif command -v firewall-cmd &> /dev/null; then
|
||||
log_info "CentOS/RHEL firewall configuration:"
|
||||
echo " sudo firewall-cmd --permanent --add-port=$HOST_PORT/tcp"
|
||||
echo " sudo firewall-cmd --reload"
|
||||
echo ""
|
||||
fi
|
||||
}
|
||||
|
||||
# Main function
|
||||
main() {
|
||||
echo "========================================"
|
||||
echo " PPanel One-Click Installer"
|
||||
echo "========================================"
|
||||
echo ""
|
||||
|
||||
check_docker
|
||||
check_port
|
||||
create_directories
|
||||
get_user_input
|
||||
create_config
|
||||
create_docker_compose
|
||||
pull_image
|
||||
start_service
|
||||
wait_for_service
|
||||
show_access_info
|
||||
show_firewall_info
|
||||
}
|
||||
|
||||
main "$@"
|
||||
216
docs/public/scripts/zh/install-docker.sh
Executable file
216
docs/public/scripts/zh/install-docker.sh
Executable file
@ -0,0 +1,216 @@
|
||||
#!/bin/bash
|
||||
|
||||
#######################################################
|
||||
# Docker & Docker Compose 安装脚本
|
||||
# 支持: Ubuntu/Debian, CentOS/RHEL
|
||||
# 用法: curl -fsSL https://ppanel.dev/scripts/zh/install-docker.sh | bash
|
||||
#######################################################
|
||||
|
||||
set -e
|
||||
|
||||
# 颜色输出
|
||||
RED='\033[0;31m'
|
||||
GREEN='\033[0;32m'
|
||||
YELLOW='\033[1;33m'
|
||||
NC='\033[0m' # No Color
|
||||
|
||||
# 日志函数
|
||||
log_info() {
|
||||
echo -e "${GREEN}[INFO]${NC} $1"
|
||||
}
|
||||
|
||||
log_warn() {
|
||||
echo -e "${YELLOW}[WARN]${NC} $1"
|
||||
}
|
||||
|
||||
log_error() {
|
||||
echo -e "${RED}[ERROR]${NC} $1"
|
||||
}
|
||||
|
||||
# 检查是否为 root 用户
|
||||
check_root() {
|
||||
if [[ $EUID -ne 0 ]]; then
|
||||
log_error "此脚本必须以 root 权限运行"
|
||||
log_info "请使用: sudo bash $0"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
# 检测系统类型
|
||||
detect_os() {
|
||||
if [[ -f /etc/os-release ]]; then
|
||||
. /etc/os-release
|
||||
OS=$ID
|
||||
VER=$VERSION_ID
|
||||
else
|
||||
log_error "无法检测操作系统类型"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
log_info "检测到系统: $OS $VER"
|
||||
}
|
||||
|
||||
# 检查 Docker 是否已安装
|
||||
check_docker_installed() {
|
||||
if command -v docker &> /dev/null; then
|
||||
DOCKER_VERSION=$(docker --version | cut -d ' ' -f3 | cut -d ',' -f1)
|
||||
log_warn "Docker 已安装 (版本: $DOCKER_VERSION)"
|
||||
read -p "是否重新安装? (y/N): " -n 1 -r
|
||||
echo
|
||||
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
|
||||
log_info "跳过 Docker 安装"
|
||||
return 0
|
||||
fi
|
||||
fi
|
||||
return 1
|
||||
}
|
||||
|
||||
# 安装 Docker - Ubuntu/Debian
|
||||
install_docker_debian() {
|
||||
log_info "开始在 Ubuntu/Debian 上安装 Docker..."
|
||||
|
||||
# 更新包索引
|
||||
apt-get update
|
||||
|
||||
# 安装依赖
|
||||
apt-get install -y \
|
||||
ca-certificates \
|
||||
curl \
|
||||
gnupg \
|
||||
lsb-release
|
||||
|
||||
# 添加 Docker 官方 GPG 密钥
|
||||
install -m 0755 -d /etc/apt/keyrings
|
||||
curl -fsSL https://download.docker.com/linux/$OS/gpg | gpg --dearmor -o /etc/apt/keyrings/docker.gpg
|
||||
chmod a+r /etc/apt/keyrings/docker.gpg
|
||||
|
||||
# 设置仓库
|
||||
echo \
|
||||
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/$OS \
|
||||
$(lsb_release -cs) stable" | tee /etc/apt/sources.list.d/docker.list > /dev/null
|
||||
|
||||
# 安装 Docker Engine
|
||||
apt-get update
|
||||
apt-get install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
|
||||
|
||||
log_info "Docker 安装完成"
|
||||
}
|
||||
|
||||
# 安装 Docker - CentOS/RHEL
|
||||
install_docker_centos() {
|
||||
log_info "开始在 CentOS/RHEL 上安装 Docker..."
|
||||
|
||||
# 安装 yum-utils
|
||||
yum install -y yum-utils
|
||||
|
||||
# 添加 Docker 仓库
|
||||
yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
|
||||
|
||||
# 安装 Docker Engine
|
||||
yum install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
|
||||
|
||||
log_info "Docker 安装完成"
|
||||
}
|
||||
|
||||
# 启动 Docker 服务
|
||||
start_docker() {
|
||||
log_info "启动 Docker 服务..."
|
||||
|
||||
systemctl start docker
|
||||
systemctl enable docker
|
||||
|
||||
log_info "Docker 服务已启动并设置为开机自启"
|
||||
}
|
||||
|
||||
# 配置 Docker 用户组(可选)
|
||||
configure_docker_group() {
|
||||
log_info "配置 Docker 用户组..."
|
||||
|
||||
if ! getent group docker > /dev/null; then
|
||||
groupadd docker
|
||||
fi
|
||||
|
||||
if [[ -n "$SUDO_USER" ]]; then
|
||||
usermod -aG docker "$SUDO_USER"
|
||||
log_info "用户 $SUDO_USER 已添加到 docker 组"
|
||||
log_warn "请注销并重新登录以使组权限生效"
|
||||
fi
|
||||
}
|
||||
|
||||
# 验证安装
|
||||
verify_installation() {
|
||||
log_info "验证 Docker 安装..."
|
||||
|
||||
# 检查 Docker 版本
|
||||
if docker --version &> /dev/null; then
|
||||
DOCKER_VERSION=$(docker --version)
|
||||
log_info "✓ $DOCKER_VERSION"
|
||||
else
|
||||
log_error "Docker 安装失败"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# 检查 Docker Compose 版本
|
||||
if docker compose version &> /dev/null; then
|
||||
COMPOSE_VERSION=$(docker compose version)
|
||||
log_info "✓ $COMPOSE_VERSION"
|
||||
else
|
||||
log_error "Docker Compose 安装失败"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# 运行测试容器
|
||||
log_info "运行测试容器..."
|
||||
if docker run --rm hello-world &> /dev/null; then
|
||||
log_info "✓ Docker 运行正常"
|
||||
else
|
||||
log_error "Docker 运行测试失败"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
# 主函数
|
||||
main() {
|
||||
echo "========================================"
|
||||
echo " Docker & Docker Compose 安装脚本"
|
||||
echo "========================================"
|
||||
echo ""
|
||||
|
||||
check_root
|
||||
detect_os
|
||||
|
||||
if check_docker_installed; then
|
||||
verify_installation
|
||||
exit 0
|
||||
fi
|
||||
|
||||
case $OS in
|
||||
ubuntu|debian)
|
||||
install_docker_debian
|
||||
;;
|
||||
centos|rhel|rocky|almalinux)
|
||||
install_docker_centos
|
||||
;;
|
||||
*)
|
||||
log_error "不支持的操作系统: $OS"
|
||||
log_info "支持的系统: Ubuntu, Debian, CentOS, RHEL, Rocky Linux, AlmaLinux"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
start_docker
|
||||
configure_docker_group
|
||||
verify_installation
|
||||
|
||||
echo ""
|
||||
log_info "========================================"
|
||||
log_info "Docker 和 Docker Compose 安装完成!"
|
||||
log_info "========================================"
|
||||
log_info "Docker 版本: $(docker --version)"
|
||||
log_info "Docker Compose 版本: $(docker compose version)"
|
||||
echo ""
|
||||
log_info "下一步: 安装 PPanel"
|
||||
log_info "运行: curl -fsSL https://ppanel.dev/scripts/install-ppanel.sh | bash"
|
||||
}
|
||||
|
||||
main "$@"
|
||||
417
docs/public/scripts/zh/install-ppanel.sh
Executable file
417
docs/public/scripts/zh/install-ppanel.sh
Executable file
@ -0,0 +1,417 @@
|
||||
#!/bin/bash
|
||||
|
||||
#######################################################
|
||||
# PPanel 一键安装脚本
|
||||
# 支持: Docker Compose 部署
|
||||
# 用法: curl -fsSL https://ppanel.dev/scripts/zh/install-ppanel.sh | bash
|
||||
#######################################################
|
||||
|
||||
set -e
|
||||
|
||||
# 颜色输出
|
||||
RED='\033[0;31m'
|
||||
GREEN='\033[0;32m'
|
||||
YELLOW='\033[1;33m'
|
||||
BLUE='\033[0;34m'
|
||||
NC='\033[0m' # No Color
|
||||
|
||||
# 配置变量
|
||||
INSTALL_DIR="${INSTALL_DIR:-$(pwd)/ppanel}"
|
||||
DOCKER_IMAGE="ppanel/ppanel:latest"
|
||||
CONTAINER_NAME="ppanel-service"
|
||||
HOST_PORT="${HOST_PORT:-8080}"
|
||||
|
||||
# 日志函数
|
||||
log_info() {
|
||||
echo -e "${GREEN}[INFO]${NC} $1"
|
||||
}
|
||||
|
||||
log_warn() {
|
||||
echo -e "${YELLOW}[WARN]${NC} $1"
|
||||
}
|
||||
|
||||
log_error() {
|
||||
echo -e "${RED}[ERROR]${NC} $1"
|
||||
}
|
||||
|
||||
log_step() {
|
||||
echo -e "${BLUE}[STEP]${NC} $1"
|
||||
}
|
||||
|
||||
# 检查 Docker 是否已安装
|
||||
check_docker() {
|
||||
if ! command -v docker &> /dev/null; then
|
||||
log_error "Docker 未安装"
|
||||
log_info "请先安装 Docker:"
|
||||
log_info "curl -fsSL https://ppanel.dev/scripts/install-docker.sh | sudo bash"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if ! docker compose version &> /dev/null; then
|
||||
log_error "Docker Compose 未安装"
|
||||
log_info "请先安装 Docker Compose"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
log_info "✓ Docker 已安装 ($(docker --version))"
|
||||
log_info "✓ Docker Compose 已安装 ($(docker compose version --short))"
|
||||
}
|
||||
|
||||
# 检查端口是否被占用
|
||||
check_port() {
|
||||
if command -v netstat &> /dev/null; then
|
||||
if netstat -tuln | grep -q ":$HOST_PORT "; then
|
||||
log_error "端口 $HOST_PORT 已被占用"
|
||||
log_info "请设置其他端口: export HOST_PORT=8081"
|
||||
exit 1
|
||||
fi
|
||||
elif command -v ss &> /dev/null; then
|
||||
if ss -tuln | grep -q ":$HOST_PORT "; then
|
||||
log_error "端口 $HOST_PORT 已被占用"
|
||||
log_info "请设置其他端口: export HOST_PORT=8081"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
log_info "✓ 端口 $HOST_PORT 可用"
|
||||
}
|
||||
|
||||
# 创建安装目录
|
||||
create_directories() {
|
||||
log_step "创建安装目录..."
|
||||
|
||||
mkdir -p "$INSTALL_DIR"/config
|
||||
# 设置权限确保容器可以读取配置文件
|
||||
chmod -R 755 "$INSTALL_DIR"
|
||||
|
||||
log_info "✓ 目录已创建: $INSTALL_DIR"
|
||||
}
|
||||
|
||||
# 生成随机密钥
|
||||
generate_secret() {
|
||||
if command -v openssl &> /dev/null; then
|
||||
openssl rand -hex 32
|
||||
else
|
||||
cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 64 | head -n 1
|
||||
fi
|
||||
}
|
||||
|
||||
# 获取用户输入
|
||||
get_user_input() {
|
||||
log_step "配置 PPanel..."
|
||||
echo ""
|
||||
|
||||
# MySQL 配置
|
||||
MYSQL_USER="ppanel"
|
||||
MYSQL_PASSWORD=$(generate_secret | cut -c1-16)
|
||||
MYSQL_DB="ppanel"
|
||||
MYSQL_ROOT_PASSWORD=$(generate_secret | cut -c1-16)
|
||||
|
||||
log_info "✓ 已生成 MySQL 密码"
|
||||
|
||||
# Redis 配置
|
||||
REDIS_PASS=$(generate_secret | cut -c1-16)
|
||||
|
||||
log_info "✓ 已生成 Redis 密码"
|
||||
|
||||
# 生成 JWT 密钥
|
||||
JWT_SECRET=$(generate_secret)
|
||||
log_info "✓ 已生成 JWT 密钥"
|
||||
}
|
||||
|
||||
# 创建配置文件
|
||||
create_config() {
|
||||
log_step "创建配置文件..."
|
||||
|
||||
cat > "$INSTALL_DIR/config/ppanel.yaml" <<EOF
|
||||
Host: 0.0.0.0
|
||||
Port: 8080
|
||||
TLS:
|
||||
Enable: false
|
||||
CertFile: ""
|
||||
KeyFile: ""
|
||||
Debug: false
|
||||
|
||||
Static:
|
||||
Admin:
|
||||
Enabled: true
|
||||
Prefix: /admin
|
||||
Path: ./static/admin
|
||||
User:
|
||||
Enabled: true
|
||||
Prefix: /
|
||||
Path: ./static/user
|
||||
|
||||
JwtAuth:
|
||||
AccessSecret: $JWT_SECRET
|
||||
AccessExpire: 604800
|
||||
|
||||
Logger:
|
||||
ServiceName: ApiService
|
||||
Mode: console
|
||||
Encoding: plain
|
||||
TimeFormat: "2006-01-02 15:04:05.000"
|
||||
Path: logs
|
||||
Level: info
|
||||
MaxContentLength: 0
|
||||
Compress: false
|
||||
Stat: true
|
||||
KeepDays: 0
|
||||
StackCooldownMillis: 100
|
||||
MaxBackups: 0
|
||||
MaxSize: 0
|
||||
Rotation: daily
|
||||
FileTimeFormat: 2006-01-02T15:04:05.000Z07:00
|
||||
|
||||
MySQL:
|
||||
Addr: mysql:3306
|
||||
Username: $MYSQL_USER
|
||||
Password: $MYSQL_PASSWORD
|
||||
Dbname: $MYSQL_DB
|
||||
Config: charset=utf8mb4&parseTime=true&loc=Asia%2FShanghai
|
||||
MaxIdleConns: 10
|
||||
MaxOpenConns: 10
|
||||
SlowThreshold: 1000
|
||||
|
||||
Redis:
|
||||
Host: redis:6379
|
||||
Pass: $REDIS_PASS
|
||||
DB: 0
|
||||
EOF
|
||||
|
||||
log_info "✓ 配置文件已创建: $INSTALL_DIR/config/ppanel.yaml"
|
||||
}
|
||||
|
||||
# 创建 docker-compose.yml
|
||||
create_docker_compose() {
|
||||
log_step "创建 Docker Compose 配置..."
|
||||
|
||||
cat > "$INSTALL_DIR/docker-compose.yml" <<'COMPOSE_EOF'
|
||||
services:
|
||||
mysql:
|
||||
image: mysql:8.0
|
||||
container_name: ppanel-mysql
|
||||
restart: always
|
||||
environment:
|
||||
MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD}
|
||||
MYSQL_DATABASE: ${MYSQL_DB}
|
||||
MYSQL_USER: ${MYSQL_USER}
|
||||
MYSQL_PASSWORD: ${MYSQL_PASSWORD}
|
||||
TZ: Asia/Shanghai
|
||||
volumes:
|
||||
- mysql:/var/lib/mysql
|
||||
command: --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci
|
||||
healthcheck:
|
||||
test: [
|
||||
"CMD-SHELL",
|
||||
"mysqladmin ping -h localhost -u $$MYSQL_USER -p$$MYSQL_PASSWORD || exit 1"
|
||||
]
|
||||
interval: 5s
|
||||
timeout: 3s
|
||||
retries: 10
|
||||
start_period: 30s
|
||||
|
||||
redis:
|
||||
image: redis:7-alpine
|
||||
container_name: ppanel-redis
|
||||
restart: always
|
||||
command: redis-server --requirepass ${REDIS_PASS} --appendonly yes
|
||||
volumes:
|
||||
- redis:/data
|
||||
healthcheck:
|
||||
test: ["CMD", "redis-cli", "--raw", "incr", "ping"]
|
||||
interval: 10s
|
||||
timeout: 3s
|
||||
retries: 5
|
||||
|
||||
ppanel-service:
|
||||
image: ${DOCKER_IMAGE}
|
||||
container_name: ${CONTAINER_NAME}
|
||||
restart: always
|
||||
ports:
|
||||
- "${HOST_PORT}:8080"
|
||||
volumes:
|
||||
- ./config:/app/etc:ro
|
||||
depends_on:
|
||||
mysql:
|
||||
condition: service_healthy
|
||||
redis:
|
||||
condition: service_healthy
|
||||
|
||||
volumes:
|
||||
mysql:
|
||||
redis:
|
||||
COMPOSE_EOF
|
||||
|
||||
log_info "✓ Docker Compose 配置已创建"
|
||||
|
||||
# 创建 .env 文件
|
||||
cat > "$INSTALL_DIR/.env" <<ENV_EOF
|
||||
MYSQL_ROOT_PASSWORD=$MYSQL_ROOT_PASSWORD
|
||||
MYSQL_DB=$MYSQL_DB
|
||||
MYSQL_USER=$MYSQL_USER
|
||||
MYSQL_PASSWORD=$MYSQL_PASSWORD
|
||||
REDIS_PASS=$REDIS_PASS
|
||||
DOCKER_IMAGE=$DOCKER_IMAGE
|
||||
CONTAINER_NAME=$CONTAINER_NAME
|
||||
HOST_PORT=$HOST_PORT
|
||||
ENV_EOF
|
||||
|
||||
log_info "✓ 环境变量文件已创建"
|
||||
}
|
||||
|
||||
# 拉取 Docker 镜像
|
||||
pull_image() {
|
||||
log_step "拉取 Docker 镜像..."
|
||||
|
||||
cd "$INSTALL_DIR"
|
||||
docker compose pull
|
||||
|
||||
log_info "✓ 镜像拉取完成"
|
||||
}
|
||||
|
||||
# 启动服务
|
||||
start_service() {
|
||||
log_step "启动 PPanel 服务..."
|
||||
|
||||
cd "$INSTALL_DIR"
|
||||
docker compose up -d
|
||||
|
||||
log_info "✓ 服务已启动"
|
||||
}
|
||||
|
||||
# 等待服务就绪
|
||||
wait_for_service() {
|
||||
log_step "等待服务就绪..."
|
||||
|
||||
local max_attempts=30
|
||||
local attempt=0
|
||||
|
||||
while [[ $attempt -lt $max_attempts ]]; do
|
||||
if command -v curl &> /dev/null; then
|
||||
if curl -s "http://localhost:$HOST_PORT" &> /dev/null; then
|
||||
log_info "✓ 服务已就绪"
|
||||
return 0
|
||||
fi
|
||||
elif command -v wget &> /dev/null; then
|
||||
if wget --quiet --tries=1 --spider "http://localhost:$HOST_PORT" &> /dev/null; then
|
||||
log_info "✓ 服务已就绪"
|
||||
return 0
|
||||
fi
|
||||
else
|
||||
# 如果 curl 和 wget 都不可用,直接检查容器状态
|
||||
if docker inspect ppanel-service --format='{{.State.Health.Status}}' 2>/dev/null | grep -q "healthy"; then
|
||||
log_info "✓ 服务已就绪"
|
||||
return 0
|
||||
fi
|
||||
fi
|
||||
|
||||
attempt=$((attempt + 1))
|
||||
echo -n "."
|
||||
sleep 2
|
||||
done
|
||||
|
||||
echo ""
|
||||
log_warn "服务启动超时,请检查日志"
|
||||
log_info "查看日志: cd $INSTALL_DIR && docker compose logs -f"
|
||||
}
|
||||
|
||||
# 显示访问信息
|
||||
show_access_info() {
|
||||
local internal_ip
|
||||
local public_ip
|
||||
|
||||
# 获取内网IP
|
||||
internal_ip=$(hostname -I | awk '{print $1}')
|
||||
|
||||
# 获取外网IP
|
||||
public_ip=$(curl -s --max-time 5 https://api.ipify.org 2>/dev/null || curl -s --max-time 5 https://ifconfig.me 2>/dev/null || echo "无法获取")
|
||||
|
||||
echo ""
|
||||
echo "========================================"
|
||||
log_info "PPanel 安装完成!"
|
||||
echo "========================================"
|
||||
echo ""
|
||||
log_info "访问地址:"
|
||||
echo " 内网访问 (局域网):"
|
||||
echo " 用户面板: http://$internal_ip:$HOST_PORT"
|
||||
echo " 管理后台: http://$internal_ip:$HOST_PORT/admin/"
|
||||
echo ""
|
||||
if [[ "$public_ip" != "无法获取" ]]; then
|
||||
echo " 外网访问 (公网):"
|
||||
echo " 用户面板: http://$public_ip:$HOST_PORT"
|
||||
echo " 管理后台: http://$public_ip:$HOST_PORT/admin/"
|
||||
echo ""
|
||||
log_warn "注意: 外网访问需要配置防火墙和路由器端口转发"
|
||||
else
|
||||
log_warn "未能获取公网IP,如需外网访问请手动配置"
|
||||
fi
|
||||
echo ""
|
||||
log_info "数据库信息:"
|
||||
echo " MySQL (容器间通信):"
|
||||
echo " 地址: mysql:3306"
|
||||
echo " 用户: $MYSQL_USER"
|
||||
echo " 密码: $MYSQL_PASSWORD"
|
||||
echo " 数据库: $MYSQL_DB"
|
||||
echo " Root 密码: $MYSQL_ROOT_PASSWORD"
|
||||
echo ""
|
||||
echo " Redis (容器间通信):"
|
||||
echo " 地址: redis:6379"
|
||||
echo " 密码: $REDIS_PASS"
|
||||
echo ""
|
||||
log_warn "注意: MySQL 和 Redis 仅在容器网络内可访问,未暴露到宿主机"
|
||||
echo " 如需从宿主机访问,请编辑 docker-compose.yml 添加端口映射"
|
||||
echo ""
|
||||
log_info "安装目录: $INSTALL_DIR"
|
||||
echo ""
|
||||
log_info "常用命令:"
|
||||
echo " 查看状态: cd $INSTALL_DIR && docker compose ps"
|
||||
echo " 查看日志: cd $INSTALL_DIR && docker compose logs -f"
|
||||
echo " 重启服务: cd $INSTALL_DIR && docker compose restart"
|
||||
echo " 停止服务: cd $INSTALL_DIR && docker compose stop"
|
||||
echo " 启动服务: cd $INSTALL_DIR && docker compose start"
|
||||
echo ""
|
||||
log_warn "重要提示:"
|
||||
echo " 1. 请妥善保管数据库密码信息"
|
||||
echo " 2. 请及时登录管理后台修改默认密码"
|
||||
echo " 3. 建议配置防火墙规则限制访问"
|
||||
echo " 4. 生产环境请配置反向代理和 HTTPS"
|
||||
echo " 5. 定期备份数据库: docker exec ppanel-mysql mysqldump -u root -p$MYSQL_ROOT_PASSWORD $MYSQL_DB > backup.sql"
|
||||
echo ""
|
||||
}
|
||||
|
||||
# 配置防火墙提示
|
||||
show_firewall_info() {
|
||||
if command -v ufw &> /dev/null; then
|
||||
log_info "Ubuntu/Debian 防火墙配置:"
|
||||
echo " sudo ufw allow $HOST_PORT/tcp"
|
||||
echo " sudo ufw status"
|
||||
echo ""
|
||||
elif command -v firewall-cmd &> /dev/null; then
|
||||
log_info "CentOS/RHEL 防火墙配置:"
|
||||
echo " sudo firewall-cmd --permanent --add-port=$HOST_PORT/tcp"
|
||||
echo " sudo firewall-cmd --reload"
|
||||
echo ""
|
||||
fi
|
||||
}
|
||||
|
||||
# 主函数
|
||||
main() {
|
||||
echo "========================================"
|
||||
echo " PPanel 一键安装脚本"
|
||||
echo "========================================"
|
||||
echo ""
|
||||
|
||||
check_docker
|
||||
check_port
|
||||
create_directories
|
||||
get_user_input
|
||||
create_config
|
||||
create_docker_compose
|
||||
pull_image
|
||||
start_service
|
||||
wait_for_service
|
||||
show_access_info
|
||||
show_firewall_info
|
||||
}
|
||||
|
||||
main "$@"
|
||||
@ -23,19 +23,29 @@ uname -m
|
||||
|
||||
访问 [GitHub Releases](https://github.com/perfect-panel/ppanel/releases) 页面或直接下载:
|
||||
|
||||
::: tip 安装目录
|
||||
你可以将 PPanel 安装在任意目录,本文档使用 `/opt/ppanel` 作为示例。如果选择其他目录,请相应调整后续命令中的路径。
|
||||
:::
|
||||
|
||||
```bash
|
||||
# 创建安装目录
|
||||
# 创建安装目录(可以自定义路径)
|
||||
sudo mkdir -p /opt/ppanel
|
||||
cd /opt/ppanel
|
||||
|
||||
# 下载 Linux amd64 版本
|
||||
wget https://github.com/perfect-panel/ppanel/releases/latest/download/ppanel-linux-amd64.tar.gz
|
||||
wget https://github.com/perfect-panel/ppanel/releases/latest/download/gateway-linux-amd64.tar.gz
|
||||
|
||||
# 或下载 Linux arm64 版本
|
||||
# wget https://github.com/perfect-panel/ppanel/releases/latest/download/ppanel-linux-arm64.tar.gz
|
||||
# wget https://github.com/perfect-panel/ppanel/releases/latest/download/gateway-linux-arm64.tar.gz
|
||||
|
||||
# 或下载 macOS amd64 版本
|
||||
# wget https://github.com/perfect-panel/ppanel/releases/latest/download/gateway-darwin-amd64.tar.gz
|
||||
|
||||
# 或下载 macOS arm64 版本 (Apple Silicon)
|
||||
# wget https://github.com/perfect-panel/ppanel/releases/latest/download/gateway-darwin-arm64.tar.gz
|
||||
|
||||
# 解压
|
||||
tar -xzf ppanel-linux-amd64.tar.gz
|
||||
tar -xzf gateway-linux-amd64.tar.gz
|
||||
|
||||
# 验证解压的文件
|
||||
ls -la
|
||||
@ -44,8 +54,7 @@ ls -la
|
||||
预期的文件结构:
|
||||
```
|
||||
/opt/ppanel/
|
||||
├── ppanel-server # 主服务器二进制文件
|
||||
├── gateway # 网关二进制文件
|
||||
├── gateway # 网关可执行文件
|
||||
└── etc/ # 配置目录
|
||||
└── ppanel.yaml # 配置文件
|
||||
```
|
||||
@ -55,52 +64,92 @@ ls -la
|
||||
### 步骤 1: 准备配置
|
||||
|
||||
```bash
|
||||
# 复制示例配置
|
||||
sudo cp etc/ppanel.yaml etc/ppanel.yaml.backup
|
||||
|
||||
# 编辑配置
|
||||
sudo nano etc/ppanel.yaml
|
||||
sudo nano /opt/ppanel/etc/ppanel.yaml
|
||||
```
|
||||
|
||||
**基础配置示例:**
|
||||
**配置示例:**
|
||||
|
||||
::: tip 相对路径
|
||||
配置中的路径(如 `Path`、`logs` 等)支持相对路径。相对路径是相对于程序工作目录(WorkingDirectory)的,在 systemd 服务中即 `/opt/ppanel`。
|
||||
:::
|
||||
|
||||
```yaml
|
||||
server:
|
||||
host: 0.0.0.0
|
||||
port: 8080
|
||||
mode: release # debug, release, 或 test
|
||||
Host: 0.0.0.0
|
||||
Port: 8080
|
||||
TLS:
|
||||
Enable: false
|
||||
CertFile: ""
|
||||
KeyFile: ""
|
||||
Debug: false
|
||||
|
||||
database:
|
||||
type: sqlite
|
||||
path: /opt/ppanel/data/ppanel.db
|
||||
# MySQL/PostgreSQL 配置:
|
||||
# type: mysql
|
||||
# host: localhost
|
||||
# port: 3306
|
||||
# user: ppanel
|
||||
# password: your_password
|
||||
# database: ppanel
|
||||
Static:
|
||||
Admin:
|
||||
Enabled: true
|
||||
Prefix: /admin
|
||||
Path: ./static/admin
|
||||
User:
|
||||
Enabled: true
|
||||
Prefix: /
|
||||
Path: ./static/user
|
||||
|
||||
log:
|
||||
level: info # debug, info, warn, error
|
||||
path: /opt/ppanel/logs
|
||||
JwtAuth:
|
||||
AccessSecret: your-secret-key-change-this
|
||||
AccessExpire: 604800
|
||||
|
||||
gateway:
|
||||
port: 8080
|
||||
timeout: 30s
|
||||
Logger:
|
||||
ServiceName: ApiService
|
||||
Mode: console
|
||||
Encoding: plain
|
||||
TimeFormat: "2006-01-02 15:04:05.000"
|
||||
Path: logs
|
||||
Level: info
|
||||
MaxContentLength: 0
|
||||
Compress: false
|
||||
Stat: true
|
||||
KeepDays: 0
|
||||
StackCooldownMillis: 100
|
||||
MaxBackups: 0
|
||||
MaxSize: 0
|
||||
Rotation: daily
|
||||
FileTimeFormat: 2006-01-02T15:04:05.000Z07:00
|
||||
|
||||
MySQL:
|
||||
Addr: localhost:3306
|
||||
Username: your-username
|
||||
Password: your-password
|
||||
Dbname: ppanel
|
||||
Config: charset=utf8mb4&parseTime=true&loc=Asia%2FShanghai
|
||||
MaxIdleConns: 10
|
||||
MaxOpenConns: 10
|
||||
SlowThreshold: 1000
|
||||
|
||||
Redis:
|
||||
Host: localhost:6379
|
||||
Pass: your-redis-password
|
||||
DB: 0
|
||||
```
|
||||
|
||||
::: warning 必需配置
|
||||
**MySQL 和 Redis 是必需的。** 部署前请配置以下项:
|
||||
- `JwtAuth.AccessSecret` - 使用强随机密钥(必需)
|
||||
- `MySQL.*` - 配置你的 MySQL 数据库连接(必需)
|
||||
- `Redis.*` - 配置你的 Redis 连接(必需)
|
||||
:::
|
||||
|
||||
### 步骤 2: 创建必要的目录
|
||||
|
||||
```bash
|
||||
# 创建数据和日志目录
|
||||
sudo mkdir -p /opt/ppanel/data
|
||||
sudo mkdir -p /opt/ppanel/logs
|
||||
sudo mkdir -p /opt/ppanel/static
|
||||
|
||||
# 设置适当的权限
|
||||
sudo chmod 755 /opt/ppanel
|
||||
sudo chmod 700 /opt/ppanel/data
|
||||
sudo chmod 755 /opt/ppanel/logs
|
||||
sudo chmod 755 /opt/ppanel/static
|
||||
```
|
||||
|
||||
## 运行服务
|
||||
@ -111,15 +160,11 @@ sudo chmod 755 /opt/ppanel/logs
|
||||
|
||||
```bash
|
||||
# 使二进制文件可执行
|
||||
sudo chmod +x /opt/ppanel/ppanel-server
|
||||
sudo chmod +x /opt/ppanel/gateway
|
||||
|
||||
# 直接运行服务器
|
||||
# 直接运行
|
||||
cd /opt/ppanel
|
||||
sudo ./ppanel-server
|
||||
|
||||
# 在另一个终端运行网关(如果分离)
|
||||
# sudo ./gateway
|
||||
sudo ./gateway
|
||||
```
|
||||
|
||||
按 `Ctrl+C` 停止。
|
||||
@ -147,7 +192,7 @@ Wants=network-online.target
|
||||
Type=simple
|
||||
User=root
|
||||
WorkingDirectory=/opt/ppanel
|
||||
ExecStart=/opt/ppanel/ppanel-server
|
||||
ExecStart=/opt/ppanel/gateway
|
||||
Restart=always
|
||||
RestartSec=10
|
||||
|
||||
@ -262,7 +307,7 @@ ps aux | grep ppanel
|
||||
### 访问应用
|
||||
|
||||
- **用户面板**: `http://your-server-ip:8080`
|
||||
- **管理后台**: `http://your-server-ip:8080/admin`
|
||||
- **管理后台**: `http://your-server-ip:8080/admin/`
|
||||
|
||||
### 配置防火墙
|
||||
|
||||
@ -312,70 +357,11 @@ sudo systemctl reload nginx
|
||||
|
||||
## 升级
|
||||
|
||||
### 升级前备份
|
||||
直接从**管理后台**主页升级 PPanel。在仪表盘主页可以检查新版本并一键升级。
|
||||
|
||||
```bash
|
||||
# 停止服务
|
||||
sudo systemctl stop ppanel
|
||||
|
||||
# 备份当前版本
|
||||
sudo cp -r /opt/ppanel /opt/ppanel-backup-$(date +%Y%m%d)
|
||||
|
||||
# 备份数据库
|
||||
sudo cp /opt/ppanel/data/ppanel.db /opt/ppanel/data/ppanel.db.backup-$(date +%Y%m%d)
|
||||
|
||||
# 备份配置
|
||||
sudo cp /opt/ppanel/etc/ppanel.yaml /opt/ppanel/etc/ppanel.yaml.backup-$(date +%Y%m%d)
|
||||
```
|
||||
|
||||
### 下载并安装新版本
|
||||
|
||||
```bash
|
||||
# 下载新版本
|
||||
cd /tmp
|
||||
wget https://github.com/perfect-panel/ppanel/releases/latest/download/ppanel-linux-amd64.tar.gz
|
||||
|
||||
# 解压到临时位置
|
||||
mkdir ppanel-new
|
||||
tar -xzf ppanel-linux-amd64.tar.gz -C ppanel-new
|
||||
|
||||
# 备份旧的二进制文件
|
||||
sudo mv /opt/ppanel/ppanel-server /opt/ppanel/ppanel-server.old
|
||||
sudo mv /opt/ppanel/gateway /opt/ppanel/gateway.old
|
||||
|
||||
# 安装新的二进制文件
|
||||
sudo cp ppanel-new/ppanel-server /opt/ppanel/
|
||||
sudo cp ppanel-new/gateway /opt/ppanel/
|
||||
|
||||
# 设置权限
|
||||
sudo chmod +x /opt/ppanel/ppanel-server
|
||||
sudo chmod +x /opt/ppanel/gateway
|
||||
|
||||
# 启动服务
|
||||
sudo systemctl start ppanel
|
||||
|
||||
# 检查状态
|
||||
sudo systemctl status ppanel
|
||||
```
|
||||
|
||||
### 回滚
|
||||
|
||||
如果升级失败:
|
||||
|
||||
```bash
|
||||
# 停止服务
|
||||
sudo systemctl stop ppanel
|
||||
|
||||
# 恢复旧的二进制文件
|
||||
sudo mv /opt/ppanel/ppanel-server.old /opt/ppanel/ppanel-server
|
||||
sudo mv /opt/ppanel/gateway.old /opt/ppanel/gateway
|
||||
|
||||
# 恢复数据库(如需要)
|
||||
sudo cp /opt/ppanel/data/ppanel.db.backup-YYYYMMDD /opt/ppanel/data/ppanel.db
|
||||
|
||||
# 启动服务
|
||||
sudo systemctl start ppanel
|
||||
```
|
||||
::: tip 提示
|
||||
系统会自动处理升级过程,包括下载新的二进制文件和重启服务。
|
||||
:::
|
||||
|
||||
## 故障排除
|
||||
|
||||
@ -413,14 +399,14 @@ sudo systemctl restart ppanel
|
||||
```bash
|
||||
# 检查架构兼容性
|
||||
uname -m
|
||||
file /opt/ppanel/ppanel-server
|
||||
file /opt/ppanel/gateway
|
||||
|
||||
# 检查是否可执行
|
||||
ls -la /opt/ppanel/ppanel-server
|
||||
sudo chmod +x /opt/ppanel/ppanel-server
|
||||
ls -la /opt/ppanel/gateway
|
||||
sudo chmod +x /opt/ppanel/gateway
|
||||
|
||||
# 检查缺失的库(静态编译应该没有)
|
||||
ldd /opt/ppanel/ppanel-server
|
||||
ldd /opt/ppanel/gateway
|
||||
```
|
||||
|
||||
### 内存使用过高
|
||||
@ -497,7 +483,7 @@ sudo nano /etc/systemd/system/ppanel.service
|
||||
# 更改: User=ppanel
|
||||
|
||||
# 如果绑定到端口 < 1024,授予能力
|
||||
sudo setcap 'cap_net_bind_service=+ep' /opt/ppanel/ppanel-server
|
||||
sudo setcap 'cap_net_bind_service=+ep' /opt/ppanel/gateway
|
||||
|
||||
sudo systemctl daemon-reload
|
||||
sudo systemctl restart ppanel
|
||||
|
||||
@ -77,17 +77,17 @@ cd ~/ppanel
|
||||
version: '3.8'
|
||||
|
||||
services:
|
||||
ppanel:
|
||||
ppanel-service:
|
||||
image: ppanel/ppanel:latest
|
||||
container_name: ppanel
|
||||
container_name: ppanel-service
|
||||
restart: always
|
||||
ports:
|
||||
- "8080:8080"
|
||||
volumes:
|
||||
- ./ppanel-config:/app/etc:ro
|
||||
- ppanel-data:/app/data
|
||||
restart: unless-stopped
|
||||
environment:
|
||||
- TZ=Asia/Shanghai
|
||||
- ./config:/app/etc:ro
|
||||
- ./web:/app/static
|
||||
networks:
|
||||
- ppanel-net
|
||||
healthcheck:
|
||||
test: ["CMD", "wget", "--quiet", "--tries=1", "--spider", "http://localhost:8080/health"]
|
||||
interval: 30s
|
||||
@ -95,45 +95,92 @@ services:
|
||||
retries: 3
|
||||
start_period: 40s
|
||||
|
||||
volumes:
|
||||
ppanel-data:
|
||||
driver: local
|
||||
networks:
|
||||
ppanel-net:
|
||||
driver: bridge
|
||||
```
|
||||
|
||||
**配置说明:**
|
||||
|
||||
- **image**: 使用的 Docker 镜像(latest 或指定版本如 `v0.1.2`)
|
||||
- **ports**: 将容器的 8080 端口映射到宿主机的 8080 端口
|
||||
- **container_name**: 设置自定义容器名称
|
||||
- **ports**: 将容器的 8080 端口映射到宿主机的 8080 端口(可根据需要修改宿主机端口)
|
||||
- **volumes**:
|
||||
- `./ppanel-config:/app/etc:ro` - 配置目录(只读)
|
||||
- `ppanel-data:/app/data` - 持久化数据存储
|
||||
- **restart**: 自动重启策略
|
||||
- **environment**: 设置时区(可改为 `Asia/Shanghai` 等)
|
||||
- `./config:/app/etc:ro` - 配置目录(只读)
|
||||
- `./web:/app/static` - 静态文件目录(管理后台和用户前端)
|
||||
- **networks**: 创建自定义网络以实现服务隔离
|
||||
- **restart**: 自动重启策略(always 表示总是重启)
|
||||
- **healthcheck**: 服务健康检查
|
||||
|
||||
### 步骤 3: 准备配置
|
||||
|
||||
```bash
|
||||
# 创建配置目录
|
||||
mkdir -p ppanel-config
|
||||
mkdir -p config
|
||||
|
||||
# 创建配置文件
|
||||
cat > ppanel-config/ppanel.yaml <<EOF
|
||||
# PPanel 配置文件
|
||||
server:
|
||||
host: 0.0.0.0
|
||||
port: 8080
|
||||
cat > config/ppanel.yaml <<EOF
|
||||
Host: 0.0.0.0
|
||||
Port: 8080
|
||||
TLS:
|
||||
Enable: false
|
||||
CertFile: ""
|
||||
KeyFile: ""
|
||||
Debug: false
|
||||
|
||||
database:
|
||||
type: sqlite
|
||||
path: /app/data/ppanel.db
|
||||
Static:
|
||||
Admin:
|
||||
Enabled: true
|
||||
Prefix: /admin
|
||||
Path: ./static/admin
|
||||
User:
|
||||
Enabled: true
|
||||
Prefix: /
|
||||
Path: ./static/user
|
||||
|
||||
# 根据需要添加更多配置
|
||||
JwtAuth:
|
||||
AccessSecret: your-secret-key-change-this
|
||||
AccessExpire: 604800
|
||||
|
||||
Logger:
|
||||
ServiceName: ApiService
|
||||
Mode: console
|
||||
Encoding: plain
|
||||
TimeFormat: "2006-01-02 15:04:05.000"
|
||||
Path: logs
|
||||
Level: info
|
||||
MaxContentLength: 0
|
||||
Compress: false
|
||||
Stat: true
|
||||
KeepDays: 0
|
||||
StackCooldownMillis: 100
|
||||
MaxBackups: 0
|
||||
MaxSize: 0
|
||||
Rotation: daily
|
||||
FileTimeFormat: 2006-01-02T15:04:05.000Z07:00
|
||||
|
||||
MySQL:
|
||||
Addr: localhost:3306
|
||||
Username: your-username
|
||||
Password: your-password
|
||||
Dbname: ppanel
|
||||
Config: charset=utf8mb4&parseTime=true&loc=Asia%2FShanghai
|
||||
MaxIdleConns: 10
|
||||
MaxOpenConns: 10
|
||||
SlowThreshold: 1000
|
||||
|
||||
Redis:
|
||||
Host: localhost:6379
|
||||
Pass: your-redis-password
|
||||
DB: 0
|
||||
EOF
|
||||
```
|
||||
|
||||
::: tip 提示
|
||||
详细的配置选项请参考 [配置指南](/zh/guide/configuration)。
|
||||
::: warning 必需配置
|
||||
**MySQL 和 Redis 是必需的。** 部署前请配置以下项:
|
||||
- `JwtAuth.AccessSecret` - 使用强随机密钥(必需)
|
||||
- `MySQL.*` - 配置你的 MySQL 数据库连接(必需)
|
||||
- `Redis.*` - 配置你的 Redis 连接(必需)
|
||||
:::
|
||||
|
||||
### 步骤 4: 启动服务
|
||||
@ -169,7 +216,7 @@ docker compose logs -f ppanel
|
||||
安装成功后,你可以通过以下地址访问:
|
||||
|
||||
- **用户面板**: `http://your-server-ip:8080`
|
||||
- **管理后台**: `http://your-server-ip:8080/admin`
|
||||
- **管理后台**: `http://your-server-ip:8080/admin/`
|
||||
|
||||
::: warning 默认凭据
|
||||
为了安全起见,首次登录后请立即修改默认管理员密码。
|
||||
@ -272,43 +319,11 @@ docker compose down -v
|
||||
|
||||
## 升级
|
||||
|
||||
### 升级前备份
|
||||
直接从**管理后台**主页升级 PPanel。在仪表盘主页可以检查新版本并一键升级。
|
||||
|
||||
```bash
|
||||
# 备份配置
|
||||
tar czf ppanel-config-backup-$(date +%Y%m%d).tar.gz ppanel-config/
|
||||
|
||||
# 备份数据卷
|
||||
docker run --rm \
|
||||
-v ppanel_ppanel-data:/data \
|
||||
-v $(pwd):/backup \
|
||||
alpine tar czf /backup/ppanel-data-backup-$(date +%Y%m%d).tar.gz /data
|
||||
```
|
||||
|
||||
### 升级步骤
|
||||
|
||||
```bash
|
||||
# 拉取最新镜像
|
||||
docker compose pull
|
||||
|
||||
# 使用新镜像重新创建容器
|
||||
docker compose up -d
|
||||
|
||||
# 查看日志验证
|
||||
docker compose logs -f
|
||||
```
|
||||
|
||||
### 回滚
|
||||
|
||||
如果升级后遇到问题:
|
||||
|
||||
```bash
|
||||
# 编辑 docker-compose.yml,将镜像改为之前的版本
|
||||
# image: ppanel/ppanel:v0.1.1
|
||||
|
||||
# 使用之前的版本重启
|
||||
docker compose up -d
|
||||
```
|
||||
::: tip 提示
|
||||
系统会自动处理升级过程,包括拉取新镜像和重启服务。
|
||||
:::
|
||||
|
||||
## 高级配置
|
||||
|
||||
@ -317,7 +332,9 @@ docker compose up -d
|
||||
要使用不同的端口,编辑 `docker-compose.yml`:
|
||||
|
||||
```yaml
|
||||
ports:
|
||||
services:
|
||||
ppanel-service:
|
||||
ports:
|
||||
- "3000:8080" # 宿主机端口 3000 -> 容器端口 8080
|
||||
```
|
||||
|
||||
@ -403,10 +420,10 @@ sudo lsof -i :8080
|
||||
|
||||
```bash
|
||||
# 修复配置目录权限
|
||||
sudo chown -R $USER:$USER ppanel-config/
|
||||
sudo chown -R $USER:$USER config/
|
||||
|
||||
# 确保文件可读
|
||||
chmod 644 ppanel-config/ppanel.yaml
|
||||
chmod 644 config/ppanel.yaml
|
||||
```
|
||||
|
||||
### 无法从外部访问
|
||||
|
||||
@ -67,53 +67,106 @@ mkdir -p ~/ppanel-config
|
||||
|
||||
# 创建配置文件
|
||||
cat > ~/ppanel-config/ppanel.yaml <<EOF
|
||||
server:
|
||||
host: 0.0.0.0
|
||||
port: 8080
|
||||
Host: 0.0.0.0
|
||||
Port: 8080
|
||||
TLS:
|
||||
Enable: false
|
||||
CertFile: ""
|
||||
KeyFile: ""
|
||||
Debug: false
|
||||
|
||||
database:
|
||||
type: sqlite
|
||||
path: /app/data/ppanel.db
|
||||
Static:
|
||||
Admin:
|
||||
Enabled: true
|
||||
Prefix: /admin
|
||||
Path: ./static/admin
|
||||
User:
|
||||
Enabled: true
|
||||
Prefix: /
|
||||
Path: ./static/user
|
||||
|
||||
JwtAuth:
|
||||
AccessSecret: your-secret-key-change-this
|
||||
AccessExpire: 604800
|
||||
|
||||
Logger:
|
||||
ServiceName: ApiService
|
||||
Mode: console
|
||||
Encoding: plain
|
||||
TimeFormat: "2006-01-02 15:04:05.000"
|
||||
Path: logs
|
||||
Level: info
|
||||
MaxContentLength: 0
|
||||
Compress: false
|
||||
Stat: true
|
||||
KeepDays: 0
|
||||
StackCooldownMillis: 100
|
||||
MaxBackups: 0
|
||||
MaxSize: 0
|
||||
Rotation: daily
|
||||
FileTimeFormat: 2006-01-02T15:04:05.000Z07:00
|
||||
|
||||
MySQL:
|
||||
Addr: localhost:3306
|
||||
Username: your-username
|
||||
Password: your-password
|
||||
Dbname: ppanel
|
||||
Config: charset=utf8mb4&parseTime=true&loc=Asia%2FShanghai
|
||||
MaxIdleConns: 10
|
||||
MaxOpenConns: 10
|
||||
SlowThreshold: 1000
|
||||
|
||||
Redis:
|
||||
Host: localhost:6379
|
||||
Pass: your-redis-password
|
||||
DB: 0
|
||||
EOF
|
||||
```
|
||||
|
||||
::: warning 必需配置
|
||||
**MySQL 和 Redis 是必需的。** 部署前请配置以下项:
|
||||
- `JwtAuth.AccessSecret` - 使用强随机密钥(必需)
|
||||
- `MySQL.*` - 配置你的 MySQL 数据库连接(必需)
|
||||
- `Redis.*` - 配置你的 Redis 连接(必需)
|
||||
:::
|
||||
|
||||
### 步骤 3: 运行容器
|
||||
|
||||
**基础命令:**
|
||||
```bash
|
||||
docker run -d \
|
||||
--name ppanel \
|
||||
--name ppanel-service \
|
||||
-p 8080:8080 \
|
||||
-v ~/ppanel-config:/app/etc:ro \
|
||||
-v ppanel-data:/app/data \
|
||||
--restart unless-stopped \
|
||||
-v ~/ppanel-web:/app/static \
|
||||
--restart always \
|
||||
ppanel/ppanel:latest
|
||||
```
|
||||
|
||||
**完整参数命令:**
|
||||
```bash
|
||||
docker run -d \
|
||||
--name ppanel \
|
||||
--name ppanel-service \
|
||||
-p 8080:8080 \
|
||||
-v ~/ppanel-config:/app/etc:ro \
|
||||
-v ppanel-data:/app/data \
|
||||
-e TZ=Asia/Shanghai \
|
||||
--restart unless-stopped \
|
||||
-v ~/ppanel-web:/app/static \
|
||||
--restart always \
|
||||
--memory="2g" \
|
||||
--cpus="2" \
|
||||
--network ppanel-net \
|
||||
ppanel/ppanel:latest
|
||||
```
|
||||
|
||||
**参数说明:**
|
||||
- `-d`: 以守护进程模式运行(后台运行)
|
||||
- `--name ppanel`: 设置容器名称
|
||||
- `--name ppanel-service`: 设置容器名称
|
||||
- `-p 8080:8080`: 端口映射(宿主机:容器)
|
||||
- `-v ~/ppanel-config:/app/etc:ro`: 挂载配置(只读)
|
||||
- `-v ppanel-data:/app/data`: 创建数据卷
|
||||
- `-e TZ=Asia/Shanghai`: 设置时区
|
||||
- `--restart unless-stopped`: 自动重启策略
|
||||
- `--memory="2g"`: 内存限制
|
||||
- `--cpus="2"`: CPU 限制
|
||||
- `-v ~/ppanel-web:/app/static`: 挂载静态文件目录
|
||||
- `--restart always`: 自动重启策略(总是重启)
|
||||
- `--memory="2g"`: 内存限制(可选)
|
||||
- `--cpus="2"`: CPU 限制(可选)
|
||||
- `--network ppanel-net`: 连接到自定义网络(可选)
|
||||
|
||||
### 步骤 4: 验证运行
|
||||
|
||||
@ -181,43 +234,11 @@ docker volume rm ppanel-data
|
||||
|
||||
## 升级
|
||||
|
||||
### 备份数据
|
||||
直接从**管理后台**主页升级 PPanel。在仪表盘主页可以检查新版本并一键升级。
|
||||
|
||||
```bash
|
||||
# 备份配置
|
||||
tar czf ppanel-config-backup-$(date +%Y%m%d).tar.gz ~/ppanel-config/
|
||||
|
||||
# 备份数据卷
|
||||
docker run --rm \
|
||||
-v ppanel-data:/data \
|
||||
-v $(pwd):/backup \
|
||||
alpine tar czf /backup/ppanel-data-backup-$(date +%Y%m%d).tar.gz /data
|
||||
```
|
||||
|
||||
### 升级流程
|
||||
|
||||
```bash
|
||||
# 拉取最新镜像
|
||||
docker pull ppanel/ppanel:latest
|
||||
|
||||
# 停止旧容器
|
||||
docker stop ppanel
|
||||
|
||||
# 删除旧容器
|
||||
docker rm ppanel
|
||||
|
||||
# 使用相同配置启动新容器
|
||||
docker run -d \
|
||||
--name ppanel \
|
||||
-p 8080:8080 \
|
||||
-v ~/ppanel-config:/app/etc:ro \
|
||||
-v ppanel-data:/app/data \
|
||||
--restart unless-stopped \
|
||||
ppanel/ppanel:latest
|
||||
|
||||
# 验证
|
||||
docker logs -f ppanel
|
||||
```
|
||||
::: tip 提示
|
||||
系统会自动处理升级过程,包括拉取新镜像和重启服务。
|
||||
:::
|
||||
|
||||
## 高级用法
|
||||
|
||||
|
||||
289
docs/zh/guide/installation/one-click.md
Normal file
289
docs/zh/guide/installation/one-click.md
Normal file
@ -0,0 +1,289 @@
|
||||
# 一键部署
|
||||
|
||||
使用自动化安装脚本快速部署 PPanel。适合快速测试或生产环境部署。
|
||||
|
||||
## 前置条件
|
||||
|
||||
- 干净的 Linux 服务器 (Ubuntu 20.04+, Debian 10+, CentOS 8+)
|
||||
- Root 或 sudo 访问权限
|
||||
- 基本的网络连接
|
||||
|
||||
## 安装步骤
|
||||
|
||||
### 方式一:完整安装(推荐)
|
||||
|
||||
一条命令同时安装 Docker 和 PPanel:
|
||||
|
||||
```bash
|
||||
curl -fsSL https://ppanel.dev/scripts/zh/install-docker.sh | sudo bash && \
|
||||
curl -fsSL https://ppanel.dev/scripts/zh/install-ppanel.sh | bash
|
||||
```
|
||||
|
||||
### 方式二:分步安装
|
||||
|
||||
如果你希望分别安装各个组件:
|
||||
|
||||
#### 步骤 1: 安装 Docker 和 Docker Compose
|
||||
|
||||
```bash
|
||||
curl -fsSL https://ppanel.dev/scripts/zh/install-docker.sh | sudo bash
|
||||
```
|
||||
|
||||
此脚本将会:
|
||||
- ✅ 自动检测你的操作系统
|
||||
- ✅ 安装 Docker Engine 和 Docker Compose Plugin
|
||||
- ✅ 配置 Docker 服务开机自启
|
||||
- ✅ 将当前用户添加到 docker 组
|
||||
- ✅ 验证安装是否成功
|
||||
|
||||
#### 步骤 2: 安装 PPanel
|
||||
|
||||
```bash
|
||||
curl -fsSL https://ppanel.dev/scripts/zh/install-ppanel.sh | bash
|
||||
```
|
||||
|
||||
此脚本将会:
|
||||
- ✅ 检查 Docker 环境
|
||||
- ✅ 检查端口可用性
|
||||
- ✅ 创建安装目录
|
||||
- ✅ 交互式配置(MySQL、Redis)
|
||||
- ✅ 自动生成 JWT 密钥
|
||||
- ✅ 创建 docker-compose.yml
|
||||
- ✅ 拉取 Docker 镜像并启动服务
|
||||
- ✅ 显示访问信息
|
||||
|
||||
## 安装时的配置
|
||||
|
||||
安装脚本会提示你输入以下信息:
|
||||
|
||||
### MySQL 配置(必需)
|
||||
|
||||
```
|
||||
MySQL 地址 (默认: localhost:3306):
|
||||
MySQL 用户名 (默认: ppanel):
|
||||
MySQL 密码: [你的密码]
|
||||
MySQL 数据库名 (默认: ppanel):
|
||||
```
|
||||
|
||||
### Redis 配置(必需)
|
||||
|
||||
```
|
||||
Redis 地址 (默认: localhost:6379):
|
||||
Redis 密码 (可选): [你的密码]
|
||||
Redis DB (默认: 0):
|
||||
```
|
||||
|
||||
::: tip 提示
|
||||
安装脚本会自动为你生成一个安全的 JWT 密钥。
|
||||
:::
|
||||
|
||||
## 自定义安装目录
|
||||
|
||||
默认情况下,PPanel 安装到 `~/ppanel`。你可以指定自定义目录:
|
||||
|
||||
```bash
|
||||
INSTALL_DIR=/opt/ppanel curl -fsSL https://ppanel.dev/scripts/zh/install-ppanel.sh | bash
|
||||
```
|
||||
|
||||
## 自定义端口
|
||||
|
||||
默认情况下,PPanel 监听 8080 端口。要使用其他端口:
|
||||
|
||||
```bash
|
||||
HOST_PORT=3000 curl -fsSL https://ppanel.dev/scripts/zh/install-ppanel.sh | bash
|
||||
```
|
||||
|
||||
## 部署后配置
|
||||
|
||||
### 访问你的安装
|
||||
|
||||
安装成功后,你可以访问:
|
||||
|
||||
- **用户面板**: `http://your-server-ip:8080`
|
||||
- **管理后台**: `http://your-server-ip:8080/admin/`
|
||||
|
||||
### 常用命令
|
||||
|
||||
安装脚本会显示这些有用的命令:
|
||||
|
||||
```bash
|
||||
# 进入安装目录
|
||||
cd ~/ppanel
|
||||
|
||||
# 查看服务状态
|
||||
docker compose ps
|
||||
|
||||
# 查看日志
|
||||
docker compose logs -f
|
||||
|
||||
# 重启服务
|
||||
docker compose restart
|
||||
|
||||
# 停止服务
|
||||
docker compose stop
|
||||
|
||||
# 启动服务
|
||||
docker compose start
|
||||
```
|
||||
|
||||
### 配置防火墙
|
||||
|
||||
**Ubuntu/Debian:**
|
||||
```bash
|
||||
sudo ufw allow 8080/tcp
|
||||
sudo ufw status
|
||||
```
|
||||
|
||||
**CentOS/RHEL:**
|
||||
```bash
|
||||
sudo firewall-cmd --permanent --add-port=8080/tcp
|
||||
sudo firewall-cmd --reload
|
||||
```
|
||||
|
||||
### 设置反向代理(推荐)
|
||||
|
||||
生产环境部署建议配置带 HTTPS 的反向代理:
|
||||
|
||||
**Nginx:**
|
||||
```nginx
|
||||
server {
|
||||
listen 80;
|
||||
server_name your-domain.com;
|
||||
return 301 https://$server_name$request_uri;
|
||||
}
|
||||
|
||||
server {
|
||||
listen 443 ssl http2;
|
||||
server_name your-domain.com;
|
||||
|
||||
ssl_certificate /path/to/cert.pem;
|
||||
ssl_certificate_key /path/to/key.pem;
|
||||
|
||||
location / {
|
||||
proxy_pass http://localhost:8080;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
**Caddy:**
|
||||
```
|
||||
your-domain.com {
|
||||
reverse_proxy localhost:8080
|
||||
}
|
||||
```
|
||||
|
||||
## 升级
|
||||
|
||||
直接从**管理后台**主页升级 PPanel。在仪表盘主页可以检查新版本并一键升级。
|
||||
|
||||
::: tip 提示
|
||||
系统会自动处理升级过程,包括拉取新镜像和重启服务。
|
||||
:::
|
||||
|
||||
## 故障排除
|
||||
|
||||
### 安装失败
|
||||
|
||||
如果安装失败,请检查:
|
||||
|
||||
1. **网络连接**: 确保服务器可以访问 Docker Hub 和 GitHub
|
||||
2. **系统要求**: 验证你的操作系统是否支持
|
||||
3. **权限**: 确保你有 sudo/root 访问权限
|
||||
4. **端口可用性**: 检查端口 8080 是否可用
|
||||
|
||||
### Docker 未找到
|
||||
|
||||
如果出现 "Docker not found" 错误:
|
||||
|
||||
```bash
|
||||
# 检查 Docker 是否已安装
|
||||
docker --version
|
||||
|
||||
# 如果未安装,先运行 Docker 安装脚本
|
||||
curl -fsSL https://ppanel.dev/scripts/zh/install-docker.sh | sudo bash
|
||||
```
|
||||
|
||||
### 服务无法启动
|
||||
|
||||
查看日志检查错误:
|
||||
|
||||
```bash
|
||||
cd ~/ppanel
|
||||
docker compose logs -f
|
||||
```
|
||||
|
||||
常见问题:
|
||||
- MySQL 连接失败:检查 MySQL 凭据
|
||||
- Redis 连接失败:检查 Redis 凭据
|
||||
- 端口已被占用:更改 HOST_PORT
|
||||
|
||||
### 权限被拒绝
|
||||
|
||||
如果遇到 Docker 权限错误:
|
||||
|
||||
```bash
|
||||
# 将用户添加到 docker 组
|
||||
sudo usermod -aG docker $USER
|
||||
|
||||
# 注销并重新登录,或运行:
|
||||
newgrp docker
|
||||
```
|
||||
|
||||
## 卸载
|
||||
|
||||
完全移除 PPanel:
|
||||
|
||||
```bash
|
||||
cd ~/ppanel
|
||||
docker compose down
|
||||
cd ~
|
||||
rm -rf ~/ppanel
|
||||
```
|
||||
|
||||
## 高级选项
|
||||
|
||||
### 非交互式安装
|
||||
|
||||
对于自动化部署,可以使用环境变量预配置设置:
|
||||
|
||||
```bash
|
||||
export INSTALL_DIR=/opt/ppanel
|
||||
export HOST_PORT=8080
|
||||
export MYSQL_ADDR=localhost:3306
|
||||
export MYSQL_USER=ppanel
|
||||
export MYSQL_PASSWORD=your-password
|
||||
export MYSQL_DB=ppanel
|
||||
export REDIS_HOST=localhost:6379
|
||||
export REDIS_PASS=your-redis-password
|
||||
export REDIS_DB=0
|
||||
|
||||
curl -fsSL https://ppanel.dev/scripts/zh/install-ppanel.sh | bash
|
||||
```
|
||||
|
||||
### 代理环境下安装
|
||||
|
||||
如果你的服务器在代理后面:
|
||||
|
||||
```bash
|
||||
export HTTP_PROXY=http://proxy.example.com:8080
|
||||
export HTTPS_PROXY=http://proxy.example.com:8080
|
||||
|
||||
curl -fsSL https://ppanel.dev/scripts/zh/install-docker.sh | sudo bash
|
||||
curl -fsSL https://ppanel.dev/scripts/zh/install-ppanel.sh | bash
|
||||
```
|
||||
|
||||
## 下一步
|
||||
|
||||
- [配置指南](/zh/guide/configuration) - 自定义你的 PPanel 设置
|
||||
- [管理后台](/zh/admin/dashboard) - 开始管理你的面板
|
||||
- [API 参考](/zh/api/reference) - 与你的应用集成
|
||||
|
||||
## 需要帮助?
|
||||
|
||||
- 查看 [GitHub Issues](https://github.com/perfect-panel/ppanel/issues)
|
||||
- 查看安装日志
|
||||
- 加入我们的社区获取支持
|
||||
Loading…
x
Reference in New Issue
Block a user