先记录查看与关闭端口的命令:
netstat -ano|findstr “8080”
taskkill /pid 5588 /f
打开某个端口:
netsh firewall add portopening protocol = TCP port = 8080 name = “Open8080” mode = Enable
查看进程: services.msc
配置
购买的腾讯轻量应用服务器,27R 3个月 内存2G 硬盘64G
ping 自己的ip地址:
什么是轻量应用服务器 Lighthouse? 轻量应用服务器
Lighthouse
是一种易于使用和管理、适合承载轻量级业务负载的云服务器,能帮助个人和企业在云端快速构建网站、博客、电商、论坛等各类应用以及开发测试环境,并提供应用部署、配置和管理的全流程一站式服务,极大提升构建应用的体验,是您使用腾讯云的最佳入门途径。轻量应用服务器与云服务器 CVM 的区别是什么? 轻量应用服务器 Lighthouse 对比云服务器
CVM,轻量应用服务器更加简单易用,融合多款云产品和应用服务能力,简化了传统云服务器的高阶概念及功能,帮助开发者更加专注于业务逻辑与创新。详情请参见
产品对比。
首先买了以后可以设置Administrator的密码,然后可以从这里进入
进入服务器的图形界面,也可以从自己电脑远程进入(输入IP 用户名和密码)
自己的项目前端是vue3.0框架,后端有springboot和flask(后者用于深度学习),由于接触计网的知识不多,所以对于服务器、http、ftp等协议方面还只是粗略了解,望指正。
解决tomcat启动中文乱码:
修改logging.properties
改为GBK
打包前端:
前端
新建vue.config.js
module.exports = {
// 项目部署的基础路径
// 我们默认假设你的应用将会部署在域名的根部,
// 比如 https://www.my-app.com/
// 如果你的应用时部署在一个子路径下,那么你需要在这里
// 指定子路径。比如,如果你的应用部署在
// https://www.foobar.com/my-app/
// 那么将这个值改为 `/my-app/`
/*这个是我存放在github在线预览的Reader项目*/
// 将构建好的文件输出到哪里(或者说将编译的文件)
outputDir: 'dist',
// 放置静态资源的地方 (js/css/img/font/...)
assetsDir: 'static',
// 用于多页配置,默认是 undefined
pages: {
index: {
// 入口文件
entry: 'src/main.js', /*这个是根入口文件*/
// 模板文件
template: 'public/index.html',
// 输出文件
filename: 'index.html',
// 页面title
title: 'Index Page'
},
// 简写格式
// 模板文件默认是 `public/subpage.html`
// 如果不存在,就是 `public/index.html`.
// 输出文件默认是 `subpage.html`.
subpage: 'src/main.js' /*注意这个是*/
},
// 是否在保存的时候使用 `eslint-loader` 进行检查。
// 有效的值:`ture` | `false` | `"error"`
// 当设置为 `"error"` 时,检查出的错误会触发编译失败。
lintOnSave: true,
// 使用带有浏览器内编译器的完整构建版本
// 查阅 https://cn.vuejs.org/v2/guide/installation.html#运行时-编译器-vs-只包含运行时
runtimeCompiler: false,
// babel-loader 默认会跳过 node_modules 依赖。
// 通过这个选项可以显式转译一个依赖。
transpileDependencies: [/* string or regex */],
// 是否为生产环境构建生成 source map?
productionSourceMap: true,
// 调整内部的 webpack 配置。
// 查阅 https://github.com/vuejs/vue-docs-zh-cn/blob/master/vue-cli/webpack.md
chainWebpack: () => {},
configureWebpack: () => {},
// CSS 相关选项
css: {
// 将组件内的 CSS 提取到一个单独的 CSS 文件 (只用在生产环境中)
// 也可以是一个传递给 `extract-text-webpack-plugin` 的选项对象
extract: true,
// 是否开启 CSS source map?
sourceMap: false,
// 为预处理器的 loader 传递自定义选项。比如传递给
// sass-loader 时,使用 `{ sass: { ... } }`。
loaderOptions: {},
// 为所有的 CSS 及其预处理文件开启 CSS Modules。
// 这个选项不会影响 `*.vue` 文件。
modules: false
},
// 在生产环境下为 Babel 和 TypeScript 使用 `thread-loader`
// 在多核机器下会默认开启。
parallel: require('os').cpus().length > 1,
// PWA 插件的选项。
// 查阅 https://github.com/vuejs/vue-cli/tree/dev/packages/@vue/cli-plugin-pwa
pwa: {},
// 配置 webpack-dev-server 行为。
devServer: {
open: process.platform === 'darwin',
host: '0.0.0.0',
port: 8080,
https: false,
hotOnly: false,
// 查阅 https://github.com/vuejs/vue-docs-zh-cn/blob/master/vue-cli/cli-service.md#配置代理
proxy:{
'/api':{
target:'http://localhost:9000',
changeOrigin:true,
secure:false,
// ws: true,
pathRewrite:{
'^/api':'/static/mock'// 请求数据路径别名,这里是注意将static/mock放入public文件夹
}
}
},
before: app => {}
},
// 三方插件的选项
pluginOptions: {
// ...
}
}
config目录下的index.js
'use strict'
// Template version: 1.2.6
// see http://vuejs-templates.github.io/webpack for documentation.
const path = require('path')
module.exports = {
dev: {
// Paths
assetsSubDirectory: 'static',
assetsPublicPath: './',
proxyTable: {},
// Various Dev Server settings
host: '121.5.227.176', // can be overwritten by process.env.HOST
port: 8080, // can be overwritten by process.env.PORT, if port is in use, a free one will be determined
autoOpenBrowser: true,
errorOverlay: true,
notifyOnErrors: false,
poll: false, // https://webpack.js.org/configuration/dev-server/#devserver-watchoptions-
// Use Eslint Loader?
// If true, your code will be linted during bundling and
// linting errors and warnings will be shown in the console.
useEslint: false,
// If true, eslint errors and warnings will also be shown in the error overlay
// in the browser.
showEslintErrorsInOverlay: false,
/**
* Source Maps
*/
// https://webpack.js.org/configuration/devtool/#development
devtool: 'cheap-source-map',
// CSS Sourcemaps off by default because relative paths are "buggy"
// with this option, according to the CSS-Loader README
// (https://github.com/webpack/css-loader#sourcemaps)
// In our experience, they generally work as expected,
// just be aware of this issue when enabling this option.
cssSourceMap: false
},
build: {
// Template for index.html
index: path.resolve(__dirname, '../dist/index.html'),
// Paths
assetsRoot: path.resolve(__dirname, '../dist'),
assetsSubDirectory: 'static',
/**
* You can set by youself according to actual condition
* You will need to set this if you plan to deploy your site under a sub path,
* for example GitHub pages. If you plan to deploy your site to https://foo.github.io/bar/,
* then assetsPublicPath should be set to "/bar/".
* In most cases please use '/' !!!
*/
assetsPublicPath: './',
/**
* Source Maps
*/
productionSourceMap: false,
// https://webpack.js.org/configuration/devtool/#production
devtool: 'source-map',
// Gzip off by default as many popular static hosts such as
// Surge or Netlify already gzip all static assets for you.
// Before setting to `true`, make sure to:
// npm install --save-dev compression-webpack-plugin
productionGzip: false,
productionGzipExtensions: ['js', 'css'],
// Run the build command with an extra argument to
// View the bundle analyzer report after build finishes:
// `npm run build --report`
// Set to `true` or `false` to always turn it on or off
bundleAnalyzerReport: process.env.npm_config_report || false,
// `npm run build:prod --generate_report`
generateAnalyzerReport: process.env.npm_config_generate_report || false
}
}
其实还不明白这两个的区别。
输入:
npm run build prod
生成dist
后端
jar包:
打开后端项目(IDEA)先点击clean再点击package
生成
发现 问题:(1)服务器的浏览器输入8080一片空白,
解决:只把dist复制到了ROOT目录下,但应该把index.html和static复制到下面才行,重新改为:
打开8080显示登陆页面:
问题(2)点击登录没反应,进不去
解决:
1.
修改vue.config.js
proxy:{
'/api':{
target:'http://localhost:9000',
changeOrigin:true,
secure:false,
// ws: true,
pathRewrite:{
'^/api':'/static/mock'// 请求数据路径别名,这里是注意将static/mock放入public文件夹
}
}
},
(后端springboot的application.yml中端口是9000:
server:
port: 9000
)
再次输入npm run build prod
粘贴index.html和static
2.一定要记得启动jar包 !!!!!
启动jar的方式是双击这个文件:
现在点击登录有反应了:
下一个问题是数据库的数据在服务器上还显示不出来,留待解决。