# we-mp-rss Fresh Deployment on Beijing Server

## Server Info
- Region: ap-beijing (Tencent Cloud Lighthouse)
- Instance: ins-jrstx6f5
- IP: 120.53.228.229
- Cloudflared tunnel: 40f60a3f

## Deployment Steps

### 1. Get Source Code
Source is at https://github.com/rachelos/we-mp-rss (open source).
```bash
git clone https://github.com/rachelos/we-mp-rss.git ~/project/we-mp-rss-main
```

### 2. Install Dependencies
```bash
cd ~/project/we-mp-rss-main
python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txt
playwright install chromium  # webkit blocked in China
```

### 3. Directory Structure
```bash
mkdir -p ~/project/we-mp-rss-data ~/project/state ~/project/config ~/project/scripts
```

### 4. Create .env
```
DB=sqlite:////home/ubuntu/project/we-mp-rss-data/db.db
BROWSER_TYPE=chromium
ENABLE_JOB=True
PORT=8001
WE_MP_RSS_AK=admin
WE_MP_RSS_SK=admin888
```

### 5. Critical Code Fixes (MANDATORY)

**a) playwright_driver.py line 53** — change default from "webkit" to "chromium"
**b) apis/auth.py** — remove `from driver.wx import WX_API`, use HTTP-based version
**c) apis/message_task.py** — if empty, create stub:
```python
from fastapi import APIRouter
router = APIRouter(prefix="/wx/message_tasks", tags=["消息任务"])
```

### 6. Init Database
```bash
source venv/bin/activate
DB="sqlite:////home/ubuntu/project/we-mp-rss-data/db.db" BROWSER_TYPE=chromium PORT=8001 python main.py -init True -job False
```

### 7. Systemd Service
See templates/systemd-we-mp-rss.service in this skill.

### 8. Cloudflared Tunnel
Add ingress rule to ~/.cloudflared/config.yml:
```yaml
- hostname: rss.gdcjgk.net
  service: http://localhost:8001
```
Then add Public Hostname in Cloudflare Zero Trust dashboard.

### 9. WeChat QR Code Login
Default web login: gdcjgk / admin888 (the password is NOT gdcjgk — see init_sys.py: PASSWORD env var or default admin@123). On fresh init without env vars: admin / admin@123.
After web login, use QR code to authorize WeChat Official Account access.

### 10. WeChat IP Note
Beijing datacenter IPs (120.53.228.229) are NOT blocked by WeChat MP API — tested and confirmed working.
