最近測試中國新專案時常遇到那邊所開發的CMS,原先慣用的HestiaCP並沒有支援造成需要另外設定。
所以租了一台專用的主機,原先考慮使用 BT宝塔面板,但是查一下評價發現後台數據會回傳、漏洞問題嚴重甚至影響整台設備,後來發現1Panel 在功能上可以取代宝塔面板,而且是開源、使用Docker進行快速部署。
Table of Contents
1Panel 硬體支援
官方建議值1GB
如果是使用WordPress架設網站,推薦使用2G以上
1Panel 系統版本
- RedHat
- CentOS
- Ubuntu
- Debian
- openEuler
1Panel 安裝
首先建立一台Ubuntu伺服器後,可以直接輸入下面的腳本快速安裝,安裝目錄使用預設即可
官方文件:https://1panel.cn/docs/installation/online_installation/
curl -sSL https://resource.fit2cloud.com/1panel/package/quick_start.sh -o quick_start.sh && sudo bash quick_start.sh

接下來設定登入阜號、自訂後台位置、帳號、密碼,等跳出「服務啟動成功」就可以登入。
登入後台所需的資料皆會在下方提供

1Panel 後台設定
輸入網址後會來到後台登入畫面,輸入帳號密碼並勾選同意協議後登入

在「概覽」可以看到伺服器目前的資源使用狀況

面板設定
「面板設置」可以自行設定畫面的顯示樣式、語系和帳號密碼設定

在「關於」可以查看目前使用的版本,若需要更新可以點擊「檢查更新」檢查是否有新版本,根據官方紀錄平均每個月一次bug修復和提供新功能

工具箱
在「快速設置」可以設定主機名稱、時區、時間等基本設定

「緩存清理」可以快速刪除網站所累積的無用資料

應用商店
在「應用商店」中匯集了所有網站架設所需的軟體,接下來要先進行軟體安裝
網頁伺服器有提供OpenResty和OpenLiteSpeed兩種
資料庫有提MySQL、MariaDB、SQL Server、PostgreSQL、MongoDB和Memcached、Redis等

在安裝每一款軟體時還可以指定版本、阜號及限制CPU跟記憶體資源使用

這邊會先安裝OpenResty跟MariaDB

運行環境
若要安裝php、java、node.js、go、python程式語言,則需要從「運行環境」安裝

在安裝程式語言一樣可在選擇版本、擴展,映像檔則是只有中國的版本可以選擇,點擊確認後就會執行安裝

在安裝的部分所花費的時間會稍微久一點,安裝進度可以從日誌中去查看

主機設定
在「文件」可以看到所有的文件跟權限,也可以從「網站」->「網站目錄」前往指定文件路徑

「監控」可以看到網站即時的實體資源使用數據

防火牆設定
前往「防火牆」設定主機防火牆

依使用習慣將常用阜號開啟即可

SSH設定
在SSH管理,可以修改阜號跟指定IP才能登入

1Panel 網站部署
一鍵架設網站
當前面都設定好了,接下來就是開始架設網站。
1Panel有提供一鍵部署,選擇要安裝的應用、版本跟主域名,剩下的就是由系統自動產生

普通網站架設
如果要架設的網站不是上面常見的開源軟體而是客製化網站,就要選擇「運行環境」、「反向代理」或是「靜態網站」。
假設要架設普通php網站,在運行環境,選擇php的版本、輸入網址後點選確認即可。

這時會看到剛剛創建的網站狀態已啟動

SSL證書設定
網站可以運作接下來要申請SSL證書,首先點擊創建Acme帳戶

輸入信箱、帳號類型選擇Let’s Encrypt SSL、密鑰算法選擇 RSA2048

這時Acme帳戶已經建立完成

接著點擊左上角申請證書,「從網站中獲取」選擇要申請SSL證書的網站
「Acme帳戶」選擇剛剛註冊的帳號
「驗證方式」這邊推薦用HTTP是最簡單的方式,若選擇DNS帳號有支援阿里云、腾讯云、Cloudflare、NameCheap、GoDaddy等廠商

點擊確認,將網址跟證書綁定

等待綁定,出現「證書成功」就代表完成了

然後要記得順便將自動續簽開啟

網站設定
回到網站中,「HTTPS」要開啟讓用戶前往有加密的網站

「流量限制」這邊可以開啟限制用戶短時間的多次網站訪問請求,有輕微阻擋Dos攻擊效果

容器設定
在前面我們有安裝網頁伺服器OpenResty、資料庫MariaDB、程式語言PHP,這邊都是以容器的方式執行,點擊更多可以進行設定。
但是要刪除前要注意「關聯資源」,如果直接刪除鏡像檔會造成關聯資源的檔案無法成功刪除。

高級功能
在這邊的區塊功能是屬於付費的,一年360人民幣。
相關的免費替代功能有Cloudflare、Zibbix、Analytics

1Panel 重設密碼
登入1Panel後台需要記住阜號、自訂網址、帳號密碼,萬一忘記就只能重設。
登入主機後,輸入以下指令會跳出登入的後台網址跟帳號
1pctl user-info

接著輸入下面指令重設密碼,設定完成後會顯示剛剛設定的密碼
1pctl update password

1Panel 重設後台網址
在後台選擇以自簽證書的方式綁定會出現「Client sent an HTTP request to an HTTPS server」錯誤導致無法登入,這時可以用以下兩種指令去重新設定。
取消強制以https方式登入
1pctl reset https
重新綁定網址
1pctl reset domain
1Panel 常用指令
最後輸入以下命令會跳出常用的指令
1pctl --help
