給網頁開發人員的 Studio 設定
Studio 下載檔內含兩種版本的完整原始碼、Cloudflare 部署工具和技術文件。這份指南是精簡版,適合想自己執行每個步驟的人。
- 最適合
- 想用 Studio 下載檔中的原始碼自行安裝 Studio 的網頁開發人員和 IT 團隊。
- 需要準備
- Studio 下載檔;PHP 版需要使用 Apache、LiteSpeed 或 nginx 且支援 PHP 8.0 或更新版本的主機;Cloudflare 版則需要已開啟 R2 的 Cloudflare 帳戶,以及 Node.js 20 或更新版本。
- 版本
- 同一個應用程式的兩種版本,具有相同的網址、上傳 API、儀表板和角色:一個不使用資料庫的 PHP 應用程式,以及一個搭配 R2 和 D1 的 Cloudflare Worker。
取得 Studio 下載檔
使用擁有 Studio 的帳戶登入 Maxisnap,然後:
- 在 Windows 上:在 Maxisnap 中開啟「設定 → 帳戶 → Maxisnap Studio 設定精靈」,按一下「開始使用」,再按一下「下載儀表板」。Maxisnap 會把 Studio ZIP 檔儲存到你的「下載」資料夾,並開啟該資料夾。
- 在 Mac 上:在 Maxisnap 中開啟「Settings → Welcome & Help → Studio Setup Guide」,按一下「Get Started」,再按一下「Download Dashboard」。Maxisnap 會把 Studio ZIP 檔儲存到你的「下載項目」資料夾。
解壓縮 ZIP 檔。在 Windows 上,請以滑鼠右鍵按一下該檔案,選擇「全部解壓縮」。在 Mac 上,按兩下即可。
Maxisnap-Studio-v<version>/
Maxisnap Studio - Start Here.html guided setup (branding + every route)
snaps/ PHP edition: upload this folder to a web host
cloudflare/ Cloudflare Workers edition (Worker + R2 + D1)
deploy/cli.mjs deploys it through the Cloudflare API (Node 20+)
docs/Developer guide.html architecture, upload API, security, updates
docs/Cloudflare setup - technical brief.html
AGENTS.md instructions for AI coding assistants 完整的「Developer guide」涵蓋架構、上傳 API、金鑰與角色、安全模型,以及疑難排解。它在下載檔中的位置是 docs/Developer guide.html。
PHP 版:上傳並完成設定
- 把 snaps 資料夾上傳到網站根目錄,並包含其中隱藏的 .htaccess 檔案,使最終路徑為 public_html/snaps/index.php。Start Here 頁面產生的品牌化 snaps.zip 做法相同:直接在原處解壓縮,不要變成 snaps/snaps 這樣的巢狀資料夾。
- 請先開啟 https://yourcompany.com/snaps/ 一次。設定頁面會檢查 PHP 和資料夾權限,並建議一組 40 個字元的管理員金鑰;金鑰至少需要 16 個字元。複製它,然後按一下「Create my dashboard」。
- 在 nginx 上,請依照 snaps/.htaccess 建立相同的路由與拒絕規則。uploads、data 和 branding 請維持不公開。
設定頁面會寫入 your-settings.php,更新時會保留它:
'dashboard_key' => '…', // the Admin key; the setup page writes it
'base_url' => 'https://yourcompany.com/snaps', // the address setup was opened at; fix it here if share links come out wrong
'max_upload_mb' => 500, // your host's PHP limits still apply Cloudflare 版:從終端機部署
隨附的 CLI 會先讀取帳戶,顯示一份計畫,說明它會建立什麼、不會動到什麼,並拒絕已被使用的名稱。如果部署中途停止,再執行一次相同的指令,就會接著進行,不會重複建立任何東西。
cd cloudflare
# Option 1: the bundled CLI (Node 20+; plan first, then --yes). PowerShell:
$env:CLOUDFLARE_API_TOKEN = "<token: Account Settings Read; Workers Scripts, R2 and D1 Edit;
for --zone/--hostname also Zone Read, DNS Read, Workers Routes Read>"
node deploy/cli.mjs whoami
node deploy/cli.mjs plan --account <account id> --name snaps
# no workers.dev name on the account yet? The plan asks you to "Choose your free
# workers.dev name": add --subdomain <your-company> to both commands (account-wide).
# A subdomain of your domain as well: add --zone <zone id> --hostname snaps.example.com
node deploy/cli.mjs deploy --account <account id> --name snaps --yes
# prints the Studio address and the Admin key once, and writes deployment.json here
# Option 2: plain Wrangler (create the bucket and database, set their ids in wrangler.jsonc)
npm install
npx wrangler r2 bucket create maxisnap-studio-media
npx wrangler d1 create maxisnap-studio
npx wrangler secret put ADMIN_KEY
npm run sync
npx wrangler deploy 部署作業只會顯示一次 Studio 網址和管理員金鑰,並在執行它的資料夾中寫入 deployment.json。請保留該檔案:update 和 remove 會用到它。
確認它能正常運作
curl.exe -s -H "X-Dashboard-Key: <Admin key>" https://<studio address>/api/health.php
# {"ok":true,"app":"Maxisnap Studio","version":"…"} the Cloudflare edition adds "edition":"cloudflare" 接著在瀏覽器中開啟 Studio 網址,並使用管理員金鑰登入。401 表示金鑰錯誤;404 表示網址或資料夾錯誤。
連接 Maxisnap
- Windows 版 Maxisnap:開啟「設定 → 帳戶 → Maxisnap Studio 設定精靈」,按一下「開始使用」,然後一直按「下一步」,直到第 4 步「連接 Maxisnap」。貼上 Studio 網址和金鑰,按一下「測試連線」,再按「下一步」,到最後一頁時按一下「完成並儲存」。設定時取得的管理員金鑰可以使用,儀表板「People & access」中的上傳代碼也可以。
- Mac 版 Maxisnap:開啟「Settings → Welcome & Help → Studio Setup Guide」,選擇「I already have a dashboard」。貼上 Studio 網址和金鑰,按一下「Test Connection」,再按「Next」,最後按一下「Finish & Save」。
了解上傳 API
- Maxisnap 應用程式會透過 X-Dashboard-Key 標頭上傳到 api/upload.php。系統接受圖片(PNG、JPG、GIF 和 WebP)與影片(MP4、WebM 和 MOV)。
- Windows 版和 Mac 版 Maxisnap 會以單一請求把每次上傳送到 Cloudflare 版 Studio,而它每個檔案最大可接受 25 MB。
- Cloudflare 版還提供適用於較大檔案的分段上傳 API,「Developer guide」中有說明:api/upload/start、part 和 complete。
- 分享頁面及其媒體檔案使用下列路徑;其他所有路徑都是內部使用的:
/<slug>/<slug>.<ext>
日後更新或移除 Studio
PHP:只替換 snaps/How to update.txt 中列出的檔案,然後清除主機和 CDN 的快取。擷取內容、成員、品牌設定和各項設定都會保留。
Cloudflare:請在較新套件的 cloudflare 資料夾中執行下列指令,並先把舊的 deployment.json 複製進去。
# Update: from a newer package's cloudflare folder, with the old deployment.json copied in
node deploy/cli.mjs update --record deployment.json --yes
# New Admin key (shown once):
node deploy/cli.mjs update --record deployment.json --yes --new-admin-key
# Remove the custom domain and the Worker; the bucket and database (the captures) stay
node deploy/cli.mjs remove --record deployment.json --yes
# Also delete every capture: cannot be undone
node deploy/cli.mjs remove --record deployment.json --yes --delete-data 如果發生問題
健康檢查回應 401
{"error":"unauthorized"}
金鑰不正確、已被停用或比 Studio 接受的長度還短,或是 PHP 主機上的設定尚未完成。請在 X-Dashboard-Key 標頭中傳送金鑰,絕對不要放在網址中。
健康檢查回應 404,或回應 HTML 而不是 JSON
網址或資料夾有誤、主機忽略了 Studio 的 .htaccess 規則(使用 nginx,或未啟用重寫功能的 Apache),或是由 CDN 或安全防護層代替 Studio 回應。在 nginx 上,請依照 snaps/.htaccess 建立相同的路由與拒絕規則;「Developer guide」中列有這些規則。
健康檢查回應 429
Too many incorrect codes. Wait a few minutes before trying again.
重複輸入錯誤金鑰之後,Studio 會在 15 分鐘內拒絕來自你所在網路的後續嘗試。請稍候,再用正確的金鑰重試。
在自訂網域上,上傳回應 403
該主機名稱上的 Cloudflare Access、WAF 規則或 Bot Fight Mode 擋住了應用程式的上傳。請將 Studio 的主機名稱排除在外;技術簡介中有檢查清單。Viewer 代碼上傳時也會收到 403:請改用管理員金鑰或上傳代碼。
上傳回應 413
使用 PHP 時,upload_max_filesize、post_max_size,或主機或 CDN 的限制小於檔案大小;Studio 自己的限制是 your-settings.php 中的 max_upload_mb。
在 Cloudflare 上,單一請求最多可承載 25 MB;更大的檔案需要使用分段上傳 API。
Cloudflare 版 Studio 的每個頁面都回應 503
This Studio is not set up correctly: its ADMIN_KEY secret must be at least 16 characters.
請設定更長的 ADMIN_KEY 機密,例如搭配 update 指令與 --new-admin-key,或使用 npx wrangler secret put ADMIN_KEY。
計畫停在標有「x」的一行
每一行標示「x」的項目都是阻擋項目,並會說明該怎麼做:開啟 R2;若帳戶沒有 workers.dev 名稱,就加上 --subdomain;或是在名稱無效、已被使用或不在該網域範圍內時,更改 --name、--zone 或 --hostname。然後重新產生計畫。已被使用的儲存貯體和資料庫名稱,會自動取用下一個可用的名稱,不會形成阻擋項目。
CLI 拒絕接受 deployment.json
deployment.json belongs to the Studio "snaps". Keep it, and pass --record <another file> for this one.
每個 Studio 都有自己的記錄檔。請保留該檔案,並用 --record 為第二個 Studio 指定另一個記錄檔。沒有任何記錄檔時,update 和 remove 都無法執行;請傳入正確檔案的路徑。
workers.dev 上的 Studio 顯示「Error 1027」
已達到免費方案的每日請求上限。這項上限會在 UTC 午夜重設。
還需要協助嗎?
請寄電子郵件給我們,會有真人回覆你,通常在一個工作天內。提供下列資料,能讓我們一次就完整回覆你:
- 你選擇的設定方式,以及你目前進行到哪一步。
- 目前畫面的螢幕截圖,並完整呈現任何錯誤訊息。
- 你打算把 Studio 放在哪裡:新的或現有的 Cloudflare 帳戶,或是你的虛擬主機公司名稱。
- 你的 Maxisnap 版本:在 Windows 上位於「設定 → 關於」;在 Mac 上則位於「Maxisnap → About Maxisnap」。
請不要把你的管理員金鑰、Cloudflare 金鑰或密碼寄給我們。我們不需要它們就能協助你。