vue部署到服务器
- 开发环境 vue+element
- 电脑系统 windows 10 专业版
- 在开发的过程中,咱们常常会应用到 vue 进行开发我的项目,然而开发完我的项目之后,要进行部署到服务器,接下来,咱们就聊聊怎么部署到服务器,办法如下:
- 首先咱们要对前端我的项目 vue 我的项目 进行打包,打包办法,我应用的是 npm run build 也能够应用其余的打包办法!在这里就不做扩大了。打包实现之后,咱们会失去一个 dist 的文件夹,咱们只须要拷贝这个文件就能够啦。
- 咱们还须要下载 nginx 下载实现之后,对其进行一些配置,配置如下:
- 咱们解压之后会看到这里文件
- 双击进入
- 双击
- 选中,编辑这个文件
- 代码如下:
#user nobody;worker_processes 1;#error_log logs/error.log;#error_log logs/error.log notice;#error_log logs/error.log info;#pid logs/nginx.pid;events { worker_connections 1024;}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 0; keepalive_timeout 65; #gzip on; server { listen 8098; server_name localhost; #charset koi8-r; #access_log logs/host.access.log main; location / { root G:\dist; index index.html index.htm; } location ^~ /api/admin/ { proxy_pass http://192.168.1.98:8090; } #error_page 404 /404.html; # redirect server error pages to the static page /50x.html # error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } # proxy the PHP scripts to Apache listening on 127.0.0.1:80 # #location ~ \.php$ { # proxy_pass http://127.0.0.1; #} # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 # #location ~ \.php$ { # root html; # fastcgi_pass 127.0.0.1:9000; # 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 8000; # listen somename:8080; # server_name somename alias another.alias; # location / { # root html; # index index.html index.htm; # } #} # HTTPS server # #server { # listen 443 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; # } #}}
- 只须要在以下局部进行批改就能够啦:
//nginx 配置到了这里就完结啦!
6.接下来,咱们要查看服务器是否配置了 Java 环境,如果没有配置 java环境就配置以下,配置办法如下:
- 首先要装置 java,办法如下:
- windows7 中找到我的电脑,右击属性
- windows10 找到此电脑,点击左上角的属性:你会看到如下界面:
- 点击进入
- 点击进入
- 点击进入
- 选中 path,而后点击编辑,而后点击新建
- 把 java 装置的门路粘贴就能够啦:
- 把这两个门路别离粘贴到 对应的两个 path 上面,留神:这两个 path 都有右这两个门路!
- cmd 输出 java javac 看看是否输入这样的内容:
- 如果输入的后果和这个相似示意,java配置胜利!
- 接下来你须要把后盾的代码复制,在 C盘新建一个文件,而后粘贴就能够啦!
- 找到文件的门路,而后点击门路输出 cmd
- 在终端中输出 jfinal.bat start 就能够啦!
- //留神:这个 jfinal.bat 是文件的名字,你要依据文件的名字进行变通,就能够啦。
- 关上浏览器 输出:localhost:8098 回车你就会看到成果啦!
- vue我的项目部署到了这里就完结啦!是不是很简略!是不是很棒!让咱们一起致力,走向巅峰!