vue项目打包放到服务器.

文章目录

  • 如何把vue.js项目部署到服务器上-有茶就喝茶-博客园
    • 改之前运行.-Wrong operation
    • 删除dist改config/index.js之后运行.-Proper operation
  • 新建ftp账号.管理webapps文件夹下的东西.
  • 阿里云视频学习笔记._gwdfff的博客-CSDN博客
    • 执行结果:
      • 问题何在.?(2020-1-17 1:58:27)
  • 处理完毕success(2020-1-17 2:16:12)
      • 求解(2020-1-17 1:48:04)
  • 其他
    • 如何访问(2020-1-17 1:52:35)
  • 总结

如何把vue.js项目部署到服务器上-有茶就喝茶-博客园

1-改一下config/index.js文件,如下图,把assetsPublicPath: ‘./’,

productionSourceMap: false

我搜到两处.
这两处.

dev: {

build: {

作者指build

改之前运行.-Wrong operation

PS E:\AllProjects\cmdProjects\myVue> npm run build

> myvue@1.0.0 build E:\AllProjects\cmdProjects\myVue
> node build/build.js

Hash: 9150723b55351e9668b6
Version: webpack 3.12.0   
Time: 6496ms
                                                  Asset       Size  Chunks             Chunk Names
               static/js/vendor.ef94d2f8cb15d949ea3e.js     121 kB       0  [emitted]  vendor
                  static/js/app.b22ce679862c47a75225.js    11.6 kB       1  [emitted]  app
             static/js/manifest.2ae2e69a05c33dfc65f8.js  857 bytes       2  [emitted]  manifest
static/css/app.30790115300ab27614ce176899523b62.css.map  797 bytes          [emitted]
           static/js/vendor.ef94d2f8cb15d949ea3e.js.map     611 kB       0  [emitted]  vendor
              static/js/app.b22ce679862c47a75225.js.map    22.2 kB       1  [emitted]  app
         static/js/manifest.2ae2e69a05c33dfc65f8.js.map    4.97 kB       2  [emitted]  manifest
                                             index.html  507 bytes          [emitted]

  Build complete.

  Tip: built files are meant to be served over an HTTP server.
  Opening index.html over file:// won't work.

删除dist改config/index.js之后运行.-Proper operation

PS E:\AllProjects\cmdProjects\myVue> npm run build

> myvue@1.0.0 build E:\AllProjects\cmdProjects\myVue
> node build/build.js

Hash: acad09a271cb482a3707
Version: webpack 3.12.0
Time: 5262ms
                                              Asset       Size  Chunks             Chunk Names
           static/js/vendor.ef94d2f8cb15d949ea3e.js     121 kB       0  [emitted]  vendor
              static/js/app.86416fbc3a3890459727.js    11.5 kB       1  [emitted]  app
         static/js/manifest.3ad1d5771e9b13dbdad2.js  800 bytes       2  [emitted]  manifest
static/css/app.30790115300ab27614ce176899523b62.css  363 bytes       1  [emitted]  app
                                         index.html  511 bytes          [emitted]

  Build complete.

  Tip: built files are meant to be served over an HTTP server.
  Opening index.html over file:// won't work.

项目文件的dist文件夹下面的static和index.html就是打包后的文件。然后我自己创建了cccBlog文件夹,把static和index.html拷贝到cccBlog下面,然后向服务器上传这个cccBlog文件夹就可以了。

新建ftp账号.管理webapps文件夹下的东西.

(2020-1-17 1:42:27)
并且.上传成功.

阿里云视频学习笔记._gwdfff的博客-CSDN博客

由之前的笔记.重启tomcat

service tomcat restart

执行结果:

[root@ bin]# service tomcat restart
Stoping Tomcat
Using CATALINA_BASE:   /usr/local/tomcat
Using CATALINA_HOME:   /usr/local/tomcat
Using CATALINA_TMPDIR: /usr/local/tomcat/temp
Using JRE_HOME:        /usr/java/default
Using CLASSPATH:       /usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar
grep: 2609: No such file or directory
/etc/init.d/tomcat: line 70: [: =: unary operator expected
waiting for processes to exit

add(2020-1-17 1:55:57)
这里用vim打开该文件.查看.第70行:

[root@ init.d]# vim tomcat
let kwait=$SHUTDOWN_WAIT
    count=0;
    until [ `ps -p $pid | grep -c $pid` = '0' ] || [ $count -gt $kwait ]//第70行
    do
      echo -n -e "\e[00;31mwaiting for processes to exit\e[00m\n";
      sleep 1
      let count=$count+1;
    done

问题何在.?(2020-1-17 1:58:27)

处理完毕success(2020-1-17 2:16:12)

由于是.静态文件,直接放在了.wwwroot文件夹下.直接可以访问.
不使用Tomcat?(2020-1-17 2:17:27)

求解(2020-1-17 1:48:04)

其他

4-然后访问tomcat下面的cccBlog下面的index.html就可以了。

5-需要注意的是:图片资源命名的时候不要有中文,因为中文的话服务器访问可能图片显示不出来。

如何访问(2020-1-17 1:52:35)

如上success

总结

其实就是本地产出之后.常规方法放到Tomcat(webapps)下或者不使用tomcat放到wwwroot下.

你可能感兴趣的:(公开学习记录,程序员)