1.项目打包生成dist文件夹

在项目根目录下打开cmd窗口,输入命令

npm run build
//生成dist文件夹

2.将dist文件夹上传到centos7

使用scp命令或者用远程连接工具将打包好的dist文件夹上传到服务器或者虚拟机的某个位置。

打开cmd命令输入:
scp -r E:\\dist root@192.168.3.5:/home/dist
输入root 用户密码,等待上传成功即可

E:\dist 为dist所在目录
root 为虚拟机root用户
192.168.3.5 为虚拟机ip
/home/ 为将dist文件上传虚拟机上home目录

3.安装nginx

推荐链接:
https://www.cnblogs.com/kaid/p/7640723.html

4.nginx的几个常用命令

//进入  /sbin目录下
cd /usr/local/nginx/sbin
//启动nginx
./nginx
//检查更改的配置
./nginx -t
//重新加载
./nginx -s reload
//停止nginx
./nginx -s stop

5.修改nginx的conf配置

//进入conf
cd /usr/local/nginx/conf
vim nginx.conf

nginx.conf这个是全部的配置文件,可以复制下来参考。

#user  nobody;
worker_processes ;

#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;

#pid logs/nginx.pid;


events {
worker_connections ;
}


http {
include mime.types;
default_type application/octet-stream;

#log_format main '$remote_addr - $remote_user [$time_local] "$request" '
# '$status $body_bytes_sent "$http_referer" '
# '"$http_user_agent" "$http_x_forwarded_for"';

#access_log logs/access.log main;

sendfile on;
#tcp_nopush on;

#keepalive_timeout ;
keepalive_timeout ;

#gzip on;

server {
listen ;
server_name 192.168.111.128;
index index.html index.htm;
root /app/fusionwork_deployment/web;
#charset koi8-r;

#access_log logs/host.access.log main;

#location / {
# root html;
# index index.html index.htm;
#}

#error_page /.html;

# redirect server error pages to the static page /50x.html
#
error_page /50x.html;
location = /50x.html {
root html;
}

# proxy the PHP scripts to Apache listening on 127.0.0.1:
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}

# pass the PHP scripts to FastCGI server listening on 127.0.0.1:
#
#location ~ \.php$ {
# root html;
# fastcgi_pass 127.0.0.1:;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
# include fastcgi_params;
#}

# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}


# another virtual host using mix of IP-, name-, and port-based configuration
#
#server {
# listen ;
# listen somename:;
# server_name somename alias another.alias;

# location / {
# root html;
# index index.html index.htm;
# }
#}


# HTTPS server
#
#server {
# listen ssl;
# server_name localhost;

# ssl_certificate cert.pem;
# ssl_certificate_key cert.key;

# ssl_session_cache shared:SSL:1m;
# ssl_session_timeout 5m;

# ssl_ciphers HIGH:!aNULL:!MD5;
# ssl_prefer_server_ciphers on;

# location / {
# root html;
# index index.html index.htm;
# }
#}

}

6.将端口的防火墙关掉

//8088,自己指定端口
firewall-cmd --permanent --add-port=/tcp --zone=public
//重新加载
firewall-cmd --reload

7.重新加载配置,启动nginx

//检查配置是否正确
./nginx -t
//启动nginx
./nginx

8.浏览器访问本机虚拟机ip

http://192.168.111.128

9.路径重写rewrite

可以看下这个,写的比较详细
https://blog.csdn.net/hotlinhao/article/details/88355125
http://www.pianshen.com/article/9593257962/

Centos+Nginx部署Vue项目的更多相关文章

  1. nginx部署vue项目

    nginx是一个高性能的HTTP和反向代理服务器.因此常用来做静态资源服务器和后端的反向代理服务器.本文主要记录使用nginx去部署使用vue搭建的前端项目,项目基于vue官方的脚手架vue-cli构 ...

  2. CentOS7 安装nginx部署vue项目

    简单描述:代码开发完了,需要环境来运行测试.服务器上没有nginx,搞起搞起.   在Centos下,yum源不提供nginx的安装,可以通过切换yum源的方法获取安装.也可以通过直接下载安装包的方法 ...

  3. Centos7 使用nginx部署vue项目

    一.安装nginx #设置源 sudo rpm -Uvh http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0 ...

  4. Docker镜像+nginx 部署 vue 项目

    一.打包vue项目 在开发完的vue项目输入如下命名,打包生成dist文件夹 yarn build / npm run build 此时根目录会多出一个文件夹:dist文件夹,里面就是我们要发布的东西 ...

  5. nginx部署vue项目 解决方案

    给前端同事部署了web项目之后,访问发现除了index.html可以访问,其他的路径使用了“伪静态”.比如访问:http://localhost:8081/user/login,访问即报404错误,这 ...

  6. 关于nginx部署vue项目的两个问题

    首先我使用的是后端接口+前端vue的形式,这样就涉及到跨域的问题.我是这样配置的: server { listen 80; server_name www.liangyp.xyz;//访问网址 loc ...

  7. Nginx部署vue项目的配置

    . 官网下载 http://nginx.org/en/download.html 选择stable version nginx/Windows-1.14.1 pgp . 解压 然后配置环境变量,如果环 ...

  8. 在nginx上部署vue项目(history模式);

    在nginx上部署vue项目(history模式): vue-router 默认是hash模式,使用url的hash来模拟一个完整的url,当url改变的时候,页面不会重新加载.但是如果我们不想has ...

  9. 在nginx上部署vue项目(history模式)--demo实列;

    在很早之前,我写了一篇 关于 在nginx上部署vue项目(history模式) 但是讲的都是理论,所以今天做个demo来实战下.有必要让大家更好的理解,我发现搜索这类似的问题还是挺多的,因此在写一篇 ...

随机推荐

  1. python- generator生成器

    什么是生成器? 通过列表生成式,我们可以直接创建一个列表,但是,受到内存限制,列表容量肯定是有限的,而且创建一个包含100万个元素的列表,不仅占用很大的存储空间,如果我们仅仅需要访问前面几个元素,那后 ...

  2. python常见报错信息!错误和异常!附带处理方法

    作为 Python 初学者,在刚学习 Python 编程时,经常会看到一些报错信息. Python 有两种错误很容易辨认:语法错误和异常. Python assert(断言)用于判断一个表达式,在表达 ...

  3. 深入掌握K8S Pod

    k8s系列文章: 什么是K8S K8S configmap介绍 Pod是k8s中最小的调度单元,包含了一个"根容器"和其它用户业务容器. 如果你使用过k8s的话,当然会了解pod的 ...

  4. 从LocalDateTime序列化探讨全局一致性序列化

    日拱一卒无有尽,功不唐捐终入海. 楔子 前两周发了三篇SpringSecurity和一篇征文,这周打算写点简单有用易上手的文章,换换脑子,休息一下. 今天要写的是这篇:从LocalDateTime序列 ...

  5. 深入理解JVM(二)垃圾收集器

    GC三问: 哪些内存需要回收? 什么时候回收? 如何回收? 程序计数器.虚拟机栈.本地方法栈随线程而生,随线程而灭,栈帧的内存分配在类结构确定下来就已知,在方法结束或者线程结束时就会回收.所以垃圾回收 ...

  6. LQB201804第几个幸运数

    我自己一开始想的差不多,但是好像想得是vector+sort.... 直接用set它不香吗? 还有就是寻找下一个数的时候,没有用upperbound,,, 我想的大概是遍历一遍(就是用for对这个函数 ...

  7. 面试官你好,我已经掌握了MySQL主从配置和读写分离,你看我还有机会吗?

    我是风筝,公众号「古时的风筝」,一个简单的程序员鼓励师. 文章会收录在 JavaNewBee 中,更有 Java 后端知识图谱,从小白到大牛要走的路都在里面. 面试官:我看你简历上写的你们公司数据库是 ...

  8. 11-19 hashlib模块

    Python的hashlib提供了常见的摘要算法,如MD5,SHA1等等. 什么是摘要算法呢? 摘要算法又称哈希算法.散列算法.它通过一个函数,把任意长度的数据转换为一个长度固定的数据串(通常用16进 ...

  9. PHP preg_last_error() 函数

    preg_last_error 函数用于返回最后一个 PCRE 正则执行产生的错误代码.高佣联盟 www.cgewang.com 语法 int preg_last_error ( void ) 实例 ...

  10. PHP stripslashes() 函数

    实例 删除反斜杠: <?php高佣联盟 www.cgewang.comecho stripslashes("Who's Peter Griffin?");0.000.00.. ...