vue+springboot项目在服务器上部署
1.前端vue
1.1 vue文件夹上传(不打包)
1.2 修改配置文件config文件夹
1.2.1 index.js
-
dev-host改成服务器ip(10.0.3.31) dev-port改端口
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: localhost, // can be overwritten by process.env.HOST port: 8013, // 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: true, // 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 } }
1.2.2 dev.env.js
-
npm run dev时,本地运行http://localhost:8000 服务器运行http:// + ip + : + 端口
use strict const merge = require(webpack-merge) const prodEnv = require(./prod.env) module.exports = merge(prodEnv, { NODE_ENV: "development", //BASE_API: "http://10.0.3.31:8000" BASE_API: "http://localhost:8000" })
1.2.3 prod.env.js
-
npm run build时,打包后放的服务器ip 部署服务器http:// + ip + : + 端口
use strict module.exports = { NODE_ENV: "production", BASE_API: "http://10.0.3.31:8000" }
1.3 start.sh 启动服务
-
由于在服务器上直接使用命令启动,在ctrl + c之后会中断服务,故使用nohup脚本启动 .sh脚本给执行权限,start.sh变绿
chmod 775 start.sh
1.4 启动后查看进程
-
lsof -i: + 端口 关kill
lsof -i:8013 查前端进程
2.后端springboot
2.1 打包
-
检查pom.xml文件,使用mvn clean package命令打包
2.2 上传jar包
2.3 start.sh
2.4 进程
ps -ef|grep frame kill -9 + 进程号
2.5 查看报错详情
tail -f nohup.out vi nohup.out :q
上一篇:
IDEA上Java项目控制台中文乱码