最近要部署一台新的 Server, 想說這次把它做一個紀錄好了
Server: Ubuntu 20.04.3 LTS
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 更新系統並安裝 nginx | |
sudo apt -y update && sudo apt -y upgrade; | |
sudo apt install nginx; | |
# 安裝 node 14 LTS | |
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.37.2/install.sh | bash; | |
source ~/.bashrc; | |
nvm install 14; | |
# 建立 ssh key | |
ssh-keygen -t rsa -b 4096 -C "yourMail@gmail.com"; | |
# 啟動 nginx | |
sudo service nginx start |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# /etc/nginx/sites-available/default | |
server { | |
listen 80 default_server; | |
listen [::]:80 default_server; | |
root /var/www/html/MyWeb; | |
server_name xxx.xxx.xxx; | |
#server_name _; | |
location ^~ / { | |
index index.html index.htm; | |
try_files $uri $uri/ @rewrites; | |
} | |
location @rewrites { | |
rewrite ^.*$ /index.html last; | |
} | |
location /admin-api/ { | |
proxy_pass http://xx.xx.xx.xx/apis/admin/v1/; | |
} | |
} |
就這樣。
0 意見:
張貼留言