简体   繁体   English

在 Raspberry LAMP 服务器上部署 Flutter web 应用程序

[英]Deploy a Flutter web application on Raspberry LAMP server

I've created a LAMP server on my raspberry pi, thinking to develop a Flutter web application on it.我在我的树莓派上创建了一个 LAMP 服务器,想在上面开发一个 Flutter web 应用程序。 I started with the Flutter demo project and build it with the “web” option.我从 Flutter 演示项目开始,并使用“web”选项构建它。 Then I've transfered the content of created “web” folder to /var/www/html/ on my raspberry pi.然后我将创建的“web”文件夹的内容转移到我的树莓派上的/var/www/html/。 But all I can get is a blank page when I open the webapp on my browser.但是当我在浏览器上打开 web 应用程序时,我只能得到一个空白页面。 I'm novice in web developing and I'm missing something.我是 web 开发的新手,我缺少一些东西。 Any suggestions?有什么建议么? I need to install on LAMP some engine?我需要在 LAMP 上安装一些引擎吗?

LAMP = Linux, Apache, Mysql, PHP/Python/Perl... LAMP = Linux、Apache、Mysql、PHP/Python/Perl...

Now Releasing a flutter app is quite different.现在发布 flutter 应用程序是完全不同的。 (see https://docs.flutter.dev/deployment/web ) but is same as Angular or React. (参见https://docs.flutter.dev/deployment/web )但与 Angular 或 React 相同。 You have to build it for web.您必须为 web build它。 Like convert dart code to Javascript, html, css.像将 dart 代码转换为 Javascript、html、ZC7A628CBA22E28EB17B5F5CAZAE2A26。

It should have this directory structure:它应该具有以下目录结构:

/build/web
  assets
    AssetManifest.json
    FontManifest.json
    NOTICES
    fonts
      MaterialIcons-Regular.ttf
      <other font files>
    <image files>
  index.html
  main.dart.js
  main.dart.js.map

Now, since you have LAMP, You only need Apache for running this.现在,既然你有 LAMP,你只需要 Apache 来运行它。 If you upload /build/web to /var/www/html/如果您将 /build/web 上传到 /var/www/html/

then you can access it as http://SERVERIP/build/web/然后你可以访问它 http://SERVERIP/build/web/

But if you upload contents of /build/web directly on /var/www/html/ then there is no need to look for subdirs.但是,如果您直接在 /var/www/html/ 上上传 /build/web 的内容,则无需查找子目录。

/build/web/index.html should be in /var/www/html/index.html /build/web/index.html应该在/var/www/html/index.html

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

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