简体   繁体   English

如何在apache上部署vuejs / flask项目

[英]how to deploy a vuejs/flask project on apache

I've created a simple project with vuejs as the frontend and flask as backend. 我创建了一个简单的项目,其中vuejs为前端,flask为后端。

The project was constructed by following the example here , thus the resultant file structure is like that the vuejs build files "dist" is on the same folder as that of the driving python script, run.py. 通过按照此处的示例构建项目,因此生成的文件结构类似于vuejs构建文件“ dist”与驱动python脚本run.py所在的文件夹中。

在此处输入图片说明

The project was tested and working fine locally now I ran into problems trying to deploy it on my Ubuntu server hosted by digitalocean. 该项目已经过测试并且在本地可以正常运行,现在我遇到了在将其部署在由digitalocean托管的Ubuntu服务器上时遇到的问题。

I followed this article to learn how to deploy - the article was well written but I believed I need to change the apache config file (/etc/apache2/sites-available/000-default.conf) a little to specify the static files of my project as shown in the screenshot. 我按照本文学习了如何进行部署-文章写得不错,但是我相信我需要稍微更改apache配置文件(/etc/apache2/sites-available/000-default.conf),以指定的静态文件。屏幕截图中显示了我的项目。

The question is how? 问题是如何? I don't know. 我不知道。 When I followed the article word by word and launched the web app, it showed errors like: 当我逐字关注文章并启动Web应用程序时,它显示了以下错误:

Loading failed for the <script> with source “http://my_website.com/static/js/manifest.0e78d562f6b86d93f516.js”. vue-amazon:1:1

static is a standard vuejs folder under "dist" in my file structure. static是我文件结构中“ dist”下的标准vuejs文件夹。

I found the issue has nothing to do with the way how Flask project is deployed - it's about the configuration of the vuejs frontend. 我发现问题与Flask项目的部署方式无关-与vuejs前端的配置有关。

I need to adjust the setting of assetsPublicPath in vuejs's config file, to a proper location where the index.html can find the obfuscated javascripts. 我需要将vuejs的配置文件中的assetsPublicPath的设置调整到index.html可以找到混淆的javascript的正确位置。

For example, if my project is called "ABC", and i want the url looks like: 例如,如果我的项目名为“ ABC”,而我希望该网址看起来像:

http://my-site.com/ABC

I need to have this in the vuejs config file: 我需要在vuejs配置文件中包含此文件:

env: require('./prod.env'),
index: path.resolve(__dirname, '../../dist/index.html'),
assetsRoot: path.resolve(__dirname, '../../dist'),
assetsSubDirectory: 'static',
assetsPublicPath: '../../ABC/dist/',

before I run 在我跑步之前

npm run build

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM