前端部署静态资源

105 阅读1分钟

1.申请一台服务器

image.png

2.申请完后查看自己的服务器

image.png

我这里的系统是 CentOS 7.6

image.png

3.登录

image.png

4.安装宝塔

image.png

各操作系统宝塔安装命令:

Centos安装脚本

yum install -y wget && wget -O install.sh http://download.bt.cn/install/install.sh && sh install.sh

Ubuntu/Deepin安装脚本

wget -O install.sh http://download.bt.cn/install/install-ubuntu.sh && sudo bash install.sh

Debian安装脚本

wget -O install.sh http://download.bt.cn/install/install-ubuntu.sh && bash install.sh

Fedora安装脚本

wget -O install.sh http://download.bt.cn/install/install.sh && bash install.sh

5.成功后会得到宝塔的登录地址和账号密码

切记宝塔地址和账号密码要保存起来

6.进入宝塔需要开启8888端口

image.png

7.登录宝塔

image.png

8.进入软件商店,下载nginx

image.png

9.添加站点,按要求填写地址

我这里端口号是9527,需要去防火墙开启9527端口(步骤6)

image.png

10.进入文件,刚添加的站点就是文件夹,把里面的内容删除

image.png

11.修改vue.config.js的配置

publicPath : '/项目名/'

outputDir: '项目名' image.png

12.修改router.js的配置

image.png

13.npm run build 打包项目

14.打包后的文件上传到目录中

image.png

15.查看项目

公网ip + 端口号 + '/项目名'

image.png

image.png