部署分三大块
1、按量付费购买腾讯云服务器一小时(2毛钱)。
2、部署安装部署nginx并配置反向代理。
3、把代码直接扔到ngxin中。
【一】
购买腾讯云服务器。(腾讯云应该给我广告钱)
1、购买服务器:
https://cloud.tencent.com/product/cvm
【二】
1、安装nginx
//1.1、安装nginx环境
yum install -y gcc gcc-c++ autoconf pcre pcre-devel make automake
//1.2、配置Nginx官方Yum源
vim /etc/yum.repos.d/nginx.repo
[nginx]
name=nginx repo
baseurl=http://nginx.org/packages/centos/6/$basearch/
gpgcheck=0
enabled=1
//1.3、安装Nginx
yum install nginx -y
//1.4、查看Nginx安装目录
rpm -ql nginx
2、配置代理
vim /etc/nginx/nginx.conf
root /soft/code/dist;
location / {
index index.html index.htm;
}
location ^~ /api/ {
proxy_pass https://music.163.com/api/;
proxy_redirect default;
proxy_set_header Host music.163.com;
proxy_set_header Origin http://music.163.com;
proxy_set_header Referer http://music.163.com;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_connect_timeout 30;
proxy_send_timeout 60;
proxy_read_timeout 60;
proxy_buffer_size 32k;
proxy_buffering on;
proxy_buffers 4 128k;
proxy_busy_buffers_size 256k;
proxy_max_temp_file_size 256k;
}
启动 nginx
/usr/sbin/nginx
【三】
1、打包代码
源码地址:
https://gitee.com/xrzi2016/CloudMusic
git clone https://gitee.com/xrzi2016/CloudMusic.git
cd CloudMusic
npm install
npm run build
2、扔代码上nginx
F:\code\CloudMusic