引子
作为一个前端开发工程师,每天和浏览器、业务代码打交道,对于“前端”的概念算是比较熟悉了,主流的框架、工具等都能玩得转,但总觉得自己一直都被禁锢在小小的所谓“前端”的圈子中——因为除此之外的知识点还是比较薄弱的,想要提升自己“前端知识”以外的技能树,刚好腾讯云有”良心活动”,于是就上车了。
1. 购买腾讯云服务器
2. 购买域名
进入到控制台域名服务,启动域名解析
复制代码
3. 安装Nginx
安装nginx
yum install nginx
复制代码
修改host
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(新机子必备)
安装证书
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
复制代码
证书安装成功
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
复制代码
配置nginx
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服务
git clone https://mywork.git
cd mywork
npm i
pm2 ./bin/www
复制代码
© 版权声明
文章版权归作者所有,未经允许请勿转载。
THE END