# 网站的部署根路径
kedao中间件的网站部署根目录为 bin 下的 www 。
# 设置网站的部署路径
以kedao中间件提供的 vue 项目为例,需要设置 vue.config.js 文件中的 publicPath,如:
'use strict'
const path = require('path')
const defaultSettings = require('./src/settings.js')
let CompressionPlugin = require("compression-webpack-plugin");
const JavaScriptObfuscator = require('webpack-obfuscator');
const encryption = true;
function resolve(dir) {
return path.join(__dirname, dir)
}
const name = defaultSettings.title || 'vue Admin Template' // page title
// If your port is set to 80,
// use administrator privileges to execute the command line.
// For example, Mac: sudo npm run
// You can change the port by the following methods:
// port = 9528 npm run dev OR npm run dev --port = 9528
// const port = process.env.port || process.env.npm_config_port || 8011 // dev port
// All configuration item explanations can be find in https://cli.vuejs.org/config/
module.exports = {
/**
* You will need to set publicPath 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 publicPath should be set to "/bar/".
* In most cases please use '/' !!!
* Detail: https://cli.vuejs.org/config/#publicpath
*/
publicPath: process.env.VUE_APP_PUBLIC_PATH,
outputDir: 'dist',
assetsDir: 'static',
productionSourceMap: false,
lintOnSave: process.env.NODE_ENV === 'development',
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
这里 publicPath 的值通过环境变量 process.env.VUE_APP_PUBLIC_PATH 来设置。
打开环境变量配置文件(以 .env. 开头的文件,比如生产环境的环境变量文件:.env.production),找到 VUE_APP_PUBLIC_PATH,修改其值, 如:
# 部署时相对于www根目录的路径
VUE_APP_PUBLIC_PATH = '/'
2
说明:
/ : 与 www 目录对应,即表示将打包好的静态文件放到 www 目录下,访问网站时,输入网址 http://ip:port/
如果想将静态文件放到其他目录,比如 mywebsite,则将 VUE_APP_PUBLIC_PATH 的值设置为:
VUE_APP_PUBLIC_PATH = '/mywebsite'
访问网站时,输入网址 http://ip:port/mywebsite/
ip/域名,端口号,如果是默认的 80 或 443 端口,则不用输入
# 打包与发布
在 vue 项目的根目录下,执行命令:
npm run build
打包成功后,会在 dist 目录下生成静态文件
将 dist 目录下的文件(不包含dist目录)拷贝到 www 对应的目录下,如:
如果 VUE_APP_PUBLIC_PATH = '/',则直接拷贝到 www 录下
如果 VUE_APP_PUBLIC_PATH = '/mywebsite',则直接拷贝到 www/mywebsite 目录下
# 使网站生效
1、设置 bin/config.ini 文件中的健 website_release_status,将值设置为 1,如:
website_release_status=1
kedao中间件会根据状态来自动加载发布的文件,如果 website_release_status 的值变为 0,则表示加载完成。
2、重启 kedao中间件,执行命令:
sudo systemctl restart kedao