云服务器vue项目的简单部署

云服务器vue项目的简单部署,第1张

服务器vue项目的简单部署

(1)购买服务器

阿里云,腾讯云等。

(2)安装xshell和xftp。( *** 作云服务器)。

(3)安装nginx

1、切换到对应路径(ls可以查看当前路径下的所有下一级文件

cd /

cd etc

2、安装nginx

yum install nginx

(这一步完成后,浏览器打开服务器ip地址,可以看到nginx的默认界面)

(4)配置nginx.conf文件

(1)location / {

root /root/www/dist(项目文件地址)

index index.html(默认界面)

}

(2)location /api {

proxy_pass http://127.0.0.1

}

备注:我是请求api时,调用了别的服务器的数据,所以要写这个,如果你的项目没有,可以不用写)

/api 当你访问的路径起始是/api

(127.0.0.1是要访问的服务器地址)

(3)user nginx 改为 user root;(root为主机名,linux是root)

(4)注释掉部分代码

1、include /etc/nginx/conf.d/*.conf;

2、include /etc/nginx/default.d/*.conf;

 (5)测试nginx.conf文件是否正确

  nginx -t

 (6)重启nginx

service nginx restart

(7)浏览器打开服务器ip地址就可以看到你写的项目了。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zaji/5715078.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-12-18
下一篇 2022-12-17

发表评论

登录后才能评论

评论列表(0条)

保存