Digital Ocean 架 Server 教學
建立虛擬主機
Digital Ocean 建立虛擬主機
-
Create a new project
-
Create a Droplets
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
-
Choose an image
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
-
Choose a plan
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
我選擇 $6/mo 的方案
- Choose a datacenter region
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
我是選擇 San Francisco 3,感覺也可以考慮選擇新加坡的
- 特殊功能
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
應該是不用勾選
- 登入憑證
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
建議用 SSH Key 比較安全
-
命名以及標籤
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
-
備份功能
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
考慮以後再來使用
- 創建成功
Domain
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
A Record
、 CName Record
要記得去 Hinet 那邊設定 DNS
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
環境安裝
前置作業
- 查看作業系統
- 更新套件管理器
- 新增使用者
安裝 Nginx
安裝 php
安裝 mysql
安裝 Mysql 出現 [MY-011065] 問題:解決方法
原因:因為記憶體太小了
在硬碟內建立 swap 空間來彌補實體記憶體的不足
進去 Mysql 後要來建立使用者帳號:
安裝 Composer
安裝 Git
部屬專案
Git 下載
建立 ssh hey
修改 Nginx 設定檔
Nginx 本身的 config 檔案儲存於 /etc/nginx/nginx.conf
。
Nginx 的 Virtual Host 檔案會儲存在 /etc/nginx/sites-available/
;然後在 /etc/nginx/sites-enabled/
會有一個軟連結 default
指向 /etc/nginx/sites-available/default
。
通常是建議用域名來命名(沒有強制),首先先複製 default
檔案然後再用 vim
來修改,會比較快:
Laravel 官方網站有範例:

路徑大小寫請不要打錯

那個問號很重要!!少了問號你接下來 url 的 query 都吃不到了

改完後,切換到 sites-enabled
,我們要先把原本的軟連結 default 刪除,之後建立一個軟連結到我們剛剛新增好的 vhost 檔案。
接著測試並重新啟動 Nginx
初始化 Laravel 專案
設定資料庫
開另一個終端機
更改權限
申請 https
- 安裝 Certbot
測試評分:
https://www.ssllabs.com/ssltest/analyze.html