小前端er折騰服務器的經驗

引子

做爲一個前端開發工程師,天天和瀏覽器、業務代碼打交道,對於「前端」的概念算是比較熟悉了,主流的框架、工具等都能玩得轉,但總以爲本身一直都被禁錮在小小的所謂「前端」的圈子中——由於除此以外的知識點仍是比較薄弱的,想要提高本身「前端知識」之外的技能樹,恰好騰訊雲有"良心活動",因而就上車了。html

1. 購買騰訊雲服務器

2. 購買域名

進入到控制檯域名服務,啓動域名解析
複製代碼

3. 安裝Nginx

安裝nginx前端

yum install nginx
複製代碼

修改hostnode

vi /etc/host
vi /etc/sysconfig/network
複製代碼

4. 祕鑰登錄服務器(新機子必備)

經過祕鑰登錄
ssh-keygen -t rsa
ssh-copy-id -i ~/.ssh/id_rsa.pub root@1x0.78.xx.xx
登錄命令 ssh 'root@1x0.78.xx.xx'
複製代碼

5. 使用https(新機子必備)

安裝證書nginx

cd /usr/local/bin
wget https://dl.eff.org/certbot-auto
chmod a+x certbot-auto
sudo ./certbot-auto --nginx
sudo ./certbot-auto renew --dry-run
複製代碼

證書安裝成功git

IMPORTANT NOTES:
 - Congratulations! Your certificate and chain have been saved at
   /etc/letsencrypt/live/xxxx.com/fullchain.pem. Your cert
   will expire on 20XX-09-23. To obtain a new or tweaked version of
   this certificate in the future, simply run certbot again. To
   non-interactively renew *all* of your certificates, run "certbot renew"
 - If you like Certbot, please consider supporting our work by:

   Donating to ISRG / Let's Encrypt: https://letsencrypt.org/donate Donating to EFF: https://eff.org/donate-le 複製代碼

配置nginxnpm

server {
    listen       443 ssl http2 default_server;
    listen       [::]:443 ssl http2 default_server;
    server_name  xxxx.com;
    root         /blog;

    ssl_certificate "/etc/letsencrypt/live/xxxx.com/fullchain.pem";
    ssl_certificate_key "/etc/letsencrypt/live/xxxx.com/privkey.pem";
    ssl_trusted_certificate /etc/letsencrypt/live/xxxx.com/chain.pem;

    # Load configuration files for the default server block.
    include /etc/nginx/default.d/*.conf;

    location / {
    }

    error_page 404 /404.html;
        location = /40x.html {
    }

    error_page 500 502 503 504 /50x.html;
        location = /50x.html {
    }
}
複製代碼

6. pm2部署node服務

安裝pm2瀏覽器

npm install -g pm2
複製代碼

安裝node服務bash

git clone https://mywork.git
cd mywork
npm i
pm2 ./bin/www
複製代碼
相關文章
相關標籤/搜索